我尝试使用SysGCC的交叉编译器工具为我的树莓创建一个程序。我在这个程序中使用了MySQL CPPConn。但是在我添加了mysqlclient和mysqlcppconn库之后,我得到了奇怪的错误:
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使用以下命令进行编译:
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尝试命令后:
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和
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我得到了错误消息:
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文件位于:
D:\Program Data\SysGCC\Raspberry\arm-linux-gnueabihf\sysroot\lib\arm-linux-gnueabihf在马修·范·内维尔的评论之后,我也尝试了:
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”时相同的错误:
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)知道为什么链接器找不到这些文件吗?
谢谢
整数
发布于 2016-04-17 01:15:14
如上所述,使用Wl和rpath的here对我有效:
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" ...https://stackoverflow.com/questions/36664434
复制相似问题