Reputation: 801
I'm trying the following command:
gcc -o test test.o -lblas
which gives the error:
/usr/bin/ld: test.o: undefined reference to symbol 'sqrtf@@GLIBC_2.2.5'
/usr/bin/ld: note: 'sqrtf@@GLIBC_2.2.5' is defined in DSO /lib64/libm.so.6 so try adding it to the linker command line
/lib64/libm.so.6: could not read symbols: Invalid operation collect2: error: ld returned 1 exit status
However, when I add -lm at the end of the command, there is a whole bunch of error messages:
test.o: In function `main':
test.cpp:(.text+0xe9): undefined reference to `std::cout'
test.cpp:(.text+0xee): undefined reference to `std::basic_ostream<char,
std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char,
std::char_traits<char> >&, char const*)'
[...]
collect2: error: ld returned 1 exit status
Upvotes: 2
Views: 4607
Reputation: 766
I have the same problem with you when I tried to link other libraries.
Here is my solutions:
install libtool;
add the library path to LD_LIBRARY_PATH;
I use root to make.
I don't know the exactly reason why it works on my Ubuntu. But I think you can try these steps.
Upvotes: 2