integer
integer

Reputation: 31

Linker cannot find existing library

I try to create a program for my raspberry using the Crosscompiler Tools from SysGCC. And I'm using MySQL CPPConn for this program. But after i've added mysqlclient and mysqlcppconn libraries i get weird errors:

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 uses the following command for compiling:

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

after trying the commands:

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

and

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

I got the error messages:

arm-linux-gnueabihf-g++: error: unrecognized command line option '-rpath'
arm-linux-gnueabihf-g++: error: unrecognized command line option '-rpath-link'

The files libz.so.1 and libdl.so.2 are existing in:

D:\Program Data\SysGCC\Raspberry\arm-linux-gnueabihf\sysroot\lib\arm-linux-gnueabihf

After the comment from Mathieu Van Nevel, I tried also:

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

But it leads to the same errors as without "-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)

Any Idea why the linker can't find these files?

Thanks

integer

Upvotes: 1

Views: 1030

Answers (1)

integer
integer

Reputation: 31

As described here using Wl and rpath worked for me:

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

Upvotes: 1

Related Questions