0

All problems posted related to mysql library use standard gcc compiler. However, I need to compile a project running on a beaglebone black device. Hence, I am using arm-linux-gnueabihf-gcc instead of gcc.

Here is my environment:

  • Ubuntu - 32 bit
  • using eclipse luna c++
  • mysql running fine on beaglebone. Now, I am writing code to access mysql using C++.

Please help to fix my error. thanks compiling using a standard gcc works fine, so it means i already installed

apt-get install libmysqlclient-dev
apt-get install libmysqlcppconn-dev
apt-get install mysql-client
apt-get install mysql-server

So, this is what i get after compiling:

12:38:15 **** Incremental Build of configuration Debug for project arm2 ****
make all 
Building file: ../src/arm2.cpp
Invoking: GCC C++ Compiler
arm-linux-gnueabihf-g++ -I/usr/arm-linux-gnueabihf/include/mysql -I/usr/arm-linux-gnueabihf/include/mysql/cppconn -I/usr/arm-linux-gnueabihf/include/c++/4.8.2 -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/arm2.d" -MT"src/arm2.d" -o "src/arm2.o" "../src/arm2.cpp"
../src/arm2.cpp: In function ‘int main()’:
../src/arm2.cpp:32:10: warning: variable ‘driver’ set but not used [-Wunused-but-set-variable]
  Driver *driver;
          ^
Finished building: ../src/arm2.cpp

Building target: arm2
Invoking: GCC C++ Linker
arm-linux-gnueabihf-g++ -L/usr/arm-linux-gnueabihf/lib -L/usr/arm-linux-gnueabihf/libsf -L/usr/lib/mysql -L/usr/lib -o "arm2"  ./src/arm2.o   -lmysqlcppconn
/usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/../../../../arm-linux-gnueabihf/bin/ld: skipping incompatible /usr/arm-linux-gnueabihf/lib/libmysqlcppconn.so when searching for -lmysqlcppconn
/usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/../../../../arm-linux-gnueabihf/bin/ld: skipping incompatible /usr/lib/libmysqlcppconn.so when searching for -lmysqlcppconn
/usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/../../../../arm-linux-gnueabihf/bin/ld: skipping incompatible /usr/lib/libmysqlcppconn.a when searching for -lmysqlcppconn
/usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/../../../../arm-linux-gnueabihf/bin/ld: skipping incompatible /usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/../../../../arm-linux-gnueabihf/lib/../lib/libmysqlcppconn.so when searching for -lmysqlcppconn
/usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/../../../../arm-linux-gnueabihf/bin/ld: skipping incompatible /usr/lib/../lib/libmysqlcppconn.so when searching for -lmysqlcppconn
/usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/../../../../arm-linux-gnueabihf/bin/ld: skipping incompatible /usr/lib/../lib/libmysqlcppconn.a when searching for -lmysqlcppconn
/usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/../../../../arm-linux-gnueabihf/bin/ld: skipping incompatible /usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/../../../../arm-linux-gnueabihf/lib/libmysqlcppconn.so when searching for -lmysqlcppconn
/usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/../../../../arm-linux-gnueabihf/bin/ld: skipping incompatible //usr/lib/libmysqlcppconn.so when searching for -lmysqlcppconn
/usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/../../../../arm-linux-gnueabihf/bin/ld: skipping incompatible //usr/lib/libmysqlcppconn.a when searching for -lmysqlcppconn
/usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/../../../../arm-linux-gnueabihf/bin/ld: skipping incompatible /usr/arm-linux-gnueabihf/lib/libmysqlcppconn.so when searching for -lmysqlcppconn
/usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lmysqlcppconn
collect2: error: ld returned 1 exit status
make: *** [arm2] Error 1

12:38:18 Build Finished (took 2s.451ms)
0

You must first remove these options because your linker is trying to find in these paths (which clearly have not the .so files): -L/usr/lib/mysql -L/usr/lib and find and copy these files from your BBB to your machine:

libmysqlclient.a
libmysqlclient.so
ld-linux.so.3
ld-linux-armhf.so.3
libmysqlclient.a
libmysqlclient.so
libz.so.1

then add -L these files to your linker option.

Finally, add these options to your linker:

-L/usr/lib/arm-linux-gnueabihf -L/lib/arm-linux-gnueabihf -lmysqlclient -lpthread -lz -lm -lrt -ldl
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.