linux交叉编译和动态库/链接 [英] linux cross compiling and dynamic libraries / linking
问题描述
我正在尝试为BeagleBoard开发. 因此,我安装了CodeSourcery Sourcery_G ++ _ Lite工具链.
i'm trying to develop for the BeagleBoard. Therefore i installed the CodeSourcery Sourcery_G++_Lite Toolchain.
我想使用opencv库.因此,我将源代码下载到我的Ubuntu开发系统中,使用gcc编译为共享库并安装了该库. 当我为x86体系结构构建helloworld应用程序时,一切都很好.
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.
现在,我想与用于ARM体系结构的其他工具链一起编译相同的应用程序.
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
很明显,im使用与x86体系结构相同的包含目录和库路径.这是行不通的.但是我该怎么办?我必须交叉编译opencv库吗?
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?
推荐答案
必须交叉编译库,并且必须确保在链接时找到正确的库.如果那不能自动工作,您可能需要看一下gcc的--sysroot
命令行开关.
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.
这篇关于linux交叉编译和动态库/链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!