c++ - 交叉编译: link to library only available on target system

标签 c++ linker cross-compiling

有没有办法链接到一个只在目标系统上可用,但在用于交叉编译的系统上不可用的共享库?我想交叉编译链接到目标系统上共享库的另一个共享库。

在我的源代码目录中有一个 include 目录,其中包含带有函数声明的头文件。我通过编译源代码

arm-linux-gnueabi-g++ -Wall -fPIC -I include/ -c mysource1.cpp
arm-linux-gnueabi-g++ -Wall -fPIC -I include/ -c mysource2.cpp

在此状态下没有错误或警告。下一个命令

arm-linux-gnueabi-g++ -shared -fPIC -rdynamic mysource1.o mysource2.o -L /usr/lib/libtargetsys_shlib.so -Wl,-z,defs -o another_shared_lib.so

报如下错误:

mysource2.o: In function `my_func_2':
mysource2.cpp:(.text+0xe): undefined reference to `share_lib_func'

shared_lib_func 存在于目标系统共享库中。

最佳答案

在交叉编译后的链接中,不需要native库,需要目标系统的库。将其复制到您的构建系统。

关于c++ - 交叉编译: link to library only available on target system,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39986722/

相关文章:

go - 交叉编译: "user: Current not implemented on linux/amd64"

c++ - 如何在 Windows 上使用 Eclipse 交叉编译树莓派

c++ - 使用 mingw 交叉编译时缺少库

C++ 编译器不喜欢 "using INLINE = extern inline"

c++ - 何时使用哪种排序算法,何时绝对不应该

c++ - 为什么来自文件的浮点输入不起作用 C++

Haskell 在 Ubuntu 上与动态库链接

c++ - 我可以从 C++ 库中包含/导入单个函数吗

c++ - 编译 keyczar 程序时链接器错误

c++ - boost::this_thread::sleep() 与 nanosleep()?