linux cross compiling and dynamic libraries / linking

安稳与你 提交于 2019-12-06 08:31:58

问题


i'm trying to develop for the BeagleBoard. Therefore i installed the CodeSourcery Sourcery_G++_Lite Toolchain.

I want to use the opencv library. So I downloaded the sources to my Ubuntu devolepment system, compiled with gcc as shared library and installed the library. When i build a helloworld-application for the x86-Architecture, everything is fine.

Now, i want to compile the same application with the other toolchain for the ARM-Architecture.

I get these warnings/erros while compiling/linking:

john@ubuntu:~/Downloads/BeagleTest$ arm-none-linux-gnueabi-g++ -c ImageProcessing.cpp -o ImageProcessing.o -I/usr/local/include
cc1plus: warning: include location "/usr/local/include" is unsafe for cross-compilation

john@ubuntu:~/Downloads/BeagleTest$ arm-none-linux-gnueabi-g++ -c Main.cpp -o Main.o -I/usr/local/include
cc1plus: warning: include location "/usr/local/include" is unsafe for cross-compilation

john@ubuntu:~/Downloads/BeagleTest$ arm-none-linux-gnueabi-g++ -oApplication -L/usr/local/lib Main.o ImageProcessing.o -lopencv_core
/usr/local/CodeSourcery/Sourcery_G++_Lite/bin/../lib/gcc/arm-none-linux-gnueabi/4.2.1/../../../../arm-none-linux-gnueabi/bin/ld: warning: library search path "/usr/local/lib" is unsafe for cross-compilation
/usr/local/CodeSourcery/Sourcery_G++_Lite/bin/../lib/gcc/arm-none-linux-gnueabi/4.2.1/../../../../arm-none-linux-gnueabi/bin/ld: skipping incompatible /usr/local/lib/libopencv_core.so when searching for -lopencv_core
/usr/local/CodeSourcery/Sourcery_G++_Lite/bin/../lib/gcc/arm-none-linux-gnueabi/4.2.1/../../../../arm-none-linux-gnueabi/bin/ld: cannot find -lopencv_core
collect2: ld returned 1 exit status

Obviously, im using the same include-directories and library-pathes like im using for the x86-Architecture. This does not work. But what do i have to do? Do i have to cross compile the opencv-library?


回答1:


Libraries have to be cross compiled and you have to make sure the correct library is found when linking. If that shouldn't work automatically you may want to take a look at the --sysroot command line switch of gcc.




回答2:


Yes. Libraries are specific to an architecture.



来源:https://stackoverflow.com/questions/5502603/linux-cross-compiling-and-dynamic-libraries-linking

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!