StupidBeauty
Read times:3234Posted at: - no title specified

转载: Undefined reference error with sincosf@@GLIBC_2.2.5 and sqrtf@@GLIBC_2.2.5

编译时遇到这个错误:“ /usr/bin/ld: foobar.cpp.o: undefined reference to symbol 'sqrtf@@GLIBC_2.2.5' ”。这是因为编译器未与libm链接。解决方法就是明确告知编译器要链接libm。具体对于cmake来说,就是:

target_link_libraries( foobar -lsomelibrary -lm ) ”。

http://choorucode.com/2014/05/02/undefined-reference-error-with-sincosfglibc_2-2-5/

亮点:

Solution

Ubuntu 14.04 uses newer versions of the GCC compilers and libraries. The hint here is that its complaining about a mathematical symbol:  sincosf . Suggesting the linker to link with the math library fixed this error. You can do this by adding  -lm  to the linker invocation.

For my CMake, I did this by adding  -lm  to the linking options to the target as:

1

2

3

4

5

target_link_libraries(

foobar

-lsomelibrary

-lm

)

Your opinions

Your name:Email:Website url:Opinion content:
- no title specified

HxLauncher: Launch Android applications by voice commands