This question already has answers here:
Installing gcc on linux without c compiler
(5 answers)
How install gcc on Linux without compiler
(2 answers)
Closed 9 months ago.
I have a problem that has caused me quite a few headaches and I would like some help from one of you.
I have a Linux operating system installed on my computer. The problem is that it doesn't have the GCC compiler and I would like to build it myself from source code.
The first thing I do is download GCC from its official repository (Latest version)
git clone git://gcc.gnu.org/git/gcc.git
Next, I unzip the GCC .tar.xz package and run the file called configure
At compile time, the process tells me that to compile GCC, I need gawk and bison, and this is where the problem comes.
To install either of those two tools (By source code), I need to have the compiler installed. So it goes like this,
GCC needs GAWK and BISON
GAWK and BISON needs GCC
What could I do?
Thank you!
Related
I'm trying to compile a test openmp program on an Amazon AWS t2.micro instance. It seems to have trouble. Upon trying to compile this OpenMP hello world program, the compiler fails to find omp.h despite using gcc hello_world.c -fopenmp.
After that, I tried running locate omp.h and found it in /usr/lib/gcc/x86_64-amazon-linux/4.8.5/include. I next attempted to compile by including that directory with gcc -I. Then, the compiler still needed libgomp.spec, which has been encountered and solved in this stack overflow question.
Following the most upvoted answer on there by creating some symbolic links did nothing for me and still says error: libgomp.spec: No such file or directory, even though libgomp.spec is in my /usr/lib64 directory.
So, what can I do to fix this, and why won't -fopenmp work on amazon linux like expected? This is done on an instance which was created by CfnCluster, if that helps.
As usual, header files such as omp.h come with relevant version of gcc compiler. When the compiler can't find the header file, I guess you are using the different version compiler (other than 4.8.5 in this case).
You can find all gcc versions by typing:
sudo yum list installed | grep gcc
If there are other versions of gcc such as gcc72, you can erase them by:
sudo yum erase gcc72
After that, you will compile the code successfully.
Exactly, as told #S.Takezawa , currently only gcc 6.4 installation supports libgomp (fopenmp) and supports modern c++14 standard on Amazon AMI linux.
gcc4.7 is too old. So this helps for me:
sudo yum install gcc64-c++.x86_64 libgcc64.x86_64
Im running Matlab on linux (Elementary OS)
The problem im facing is that Matlab isnt compatible with the gcc compiler higher than 4.9.
Same question as: https://www.mathworks.com/matlabcentral/answers/348906-downgrading-gcc-g-for-use-with-mex
When I use "sudo apt get install gcc" 5.4 is automatically installed. When I remove 5.4, Matlab will not recognize 4.9 which I've installed. How do I get Matlab to recognize gcc/g++ 4.9 as my compiler?
I've also followed this but it didnt resolve the problem:
https://www.mathworks.com/matlabcentral/answers/137228-setup-mex-compiler-for-r2014a-for-linux#answer_263109
Any help would be greatly appreciated.
When I remove 5.4, Matlab will not recognize 4.9 which I've installed. How do I get Matlab to recognize gcc/g++ 4.9 as my compiler?
I use Ubuntu (from which you OS is derived) and have had a similar issue. Basically, you can use update-alternative to switch between gcc versions on your choice. Here is a link that explains how to do it.
Here is the documentation on update-alternative, if you need more in-depth knowledge of its functionalities.
Note that uninstalling the default gcc for your distro (5.4 in your case) is no longer required with this solution: you can switch back to it for you development when not using Matlab. You can even install more than two versions of gcc if needed.
Hope this solves your issue.
There is no reason to downgrade GCC for MATLAB.
The reason you run into issues on Linux is because MATLAB installs its own copies of the GCC libraries. If your MEX-files expect newer libraries, they'll fail. You can delete the GCC libraries that come with MATLAB, and it will use the newer ones on your system.
The libraries are at $(MATLABROOT)/sys/os/glnx86 for 32-bit MATLAB, and $(MATLABROOT)/sys/os/glnxa64 for 64-bit MATLAB. $(MATLABROOT) is the installation root for MATLAB.
The files in question are libgcc_s.so*, libstdc++.so* and libg2c.so* (or at least they used to be called like this, I don't have a Linux MATLAB installation here to double-check).
This trick worked for MATLAB 7.0, and still worked a month ago when I suggested this to a colleague.
I do recommend that you rename or move the files, so you can replace them if things go sour.
You will need to restart MATLAB after this change, of course.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
I downloaded the MATLAB code from here http://cazencott.info/dotclear/public/code/scones.zip. When I run 'demo', it says "Undefined function 'maxflowmex' for input arguments of type 'double'". In fact there is only a c++ file "maxflowmex.cpp" in the folder (already added to path). Whether it needs a "maxflowmex.m" instead of "maxflowmex.cpp" to run properly? Or some other methods to call "maxflowmex.cpp"? Or I need to compile something?
I just took a look at the zip file. There are MEX wrappers in the maxflow directory that are written where MATLAB calls these functions which are written in C, but are runnable in MATLAB. These MEX wrappers need to be compiled using a compiler that is compatible for your operating system before you run them.
However, there are pre-compiled binaries, but I only see 64-bit binaries for Linux and Mac OS and I don't see Windows binaries. Because you can't run them, you are most likely running a 32-bit operating system or Windows. I suspect you are running either Windows or 32-bit Linux, as Mac OS by default ships out as 64-bit.
There is a make.m script that you need to run so that you can compile the maxflow library for your machine. Once you compile the library, running demo.m should be successful.
Before you do that, you need to make sure you set up mex by doing mex -setup in the command window, then choose the right compiler. Once you do this, run make.m that's inside the maxflow directory.
If you don't have a compiler, if you're using Linux, doing an apt-get on the gcc packages should be good enough, so:
sudo apt-get update
sudo apt-get install gcc-4.6-base g++-4.6 cpp-4.6 libgomp1 libquadmath0 libc6-dev
If you are using Windows, then the supported compiler that you need will depend on what version of MATLAB you are using. I'm assuming you are using the latest one, and so downloading the latest version of Visual Studio Express as well as the SDK should be sufficient.
http://www.visualstudio.com/en-us/products/visual-studio-express-vs.aspx
http://www.microsoft.com/en-us/download/details.aspx?id=40758
This question already has answers here:
Changing default C compiler in Linux, using SCons
(2 answers)
Closed 9 years ago.
I need to compile plugins for nuke. Im using centos 6.4 with gcc version 4.4.7 20120313 (Red Hat 4.4.7-3) (GCC). On my binary folder I only have gcc and g++. I cant put a different version at the makefile. And Nuke its compiled with 4.1.
I'm not an expert in linux neither GNU, but I had the idea, once you have the newer you can tell g++ to compile the project with a different version.
Something like:
MYCXX ?= g++-4.1
LINK ?= g++-4.1
as you are using linux you have following options:
Use update-alternative command
for example:
update-alternatives --config gcc
Note: i assume you have installed multiple version of gcc.
Or Commad
CC="gcc-VERSION" make
First you must install gcc 4.1 in your linux, and set its path to your PATH environment, just like this:
export PATH=gcc4.1-path:$PATH
This will make your default gcc to be gcc 4.1version. then make nuke directly.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I was wondering if it is possible to install multiple versions of g++ on the same machine without any problem.
I use the almost current gcc for my work(4.6.1). Now for my studies, my teacher has given us an incomplete project to complete and he says we should install gcc 3.4.3 .
please note that I have already read this : Is it possible to install 2 different versions of GCC at the same time? but I don't know what PATH I should set.
Moreover, I would like to use eclipse for both version. So I may need some guidance for that settings too.
Thank you very much
In bash you could do two scripts like this:
first one:
export PATH=/path/to/your/3.4.3/bin:$PATH
eclipse&
and
export PATH=/path/to/your/4.6.1/bin:$PATH
eclipse&
By running one of those, eclipse should use first gcc it finds in your path. Also your default gcc should still be primary, if you don't run any scripts.
BTW:
You can probably strike a deal with your professor on what c++ standard he wants you to use (and what libraries), not what outdated version of compiler you should use to compile your code.
If you are using some Linux distribution, you can install several versions of GCC; for instance on Debian or Ubuntu you could install both gcc-4.6 and gcc-4.7 (the exact versions available depend upon the actual distribution).
Notice that GCC 3.4.3 is a very ancient version of the compiler (it has been released in november 2004). You may have trouble to install such an ancient version of GCC on your machine. Notice also that recent GCC (last version is 4.7) gives much better warnings, optimizations, and standard conformance than ancient version.
Of course, you don't need eclipse to use GCC. You could use some plain editor like gedit or emacs, and compile either on a command line (if you have only one file) or using a builder like make.
I would not bother installing GCC 3.4.3 on a recent machine (i.e. any Linux distribution from the last few years), because you could spend more than a week in installing such an old thing, and still fail. I would use the latest GCC available on that machine, always compile with -Wall -g and ask (or tell) my teacher about it.
Learn also to use the gdb debugger, and some version control like git.
The hints I gave here are probably relevant to you.