I am on Ubuntu 14.04.3 platform. While I was compiling a project it asked cmake version 3.2 which is not present in my system. I compiled the latest version of cmake from source code and installed it into /usr/local/bin directory. When I attempt to compile project again, its cmake detects the cmake in /usr/bin which is lower version. Then cmake ..
process aborts with lower version error. Is there any built-in cmake variable or environment variable for setting path of the cmake?
EDIT:
I just found a cmake variable CMAKE_COMMAND that supposedly does what I want.
But when I insert CMAKE_COMMAND = /usr/local/bin/cmake line into cmakelist.txt then I go to build directory and issue /usr/local/bin/cmake ..
I get :
Expected a command name, got unquoted argument with text
I searched for it on the net but didn't find a solution.
If you have different versions of a software or library installed you may use stow to install and switch between the two. Especially if you want to install a newer version of a software that is not available in one's Linux distribution. So in case the new version is not yet stable you can still switch to the previous one. For example while building cmake 3.2 you can specify the prefix as
./configure --prefix=/usr/local/stow/cmake-3.2/
and then
cd /usr/local/stow
sudo stow cmake-3.2
and if you want to remove the links you can use the following command
sudo stow --delete cmake-3.2
Please keep in mind stow does not delete files. It only makes and deletes links.
Related
I have Apple's command line tools version 9.1 installed and am working through an LLVM tutorial. I need to use some libraries like llvm/ADT and llvm/IR but get an error when I run the code.
main.cpp:1:10: fatal error: 'llvm/ADT/APFloat.h' file not found
#include "llvm/ADT/APFloat.h"
^~~~~~~~~~~~~~~~~~~~
1 error generated.
I also don't seem to have tools such as the assembler. Are these things not usable with Apple's version? And can I install LLVM without conflicting with Apple's version?
Apple's fork misses most of the library,headers and command-line tools in the llvm trunk.
I suggest you compile a new llvm copy from trunk.
Conflicting depends on how you configure everything. You can:
Install your new copy to global location, where your $PATH configuration is responsible for choosing which version to use.
Install as a separate Xcode Toolchain.
Here is a build script I've been using:
cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Release -DLLVM_APPEND_VC_REV=on -DLLVM_ENABLE_EH=on -DLLVM_ENABLE_RTTI=on -DLLVM_CREATE_XCODE_TOOLCHAIN=on -DCMAKE_INSTALL_PREFIX=~/Library/Developer/ ../LLVM
Running ninja install will install to global location, otherwise run ninja install-xcode-toolchain to install as a separate toolchain
In your case I suggest installing to global location to avoid the trouble of messing with CFLAGS/LDFLAGS/Header Search Path. Then remove the installation manually after you are done with the tutorial
EDIT: You might also want to check out the official build guide https://llvm.org/docs/CMake.html
For your use case, in-tree building is also a feasible option(Providing you are familiar with write cmake configs)
Actually, there is no need to build the LLVM yourself. You can get prebuilt version for your platform here: http://releases.llvm.org
In your case it would be something like this:
cd /opt
wget http://releases.llvm.org/5.0.0/clang+llvm-5.0.0-x86_64-apple-darwin.tar.xz
tar xvf clang+llvm-5.0.0-x86_64-apple-darwin.tar.xz
mv clang+llvm-5.0.0-x86_64-apple-darwin llvm-5.0.0
After that you will have everything under /opt/llvm-5.0.0, e.g.:
/opt/llvm-5.0.0/bin/clang
/opt/llvm-5.0.0/bin/llvm-config
/opt/llvm-5.0.0/lib/libc++.a
etc.
P.S. I use /opt just as an example, feel free to pick any other directory that fits you best.
I downloaded:
https://mingw-w64.org/doku.php/download/mingw-builds
https://mingw-w64.org/doku.php/download/msys2
and installed them under C:/development/msys64. Under this folder I find the msys2.exe and the mingw64 folder, which in turn contains the bin one with all the mingw executable.
I added C:/development/msys64/mingw64/bin folder to the PATH env var.
In fact from a Windows prompt I can invoke the gcc - for example. Instead inside the msys2 shell I cannot find them. I mean, they are in /mingw64/bin but they are not available at prompt.
I'm sure I missed some steps!
Method to switch from MinGW-w32 to MinGW-w64
Download the executable file of MinGW-w64 Refer the EDIT
(Executable file link may change for future releases, this is for Version 8.1.0, Kindly cross verify the latest version before installing from this link)
Installation Process (In Settings):
Version: PICK LATEST
Architecture: x86_64
Threads: posix
Exception: seh
If anyone is trying to add MinGW-w64 as a PATH variable and is not able to find the gdb.exe in C:\msys64\mingw64\bin, try looking for it in the Program files.
C:\Program Files\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin
The gdb.exe and other files are located in this directory.
EDIT:
After making some changes in the launch.json file in VSCode, the MinGW-w64 GDB debugger started giving errors because there was 2 versions of MinGW in different folders i.e, MINGW and mingw64!
It is essential that the installation path does not contain any spaces
(i.e., space in "Program Files"), this will create conflicts later.
STEPS:
1. Uninstalled all the versions of GCC that was installed in the PC - Cygwin, MSYS2(32 bit) and mingw64(64 bit) and installed the MinGW-w64 again, this time using the MSYS2.
Please start afresh, if debugger is giving errors and if versions are clashing!
2. Download the MSYS2 installer from this link.
Install process is simple, follow the steps mentioned in the website!
It is essential that the installation path does not contain any spaces. Therefore, we cannot install MinGW-w64 in Program Files.
3. After Installation is complete: Open MSYS2 terminal (pink icon).
Update the package database and base packages using:
pacman -Syu
After this, Update rest of the base packages using:
pacman -Su
4. Now switch over to MSYS2 MinGW 64-bit terminal (blue icon).
To install gcc and g++ for C and C++.
For 64 bit:
pacman -S mingw-w64-x86_64-gcc
To install debugger (gdb).
For 64 bit:
pacman -S mingw-w64-x86_64-gdb
5. Now you're all SET!
Check versions:
gcc --version
g++ --version
gdb --version
6. Finally, remove the old environment variables if any are left and add the new environment variable to the PATH!
BEFORE DEBUGGING FILES IN VSCode, MAKE SURE TO ADD -g tag while building, otherwise breakpoints will be ignored by the debugger!
Footnote:
It's very important to keep all the versions in one folder, if folders are different, then life will get tough later!
MSYS2 has packages for its own GCC toolchains and you would probably be better off using those toolchains instead of downloading a different one. For example, to use a 64-bit MinGW GCC, you would have to run pacman -S x86_64-w64-mingw32-toolchain and then make sure you are starting MSYS2 using the "MinGW-w64 64-bit Shell" shortcut (or something like that) so that /mingw64/bin is on your PATH.
Also, MSYS2 does not respect your system or user environment variables; it uses its own PATH by default.
I am a non-administrator user of a Linux (CentOS 6.6) server at work. I log in through a terminal program on a windows computer. My problem is that the IT does not feel comfortable upgrading GCC/gfortran for me so I want to just run it from my personal folders. They claim the latest yum (devtoolset-3 for this OS version) will downgrade some other feature they have. It's not the latest version of GCC anyway.
I have downloaded the latest GCC 5.3 binaries and prerequisites from gfortran.com and can almost get my test code to compile. Actually, when I do the following it will compile with -c but will not not link. That folder is where I put the prerequisites and also I copied stuff from the /usr/lib64 directory into there as well.
LD_LIBRARY_PATH=/users/home/me/me/gcc53mark/my_lib
export LD_LIBRARY_PATH
./gfortran test.f90
The error message is as follows:
collect2: fatal error: cannot find 'ld'
But ld does exist
-bash-4.1$ whereis ld
ld: /usr/bin/ld /usr/share/man/man1/ld.1.gz
After much effort I have answered my own question! To install GCC to my own personal Linux account as a non-administrator, I ended up having to compile GCC and not use the binaries I originally downloaded. My friend was make install which knows where everything needs to go, which I did not have with the binaries.
The key was to install to my user root directory /GCC with the following command provided with the build-it-yourself method (-prefix):
../gcc-5.3.0/configure --prefix$HOME/gcc-5.3.0 --enable-languages=c,c++,fortran --disable-multilib
For me I had to disable multilib because I guess my system only has 64 bit libraries (I think this was causing my original problem).
Before I got to that point, I had to also download the prerequisites manually since my workplace I suppose blocks the automatic prerequisite downloader as referenced in these instructions.
https://gcc.gnu.org/wiki/InstallingGCC
Prerequisites need to be taken from here, placed into the root of the directory that gets created when you unzip GCC. Then unzip them and link them as is done in the batch file you have already unzipped ./contrib/download_prerequisites.
ftp://gcc.gnu.org/pub/gcc/infrastructure/
Finally I need to run the following command, after it is all up so it looks at the new libraries. I will add this to my .profile when I am ready to fully switch to the local newer version.
LD_LIBRARY_PATH=/users/home/myself/gcc-5.3.0/lib64
export LD_LIBRARY_PATH
For now I am running gfortran with the following command but also I will add this to my .profile later.
/users/home/myself/gcc-5.3.0/bin/gfortran Test.f90
It works! Latest version of GCC running from my local Linux user non-administrator account!
Edited to add how we resolved this for the network group:
IT did not want to overwrite the original installation so we installed to some network folder /gcc-5.3.0 . Then we modified the group's .profile to add the library and binary paths to that, before the standard path.
I've installed XCode v3.1.3 and am having difficulties using the rumored GCC that is installed along with it. -- I'm certainly able to use the XCode IDE to compile my programs but would like the flexibility of also using the command line...
Where's GCC?
Look in /Developer/usr/bin
The most likely explanation is that when you installed the Developer tools you unchecked "UNIX Development Support", so the command line tools were never installed. Delete your /Developer/ directory and do a clean install of the tools; make sure to select "configure" during the installation process and ensure that the appropriate items are checked.
In /usr/bin you should find gcc-4.0 and gcc-4.2 and then there will be a symbolic link gcc which points to one of these (usually gcc-4.2).
As always, you can find out where any available command in your PATH is located using which, e.g.
$ which gcc
I have installed Cygwin on my system. But when I try to use the gcc command it says:
bash: gcc: command not found
Can anyone provide me the solution, please?
In my installation there was no generic gcc command either, so I made a symlink for it:
cd /usr/bin
ln -s i686-pc-cygwin-gcc-3.4.4.exe gcc
Now check if it worked by doing which gcc which should give you /usr/bin/gcc and then gcc should give you gcc: no input files. Note that your version of i686-pc-cygwin-gcc-3.4.4.exe may be different. Check in /usr/bin for it.
Maybe during installation of Cygwin you have not selected gcc, gdb and make packages.
I had the same problem and it was resolved after I selected above-mentioned packages.
A couple of things:
I always install the whole Cygwin package. Earlier versions had troubles with dependencies that are fixed now, I believe, but it's still a good habit. You never know when you may need the most esoteric bit of Cygwin.
You may have to change your path. All the tools can generally be found okay if you're running inside the Cygwin bash shell but that's not necessarily the case from cmd.exe.
It's unlikely to be that last one since your error message is coming from bash itself, so I'm pretty certain that's how you're running it.
Have a look to make sure you have /usr/bin/gcc from within bash and that your path includes /usr/bin somewhere:
pax> echo $PATH
/usr/local/bin:/usr/bin:/bin:/cygdrive/c/WINDOWS/system32:/cygdrive/c/WINDOWS
pax> which gcc
/usr/bin/gcc
If it's not there, go back and re-install everything (or the relevant development package if you don't want everything). If it is there and your path doesn't have its location, change your path, in either /etc/profile or the equivalent in your home directory.
Another related issue that wasn't mentioned here, is from the command line the compiler needs the environment path variable updated to find the location of the c++ header files. In windows you can just update the path environment using the 'advanced system properties' GUI and add the location of the c++ include files. This will update the PATH environment variable in Windows cmd & Cygwin automatically upon restarting the shell.
To update your PATH from Linux or the Cygwin shell type... PATH=$PATH:/your_path_here Example:PATH=$PATH:/cygdrive/c/cygwin/lib/gcc/i686-pc-mingw32/4.7.3/include/c++ Also a good idea to add just the include directory as well: PATH=$PATH:/cygdrive/c/cygwin/lib/gcc/i686-pc-mingw32/4.7.3/include/ ...or check the proper directories for the location of your installation's include files, I recommend installing mingw for use with Cygwin, which is envoked with g++.
To install additional needed packages in Cygwin re-run the Cygwin install utility & check install from Internet to add packages from web repositories and add mingw-gcc-g++ & mingw-binutils. To compile your code: g++ hello.cpp -o hello
If using the gcc utility instead compile with the command: gcc hello.cpp -o hello -lstdc++ ... to get your executable.
As long as you have either gcc or mingw installed and the path to the c++ include files is in your path environment, the commands will work.
There is another hard to spot mistake could also cause this error,
If your Makefile uses PATH as variable, the gcc not found error could happen.
This is because it changes the system path temporarily.
I took a lot of time checking the cygwin environment setting to discover this, so I'll leave it here in case this helps anyone finding their way here.