首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >链接器找不到现有的库

链接器找不到现有的库
EN

Stack Overflow用户
提问于 2016-04-16 20:53:07
回答 1查看 918关注 0票数 1

我尝试使用SysGCC的交叉编译器工具为我的树莓创建一个程序。我在这个程序中使用了MySQL CPPConn。但是在我添加了mysqlclient和mysqlcppconn库之后,我得到了奇怪的错误:

代码语言:javascript
复制
d:/program data/sysgcc/raspberry/bin/../lib/gcc/arm-linux-gnueabihf/4.9/../../../../arm-linux-gnueabihf/bin/ld.exe: warning: libz.so.1, needed by D:\Program Data\SysGCC\Raspberry\arm-linux-gnueabihf\sysroot\usr\lib\arm-linux-gnueabihf/libmysqlclient.so, not found (try using -rpath or -rpath-link)
d:/program data/sysgcc/raspberry/bin/../lib/gcc/arm-linux-gnueabihf/4.9/../../../../arm-linux-gnueabihf/bin/ld.exe: warning: libdl.so.2, needed by D:\Program Data\SysGCC\Raspberry\arm-linux-gnueabihf\sysroot\usr\lib\arm-linux-gnueabihf/libmysqlclient.so, not found (try using -rpath or -rpath-link)

我的eclipse使用以下命令进行编译:

代码语言:javascript
复制
arm-linux-gnueabihf-g++ -L"D:\Program Data\SysGCC\Raspberry\arm-linux-gnueabihf\sysroot\usr\lib\arm-linux-gnueabihf" -L"D:\Program Data\SysGCC\Raspberry\arm-linux-gnueabihf\sysroot\usr\local\lib" -L"D:\Program Data\SysGCC\Raspberry\arm-linux-gnueabihf\sysroot\usr\lib" -L"D:\Program Data\SysGCC\Raspberry\arm-linux-gnueabihf\sysroot\lib\arm-linux-gnueabihf" -lpthread -o "SensorBox"  ./DBController.o ./DS18B20.o ./main.o   -llog4cpp -lnsl -lmysqlclient -lmysqlcppconn

尝试命令后:

代码语言:javascript
复制
arm-linux-gnueabihf-g++ -L"D:\Program Data\SysGCC\Raspberry\arm-linux-gnueabihf\sysroot\usr\lib\arm-linux-gnueabihf" -L"D:\Program Data\SysGCC\Raspberry\arm-linux-gnueabihf\sysroot\usr\local\lib" -L"D:\Program Data\SysGCC\Raspberry\arm-linux-gnueabihf\sysroot\usr\lib" -L"D:\Program Data\SysGCC\Raspberry\arm-linux-gnueabihf\sysroot\lib\arm-linux-gnueabihf" -lpthread -rpath "D:\Program Data\SysGCC\Raspberry\arm-linux-gnueabihf\sysroot\lib\arm-linux-gnueabihf/libz.so.1" -o "SensorBox"  ./DBController.o ./DS18B20.o ./main.o   -llog4cpp -lnsl -lmysqlclient -lmysqlcppconn

代码语言:javascript
复制
arm-linux-gnueabihf-g++ -L"D:\Program Data\SysGCC\Raspberry\arm-linux-gnueabihf\sysroot\usr\lib\arm-linux-gnueabihf" -L"D:\Program Data\SysGCC\Raspberry\arm-linux-gnueabihf\sysroot\usr\local\lib" -L"D:\Program Data\SysGCC\Raspberry\arm-linux-gnueabihf\sysroot\usr\lib" -L"D:\Program Data\SysGCC\Raspberry\arm-linux-gnueabihf\sysroot\lib\arm-linux-gnueabihf" -lpthread -rpath-link "D:\Program Data\SysGCC\Raspberry\arm-linux-gnueabihf\sysroot\lib\arm-linux-gnueabihf/libz.so.1" -o "SensorBox"  ./DBController.o ./DS18B20.o ./main.o   -llog4cpp -lnsl -lmysqlclient -lmysqlcppconn

我得到了错误消息:

代码语言:javascript
复制
arm-linux-gnueabihf-g++: error: unrecognized command line option '-rpath'
arm-linux-gnueabihf-g++: error: unrecognized command line option '-rpath-link'

libz.so.1和libdl.so.2文件位于:

代码语言:javascript
复制
D:\Program Data\SysGCC\Raspberry\arm-linux-gnueabihf\sysroot\lib\arm-linux-gnueabihf

在马修·范·内维尔的评论之后,我也尝试了:

代码语言:javascript
复制
arm-linux-gnueabihf-g++ -L"D:\Program Data\SysGCC\Raspberry\arm-linux-gnueabihf\sysroot\usr\lib\arm-linux-gnueabihf" -L"D:\Program Data\SysGCC\Raspberry\arm-linux-gnueabihf\sysroot\usr\local\lib" -L"D:\Program Data\SysGCC\Raspberry\arm-linux-gnueabihf\sysroot\usr\lib" -L"D:\Program Data\SysGCC\Raspberry\arm-linux-gnueabihf\sysroot\lib\arm-linux-gnueabihf" -lpthread -Wl,-rpath,"D:\Program Data\SysGCC\Raspberry\arm-linux-gnueabihf\sysroot\lib\arm-linux-gnueabihf/libz.so.1" -o "SensorBox"  ./DBController.o ./DS18B20.o ./main.o   -llog4cpp -lnsl -lmysqlclient -lmysqlcppconn

但它会导致与不使用“-rpath”时相同的错误:

代码语言:javascript
复制
d:/program data/sysgcc/raspberry/bin/../lib/gcc/arm-linux-gnueabihf/4.9/../../../../arm-linux-gnueabihf/bin/ld.exe: warning: libz.so.1, needed by D:\Program Data\SysGCC\Raspberry\arm-linux-gnueabihf\sysroot\usr\lib\arm-linux-gnueabihf/libmysqlclient.so, not found (try using -rpath or -rpath-link)
d:/program data/sysgcc/raspberry/bin/../lib/gcc/arm-linux-gnueabihf/4.9/../../../../arm-linux-gnueabihf/bin/ld.exe: warning: libdl.so.2, needed by D:\Program Data\SysGCC\Raspberry\arm-linux-gnueabihf\sysroot\usr\lib\arm-linux-gnueabihf/libmysqlclient.so, not found (try using -rpath or -rpath-link)

知道为什么链接器找不到这些文件吗?

谢谢

整数

EN

回答 1

Stack Overflow用户

发布于 2016-04-17 01:15:14

如上所述,使用Wl和rpath的here对我有效:

代码语言:javascript
复制
arm-linux-gnueabihf-g++ -L"D:\Program Data\SysGCC\Raspberry\arm-linux-gnueabihf\sysroot\usr\lib\arm-linux-gnueabihf" -L"D:\Program Data\SysGCC\Raspberry\arm-linux-gnueabihf\sysroot\usr\local\lib" -L"D:\Program Data\SysGCC\Raspberry\arm-linux-gnueabihf\sysroot\usr\lib" -L"D:\Program Data\SysGCC\Raspberry\arm-linux-gnueabihf\sysroot\lib\arm-linux-gnueabihf" -lpthread -Wl,-rpath-link,"D:\Program Data\SysGCC\Raspberry\arm-linux-gnueabihf\sysroot\lib\arm-linux-gnueabihf" ...
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36664434

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档