在使用gcc 编译简单的测试程序时发现报如下错误
gcc -Wall -Iworld/include -Lworld/lib_x86/ -lworld -o bin_x86/hello src/main.cpp
/usr/bin/ld: /tmp/cc4fbSb5.o: in function `main':
main.cpp:(.text+0x4a): undefined reference to `World::Str()'
collect2: error: ld returned 1 exit status
make: *** [Makefile:11:x86] 错误 1
查找了对应的so库 libworld, 头文件该有的都有,非常奇怪的问题
libword.so 库的编译使用的是下面指令
gcc -Wall -fPIC -shared -Iinclude -o lib_x86/libworld.so src/world.cpp
最后的解决方案把gcc的编译分开来实现
g++ -c -Wall -W -fPIC -Iworld/include -o main.o src/main.cpp
g++ -o bin_x86/hello main.o -Lworld/lib_x86/ -lworld
最后编译成功