I've been struggling with this issue for several weeks now, working it off and on. I've got Ubuntu running on Windows. I also installed OpenFOAM to analyze CFD simulations. My issue is the default the gcc called at the command prompt is the OpenFOAM one.
$ gcc --version
gcc (OpenFOAM) 6.3.0
I needed updated libraries installed for something else I'm working on. I managed to get all the libraries installed, but linux is still looking to the OpenFOAM version of gcc (which doesn't see the libraries) when I run the program at the command prompt. I am calling a shell scrip that in turns calls other programs, so I cannot determine a way to directly call out the full path to the desired gcc version.
I've worked out that the bash gcc command is actually linked to three versions of gcc:
$ type -a gcc
gcc is /opt/OpenFOAM/OpenFOAM-v2012/ThirdParty/platforms/linux64/gcc-6.3.0/bin/gcc
gcc is /usr/bin/gcc
gcc is /bin/gcc
This leads me to believe that the shell scrip is going to the first one and ignoring the next two. How do I get it to go to the second?
i.e. so terminal would return
gcc is /usr/bin/gcc
gcc is /bin/gcc
gcc is /opt/OpenFOAM/OpenFOAM-v2012/ThirdParty/platforms/linux64/gcc-6.3.0/bin/gcc
This should yield the correct version of gcc being called and the installed libraries I need to be referenced at runtime.
$ which gcc
/opt/OpenFOAM/OpenFOAM-v2012/ThirdParty/platforms/linux64/gcc-6.3.0/bin/gcc
I was expecting this to return /usr/bin/gcc instead.
I tried appending the /bin/gcc/ to the front of the path variable:
$ export PATH = /usr/bin/:$PATH
without success. (edited for syntax)
I also researched installing multiple versions of gcc on Ubuntu and worked out there is a command that should permit me to do what I'm trying to, but it doesn't work:
$ sudo update-alternatives --config gcc
update-alternatives: error: no alternatives for gcc
I was expecting to be able to select which version of gcc was called.
Thanks for rici's input:
$ export PATH=/usr/bin:$PATH
prepended '/usr/bin' to the path variable before all the OpenFOAM stuff.
$ type -a $PATH
returned
gcc is /usr/bin/gcc
gcc is /opt/OpenFOAM/OpenFOAM-v2012/ThirdParty/platforms/linux64/gcc-6.3.0/bin/gcc
gcc is /usr/bin/gcc
gcc is /bin/gcc
This should have resolved my issue except for some reason it's still looking for another library in the OpenFOAM directories. As for the original question, the matter is resolved.
I am on a cluster and do not have root permission, I am new to linux. I wish to run a tool with a gcc 5 version or less. My default gcc version is 6.3.0. But there is another version of gcc (gcc 4:6.3.0-4) on the system. I am trying to find its location so that I can set CC and CXX variable value to that location (e.g. export CC="/usr/bin/gcc"). I tried which gcc (it is pointing to my default gcc location) and whereis gcc. I am not able to find the location of other gcc. It would be really helpful if someone can share the way to do it.
dpkg --list | grep compiler
Name Version Architecture Description
gcc 4:6.3.0-4 amd64 GNU C compiler
gcc-6 6.3.0-18+deb9u1 amd64 GNU C compiler
My system description is as follows:
Linux b03 4.9.0-6-amd64 #1 SMP Debian 4.9.82-1+deb9u3 (2018-03-02) x86_64 GNU/Linux
Running dpkg -L gcc 4:6.3.0-4 will give you a list of all files installed by that package. You should be able to find the executable path in there.
I am required to use LLVM and Clang for a compilers class I am enrolled in. This is not a question about the content of the class, just how to get the required software installed.
I am running gcc version 4.6.3 and have downloaded, built, tested, and updated what I believe to be LLVM suite version 3.4 (the latest svn edition). I do a simple "hello world" application, as referenced on the LLVM getting started page, but on the line
lli helloworld.bc
I get the error "lli:helloworld.bc: Invalid MODULE_CODE_GLOBALVAR record"
Here are the instructions I ran in the terminal, most of which was taken directly from the LLVM website:
cd myFolder
svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm
cd myFolder
cd llvm/tools
svn co http://llvm.org/svn/llvm-project/cfe/trunk clang
cd myFolder
cd llvm/projects
svn co http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
cd myFolder
mkdir build
cd build
../llvm/configure --enable-optimized CC=/usr/bin/clang CXX=/usr/bin/clang++
make
make check-all
make update
THEN
clang hello.c -o hello
clang -03 -emit-llvm hello.c -c -o hello.bc
lli hello.bc
And that final line, lli hello.bc, is where I get the error above.
Here are my questions:
What is installed on my machine? How do I resolve this error?
My professor said we need clang and LLVM 3.3. How can I get LLVM 3.3?
When you typed:
clang -03 -emit-llvm hello.c -c -o hello.bc
You used the system's clang executable, which is at /usr/bin/clang, and is not the clang you have just built. The two have a different version. lli, however, is the lli you've just built - Ubuntu doesn't come with it. That means you have generated a .bc file with an older LLVM version and then tried to run it with a newer LLVM version, hence the problem.
To verify this, you can check which clang you are using by typing which clang into the console.
The simplest way to remedy this is to type ./clang (or any other path which isn't just the file name) instead of clang, which forces the shell to choose the file in the current directory.
I am trying to compile node.js on openindiana, below is my Environment,
Even I set gcc path in .profile
It keeps saying
No acceptable C compiler found!
export PATH=/usr/gnu/bin:/usr/bin:/usr/sbin:/sbin:/opt/gcc/4.4.4/bin:/usr/gnu/bin:$PATH
export PAGER="/usr/bin/less -ins"
export CC=/opt/gcc/4.4.4/bin/gcc
export cc=/opt/gcc/4.4.4/bin/gcc
run
$ CC=gcc ./configure --with-dtrace --dest-cpu=x64 --prefix=~/local
or
$ ./configure --with-dtrace --dest-cpu=x64 --prefix=~/local
both of them gives following error
Node.js configure error: No acceptable C compiler found!
Please make sure you have a C compiler installed on your system and/or
consider adjusting the CC environment variable if you installed
it in a non-standard prefix.
nick#www:~/node-latest-install$ echo $PATH
/usr/gnu/bin:/usr/bin:/usr/sbin:/sbin:/opt/gcc/4.4.4/bin/gcc
nick#www:~/node-latest-install$ which gcc
/usr/bin/gcc
nick#www:~/node-latest-install$ which cc
which: no cc in (/usr/gnu/bin:/usr/bin:/usr/sbin:/sbin:/opt/gcc/4.4.4/bin/gcc)
nick#www:~/node-latest-install$ gcc -v
Using built-in specs.
Target: i386-pc-solaris2.11
Configured with: /home/jt/OI-151A-STABLE/151A-PRESTABLE6/newbuilds/oi-build/components/illumos-gcc/richlowe-gcc-f268959/configure --prefix=/opt/gcc/4.4.4 --with-gnu-as --with-as=/usr/sfw/bin/gas --with-ld=/usr/bin/ld --without-gnu-ld --enable-languages=c,c++,objc --enable-shared --with-mpfr-include=/usr/include/mpfr --with-gmp-include=/usr/include/gmp
Thread model: posix
gcc version 4.4.4 (GCC)
if you specify CC variable, make it absolute path to gcc: CC=/opt/gcc/4.4.4/bin/gcc. But if compiler is already in PATH, specifying CC shouldn't be necessary.
This may sound like a stupid answer but have you tried removing it and re-installing it from package manager. GCC that is
Also when did the problem start occurring? You could use beadm to roll back the OS to the last update or to when you created a 'Restore Point' so to speak. Check it out, very useful thing to use before running installs.
I need to determine which version of GTK+ is installed on Ubuntu
Man does not seem to help
This suggestion will tell you which minor version of 2.0 is installed. Different major versions will have different package names because they can co-exist on the system (in order to support applications built with older versions).
Even for development files, which normally would only let you have one version on the system, you can have a version of gtk 1.x and a version of gtk 2.0 on the same system (the include files are in directories called gtk-1.2 or gtk-2.0).
So in short there isn't a simple answer to "what version of GTK is on the system". But...
Try something like:
dpkg -l libgtk* | grep -e '^i' | grep -e 'libgtk-*[0-9]'
to list all the libgtk packages, including -dev ones, that are on your system. dpkg -l will list all the packages that dpkg knows about, including ones that aren't currently installed, so I've used grep to list only ones that are installed (line starts with i).
Alternatively, and probably better if it's the version of the headers etc that you're interested in, use pkg-config:
pkg-config --modversion gtk+
will tell you what version of GTK 1.x development files are installed, and
pkg-config --modversion gtk+-2.0
will tell you what version of GTK 2.0. The old 1.x version also has its own gtk-config program that does the same thing. Similarly, for GTK+ 3:
pkg-config --modversion gtk+-3.0
This isn't so difficult.
Just check your gtk+ toolkit utilities version from terminal:
gtk-launch --version
get GTK3 version:
dpkg -s libgtk-3-0|grep '^Version'
or just version number
dpkg -s libgtk-3-0|grep '^Version' | cut -d' ' -f2-
You can use this command:
$ dpkg -s libgtk2.0-0|grep '^Version'
You could also just compile the following program and run it on your machine.
#include <gtk/gtk.h>
#include <glib/gprintf.h>
int main(int argc, char *argv[])
{
/* Initialize GTK */
gtk_init (&argc, &argv);
g_printf("%d.%d.%d\n", gtk_major_version, gtk_minor_version, gtk_micro_version);
return(0);
}
compile with ( assuming above source file is named version.c):
gcc version.c -o version `pkg-config --cflags --libs gtk+-2.0`
When you run this you will get some output. On my old embedded device I get the following:
[root#n00E04B3730DF n2]# ./version
2.10.4
[root#n00E04B3730DF n2]#
Try,
apt-cache policy libgtk2.0-0 libgtk-3-0
or,
dpkg -l libgtk2.0-0 libgtk-3-0
I think a distribution-independent way is:
gtk-config --version
You can also just open synaptic and search for libgtk, it will show you exactly which lib is installed.
Try:
dpkg-query -W libgtk-3-bin
Because apt-cache policy will list all the matches available, even if not installed, I would suggest using this command for a more manageable shortlist of GTK-related packages installed on your system:
apt list --installed libgtk*
This will get the version of the GTK libraries for GTK 2, 3, and 4.
dpkg -l | egrep "libgtk(2.0-0|-3-0|-4)"
As major versions are parallel installable, you may have several of them on your system, which is my case, so the above command returns this on my Ubuntu Trusty system:
ii libgtk-3-0:amd64 3.10.8-0ubuntu1.6 amd64 GTK+ graphical user interface library
ii libgtk2.0-0:amd64 2.24.23-0ubuntu1.4 amd64 GTK+ graphical user interface library
This means I have GTK+ 2.24.23 and 3.10.8 installed.
If what you want is the version of the development files, use:
pkg-config --modversion gtk+-2.0 for GTK 2
pkg-config --modversion gtk+-3.0 for GTK 3
pkg-config --modversion gtk4 for GTK 4
(This changed because the + from GTK+ was dropped a while ago.)
To make the answer more general than Ubuntu (I have Redhat):
gtk is usually installed under /usr, but possibly in other locations. This should be visible in environment variables. Check with
env | grep gtk
Then try to find where your gtk files are stored. For example, use locate and grep.
locate gtk | grep /usr/lib
In this way, I found /usr/lib64/gtk-2.0, which contains the subdirectory 2.10.0, which contains many .so library files. My conclusion is that I have gtk+ version 2.10. This is rather consistent with the rpm command on Redhat: rpm -qa | grep gtk2, so I think my conclusion is right.
To compile and link a GTK program with pkg-config, we need the library name instead of the actual version number. For example, the following command compiles and links a GTK program that uses the GTK4 library:
gcc -o program program.c `pkg-config --cflags --libs gtk`
To obtain the library name for GTK, use the following command:
pkg-config --list-all | grep gtk