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.
Related
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 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.
I am currently trying to build a gcc 4.4 on a newly updated ubuntu 11.10. However building the compiler always fails with some problems, when trying to bootstrap.
First crti.o and crtn.o could not be found. I symlinked them into another directory within the search path, and so I could get a bootstrap compiler. However now it fails with the message:
configure: error: C compiler cannot create executables
I tried out to use the intermediate compiler on a simple test program, and I get the message:
$ ./host-x86_64-unknown-linux-gnu/prev-gcc/xgcc test.c
xgcc: error trying to exec 'cc1': execvp: File or directory not found
So something is seriously messed up with the paths of my intermediate compiler it seems. When I did the same thing on ubuntu 11.04 everything just worked fine.
I used the following command line to configure:
./configure --prefix=/opt --program-suffix=44
I also tried both a VPATH-built, as well as an in source build, but both have the same problem. I still have the gcc44 from before the update lying around within /opt, but it has become unusable since the update.
Is there any easy way to get gcc 4.4 working under Ubuntu 11.10? I does not have to be a self build compiler, if I can just download a package and install that, it would be fine as well.
This is caused by Ubuntu's switch to multi-arch. Basically all the "standard" paths have been changed so you can install libraries for multiple architectures on the same machine without any clashes.
Ubuntu GCC has been patched to fix the problem, of course, but the upstream compiler still wasn't fixed last time I checked.
See here: https://askubuntu.com/questions/69365/cant-build-gcc-anymore-since-upgrade-to-11-10
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.
From llvm.org I've downloaded llvm-2.6-x86-mingw32.tar.bz2 into c:\llvm and llvm-gcc-4.2-2.6-x86-mingw32-tar.bz2 into c:\llvm-gcc as well as setup a desktop shortcut the following batch file in c:\llvm-gcc which attempts to setup an environment for compiling via the llvm-gcc command line too:
#echo off
color 0E
echo Configuring LLVM environment...
set LLVM_LIB_SEARCH_PATH=%~dp0lib
set PATH=c:\llvm;%~dp0bin;%PATH%
Unfortunately, this setup gives the following error when trying to compile a simple hello world program:
C:\CDev\sandbox>llvm-gcc -o hello.exe hello.c
llvm-gcc: CreateProcess: No such file or directory
I've briefly looked through the LLVM binaries and it appears that the MinGW-based Win32 API and runtime files are already included. I also tried adding the MinGW DLL to c:\llvm-gcc\bin to no avail.
What have I missed in setting up the binary LLVM environment and GCC-based front end on Vista?
Thanks, Jon
Because the GNU/MinGW assembler 'as' was required by 'llvm-gcc' to generate the obj file. The problem can be solved by using:
Install GNU/MinGW binutils, extract the as.exe into c:\llvm-gcc\bin
Install a full MinGW package, add %MinGW%\bin your %PATH%
#rwallace is correct that one needs to also install MinGW's binutils along with the LLVM binary download. I've updated the LLVM documentation appropriately at
http://llvm.org/docs/GettingStarted.html#installcf
As far as I can tell, the answer is that the MinGW distribution supplied by LLVM is not complete, in particular, it doesn't come with the 'binutils' programs.
The recommended solution seems to be to download and install MinGW yourself. However, the MinGW download page seems to be saying this requires 10 different packages to be downloaded and installed separately.
The solution I tried today was to use the MinGW that comes with Qt, which does come in a single package; thus far, that appears to work.
It seems like it is looking for the base MinGW installation in C:\MinGW. I just had this error today using gcc.exe in msys. To solve it, I created a symbolic link from c:\msys to c:\MinGW and everything worked.