gcc option "-lm" fails - cannot link agains libm
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
gcc-defaults (Ubuntu) |
Invalid
|
Undecided
|
Unassigned |
Bug Description
I newly installed LinuxMint13 (Mate 64 Bit) , fully updated (2012-09-25) , on a new AMD64 machine.
gcc works properly except when using mathlib functions. Error messages always indicate that sqrt() and other mathlib functions are unresolved. I checked the installation and found:
- /usr/lib/
- /usr/lib/
- /lib/x86_
- /lib/x86_
Symbol "sqrt" was present (type "W") in both the static and the shared library.
Both "gcc -lm" and "gcc -L/usr/
"undefined reference to sqrt".
Same picture with all other libm functions I tried. The source code contains "#include <math.h>", of course.
What is going wrong?
"-m64" didn't help, either.
Protocol of "gcc -v":
cc -v -L/usr/ lib/x86_ 64-linux- gnu -L/lib/ x86_64- linux-gnu -lm sieve1-4.o sieveMethods.o -o sieve1-4 LTO_WRAPPER= /usr/lib/ gcc/x86_ 64-linux- gnu/4.6/ lto-wrapper pkgversion= 'Ubuntu/ Linaro 4.6.3-1ubuntu5' --with- bugurl= file:// /usr/share/ doc/gcc- 4.6/README. Bugs --enable- languages= c,c++,fortran, objc,obj- c++ --prefix=/usr --program- suffix= -4.6 --enable-shared --enable- linker- build-id --with-system-zlib --libexecdir= /usr/lib --without- included- gettext --enable- threads= posix --with- gxx-include- dir=/usr/ include/ c++/4.6 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable- clocale= gnu --enable- libstdcxx- debug --enable- libstdcxx- time=yes --enable- gnu-unique- object --enable-plugin --enable-objc-gc --disable-werror --with-arch-32=i686 --with-tune=generic --enable- checking= release --build= x86_64- linux-gnu --host= x86_64- linux-gnu --target= x86_64- linux-gnu PATH=/usr/ lib/gcc/ x86_64- linux-gnu/ 4.6/:/usr/ lib/gcc/ x86_64- linux-gnu/ 4.6/:/usr/ lib/gcc/ x86_64- linux-gnu/ :/usr/lib/ gcc/x86_ 64-linux- gnu/4.6/ :/usr/lib/ gcc/x86_ 64-linux- gnu/ PATH=/usr/ lib/gcc/ x86_64- linux-gnu/ 4.6/:/usr/ lib/gcc/ x86_64- linux-gnu/ 4.6/../ ../../x86_ 64-linux- gnu/:/usr/ lib/gcc/ x86_64- linux-gnu/ 4.6/../ ../../. ./lib/: /lib/x86_ 64-linux- gnu/:/lib/ ../lib/ :/usr/lib/ x86_64- linux-gnu/ :/usr/lib/ ../lib/ :/usr/lib/ gcc/x86_ 64-linux- gnu/4.6/ ../../. ./:/lib/ :/usr/lib/ GCC_OPTIONS= '-v' '-L/usr/ lib/x86_ 64-linux- gnu' '-L/lib/ x86_64- linux-gnu' '-o' 'sieve1-4' '-mtune=generic' '-march=x86-64' gcc/x86_ 64-linux- gnu/4.6/ collect2 --sysroot=/ --build-id --no-add-needed --as-needed --eh-frame-hdr -m elf_x86_64 --hash-style=gnu -dynamic-linker /lib64/ ld-linux- x86-64. so.2 -z relro -o sieve1-4 /usr/lib/ gcc/x86_ 64-linux- gnu/4.6/ ../../. ./x86_64- linux-gnu/ crt1.o /usr/lib/ gcc/x86_ 64-linux- gnu/4.6/ ../../. ./x86_64- linux-gnu/ crti.o /usr/lib/ gcc/x86_ 64-linux- gnu/4.6/ crtbegin. o -L/usr/ lib/x86_ 64-linux- gnu -L/lib/ x86_64- linux-gnu -L/usr/ lib/gcc/ x86_64- linux-gnu/ 4.6 -L/usr/ lib/gcc/ x86_64- linux-gnu/ 4.6/../ ../../x86_ 64-linux- gnu -L/usr/ lib/gcc/ x86_64- linux-gnu/ 4.6/../ ../../. ./lib -L/lib/ x86_64- linux-gnu -L/lib/../lib -L/usr/ lib/x86_ 64-linux- gnu -L/usr/lib/../lib -L/usr/ lib/gcc/ x86_64- linux-gnu/ 4.6/../ ../.. -lm sieve1-4.o sieveMethods.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/ gcc/x86_ 64-linux- gnu/4.6/ crtend. o /usr/lib/ gcc/x86_ 64-linux- gnu/4.6/ ../../. ./x86_64- linux-gnu/ crtn.o 4.c:(.text. startup+ 0x8c): undefined reference to `trunc' 4.c:(.text. startup+ 0x2c4): undefined reference to `sqrt'
Using built-in specs.
COLLECT_GCC=cc
COLLECT_
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-
Thread model: posix
gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5)
COMPILER_
LIBRARY_
COLLECT_
/usr/lib/
sieve1-4.o: In function `main':
sieve1-
sieve1-
collect2: ld returned 1 exit status
make: *** [sieve1-4] Error 1