I installed another version of gcc (9.2.0) to a non-default folder in my Linux machine and pointed $PATH to that new location. gcc and g++ are working but there is no cc so I made a symlink:
ln -s $HOME/.local/bin/gcc $HOME/.local/bin/cc
I thought cc now points to the correct one
$ ~/.local/bin/cc --version
cc (GCC) 9.2.0
$ which cc
~/.local/bin/cc
but without the full path, cc still uses the old version
$ cc --version
cc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-16)
I could not understand how this could happen. Any help is appreciated.
Related
In Linux, how can I choose which ncurses library to build against when both V5 and V6 are installed?
Right now it defaults to V6 (the project is the same as when it was building to V5 before the upgrade from Debian Jessie to Buster).
TIA!!
Debian has several packages for ncurses (I find the bug-reporting links easier to navigate than the package-tracking). At the moment, buster is "oldstable". That has development packages for ABI 5 and 6:
libncurses-dev
libncursesw-dev
libncurses5-dev
libncursesw5-dev
Each of those has a package-page which includes a list of files for each architecture, e.g., this, and for example
/usr/lib/x86_64-linux-gnu/pkgconfig/form.pc
/usr/lib/x86_64-linux-gnu/pkgconfig/formw.pc
/usr/lib/x86_64-linux-gnu/pkgconfig/menu.pc
/usr/lib/x86_64-linux-gnu/pkgconfig/menuw.pc
/usr/lib/x86_64-linux-gnu/pkgconfig/ncurses++.pc
/usr/lib/x86_64-linux-gnu/pkgconfig/ncurses++w.pc
/usr/lib/x86_64-linux-gnu/pkgconfig/ncurses.pc
/usr/lib/x86_64-linux-gnu/pkgconfig/ncursesw.pc
/usr/lib/x86_64-linux-gnu/pkgconfig/panel.pc
/usr/lib/x86_64-linux-gnu/pkgconfig/panelw.pc
/usr/lib/x86_64-linux-gnu/pkgconfig/tic.pc
/usr/lib/x86_64-linux-gnu/pkgconfig/tinfo.pc
Generally, the filename for the ".pc" files is useful as a parameter to pkg-config, e.g.,
pkg-config --cflags --libs libncurses-dev
which prints the -I, -D, -L and -l options you'd use in a makefile or script.
You don't have to search through the webpages for that;
dpkg -l | grep 'ncurses'
lists the package with "ncurses" in their name, and for the example shown
dpkg -L libncurses-dev | grep -F .pc
shows the pkg-config files.
In a command-line, I could do this:
gcc -c $(pkg-config --cflags libncurses-dev) foo.c
for just the compiler, or to compile/link:
gcc -o foo $(pkg-config --cflags --libs libncurses-dev) foo.c
The package also has the "*-config" scripts which give similar information, without using pkg-config, e.g.,
/usr/bin/ncurses5-config
/usr/bin/ncurses6-config
/usr/bin/ncursesw5-config
/usr/bin/ncursesw6-config
In the Debian development packages, it appears that there are ".pc" files only for ABI 6. But the "-config" files are provided for both ABI 5 and 6. So you should be able to compile with ABI 5, e.g,.
gcc -c $(ncurses5-config --cflags libncurses-dev) foo.c
When I check location of gcc I get correct output. But when I try to get gcc version I get command not found.
I have added the path to $PATH
echo $PATH
/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/home/ptladmin/bin:/usr/libexec/gcc
whereis gcc
gcc: /usr/libexec/gcc
gcc --version
-bash: gcc: command not found
I am trying to install a pakcage I keep getting configure: error: no acceptable C compiler found in $PATH
uname -a
Linux deehxpy011ccpra 2.6.18-419.el5 #1 SMP Wed Feb 22 22:40:57 EST 2017 x86_64 x86_64 x86_64 GNU/Linux
I'm trying to use clang++ as drop-in replacement for G++. I'm compiling for AArch64, but for linking, clang seems to invoke the native (x86) /usr/bin/ld instead of that from AArch64 GCC suite. The clang command line looks like:
clang++ -target aarch64-linux-gnu -v \
-gcc-toolchain /path/to/aarch64/gcc \
--sysroot=/path/to/aarch64/gcc/aarch64-linux-gnu/libc \
<some other options> <obj files>
And from the verbose output, I get:
Ubuntu clang version 3.4-1ubuntu3 (tags/RELEASE_34/final) (based on LLVM 3.4)
Target: aarch64--linux-gnu
Thread model: posix
Found candidate GCC installation: /path/to/aarch64/gcc/lib/gcc/aarch64-linux-gnu/4.9.3
Selected GCC installation: /path/to/aarch64/gcc/lib/gcc/aarch64-linux-gnu/4.9.3
"/usr/bin/ld" --sysroot=/path/to/aarch64/gcc/aarch64-linux-gnu/libc ...
I don't get why clang got around choosing the native linker. The link fails for obvious reasons that object files are AArch64 ELF. Compilation lines similar to the above, but they go OK.
Any thoughts?
PS: I'm a novice clang user
I managed to find a solution: GCC accepts -B option to point to the search path where it'd try to locate the utilities. It turns out--although not documented--that clang too accepts this option. For me, having -B point to AArch64 binutils solved the problem. Another suggestion was to add the AArch64 binutils in $PATH.
I have two workstations, one of them runs Debian Wheezy and has gcc 4.9.2
Second one runs RHEL 5.5, gcc version is 4.8.2
when I compile the same code with the same options:
$gcc -O3 -DNDEBUG -g -o test test.c
I get all the necessary debugging information on gcc 4.9 on Debian box, however on RHEL box objdump says:
$ objdump --debugging test
test: file format elf64-x86-64
objdump: test: no recognized debugging information
What do I do wrong?
From looking around, this appears to be a known bug or limitation in objdump:
https://bugzilla.redhat.com/show_bug.cgi?id=118383
https://sourceware.org/bugzilla/show_bug.cgi?id=6483
How can I tell if a library was compiled with -g?
Suggested workarounds are using objdump -W, readelf -w, or gcc -gstabs.
while installing ns2 according to the steps mentioned here:
http://stanjuly.wordpress.com/2011/12/22/install-ns2-ns-allinone-2-35-on-ubuntu-11-04-for-beginners/
In Step 4, when i opened my make file, my make file looks like this:
CC= #CC#
CFLAGS= #CFLAGS#
RANLIB= #RANLIB#
INSTALL= #INSTALL#
#
# how to compile, link, and name shared libraries
#
SHLIB_LD= #SHLIB_LD#
SHLIB_CFLAGS= #SHLIB_CFLAGS#
SHLIB_SUFFIX= #SHLIB_SUFFIX#
SHLD_FLAGS= #DL_LD_FLAGS#
DL_LIBS= #DL_LIBS#
SHLIB_LD_LIBS = #SHLIB_LD_LIBS#
#
# where to install shells, libraries, and includes
#
INST_OTCLSH= #prefix#/bin
INST_OWISH= #prefix#/bin
INST_OLIB= #prefix#/lib
INST_OLIBSH= #INST_OLIBSH#
INST_OINC= #prefix#/include
#
# ------------ you shouldn't need to configure below here -----------------
#
the instructions say that i am supposed to change CC = #CC# to CC = #CC# -V 4.7.0 (4.7.0 because when i type gcc --version on my terminal it says):
gcc (Ubuntu/Linaro 4.7.3-1ubuntu1) 4.7.3
But when instlaiing ns2 (step5): sudo ./install i get the following error:
config.status: creating Makefile
rm -f libotcl.a otcl.o
gcc -V 4.7 -c -g -O2 -DNDEBUG -DUSE_SHM -DHAVE_UNISTD_H=1 -I. -I/home/me/ns-
allinone-2.35/include -I/home/me/ns-allinone-2.35/include -I/home/me/ns-
allinone-2.35/include -I/include otcl.c
gcc: error: unrecognized command line option ā-Vā
gcc: error: 4.7: No such file or directory
make: *** [libotcl.a] Error 1
otcl-1.14 make failed! Exiting ...
How am i supposed to modify makefile that i dont get this error? Do i have the gcc compiler installed? I dont understand. I dont know how to check if it is installed.
This means your compiler is not compatible and if you don't want to install
gcc 4.4 than change
CC = gcc-4.4
to
CC = #CC#
in makefile and makefile.in present in otcl folder and also change
SHLIB_LD="ld -shared"
to
SHLIB_LD="gcc -shared"
in configure file
You need to install an old version of gcc: (Newer versions dosent work)
apt-get install gcc-4.4 (4.4 is the older version that I found on my repository)
And change
CC= #CC#
for:
CC=gcc-4.4