Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/57.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 链接器找不到现有库_C++_Mysql - Fatal编程技术网

C++ 链接器找不到现有库

C++ 链接器找不到现有库,c++,mysql,C++,Mysql,我尝试使用来自的Crosscompiler工具为我的raspberry创建一个程序。我正在使用MySQL CPPCON进行这个程序。但是在我添加了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,

我尝试使用来自的Crosscompiler工具为我的raspberry创建一个程序。我正在使用MySQL CPPCON进行这个程序。但是在我添加了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)
My 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++: 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
在Mathieu Van Nevel的评论之后,我还尝试:

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”时相同的错误:

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

谢谢

整数

如使用Wl和rpath所述对我有效:

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" ...

找不到(尝试使用-rpath或-rpath链接):您尝试过吗?是的,我尝试过。它给了我一条错误消息,如:“错误:无法识别的命令行选项“-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)
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" ...