尽管缺少共享库和相关符号,如何链接可执行文件?

时间:2012-07-06 13:43:27

标签: gcc linker ld

尽管缺少共享库(以及相关的缺失符号),我如何强制gcc / ld继续并链接(部分)可用的可执行文件?

上下文:我有一个仅作为32位ELF二进制blob(libEposCmd.so)分发的硬件驱动程序。它取决于我从上下文中知道的库(libftd2xx.so)实际上并未使用(ftdi的东西是用于usb-serial适配器,我没有使用它。)

gcc main.o -o epos_server -m32 -L/usr/lib32 -L/usr/local/lib32 -lEposCmd
/usr/bin/ld: warning: libftd2xx.so.0, needed by /usr/local/lib32/libEposCmd.so, not found (try using -rp
ath or -rpath-link)
main.o: In function `main':
/usr/local/lib32/libEposCmd.so: undefined reference to `FT_Write'
/usr/local/lib32/libEposCmd.so: undefined reference to `FT_SetDataCharacteristics'
/usr/local/lib32/libEposCmd.so: undefined reference to `FT_GetDeviceInfoDetail'
/usr/local/lib32/libEposCmd.so: undefined reference to `FT_SetFlowControl'
...

我唯一未定义的引用是FT_ *,我相当确定它们都属于libftd2xx。

丑陋的黑客行为是可以接受的;这是研究代码,我们希望尽快用更好的Linux支持替换这个硬件(maxon epos2 motor driver)。

更新:.so没有被剥离,因此应该可以为缺失的函数提取原型...

1 个答案:

答案 0 :(得分:-1)

最快的方法是创建一个包含缺失函数的虚拟库并与之链接。