简体   繁体   English

linux交叉编译和动态库/链接

[英]linux cross compiling and dynamic libraries / linking

i'm trying to develop for the BeagleBoard. 我正在努力为BeagleBoard开发。 Therefore i installed the CodeSourcery Sourcery_G++_Lite Toolchain. 因此我安装了CodeSourcery Sourcery_G ++ _ Lite工具链。

I want to use the opencv library. 我想使用opencv库。 So I downloaded the sources to my Ubuntu devolepment system, compiled with gcc as shared library and installed the library. 所以我将源代码下载到我的Ubuntu devolepment系统,用gcc编译为共享库并安装了库。 When i build a helloworld-application for the x86-Architecture, everything is fine. 当我为x86架构构建helloworld应用程序时,一切都很好。

Now, i want to compile the same application with the other toolchain for the ARM-Architecture. 现在,我想用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. 显然,即时通讯使用相同的包含目录和库,如im用于x86-Architecture。 This does not work. 这不起作用。 But what do i have to do? 但我该怎么办? Do i have to cross compile the opencv-library? 我是否必须交叉编译opencv-library?

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. 如果这不应该自动运行,您可能需要查看gcc的--sysroot命令行开关。

Yes. 是。 Libraries are specific to an architecture. 库是特定于体系结构的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM