0

I built a simple c++ application using Netbeans on ubuntu. in the application I use mysql_connection and curl. the application is working fine on my local system (Ubuntu)

when I tried to run the application on my Centos server I get this message:

 error while loading shared libraries: libmysqlcppconn.so.5: cannot open shared object file: No such file or directory.

tried to check if the libmysqlcppconn.so.5 library exists on the server or not I found that there is the following:

 REMOTE (Centos)
 **in [/usr/local/lib]**

 libmysqlcppconn-static.a  
 libmysqlcppconn.so@  
 libmysqlcppconn.so.7@  
 libmysqlcppconn.so.7.1.1.3*


 LOCAL (Ubuntu)
 **in [/usr/lib]**

 libmysqlcppconn-static.a  
 libmysqlcppconn.so@  
 libmysqlcppconn.so.5@  
 libmysqlcppconn.so.5.1.1.0*

why can't the application run? How can I fix it?

medo ampir
  • 1,850
  • 7
  • 33
  • 57

2 Answers2

2

You should build and package it for your server.

Your application was linked against a different (incompatible) version of one of the libraries it uses.

IMHO the simplest is often to build it on the box it is going to run on.

wojciii
  • 4,253
  • 1
  • 30
  • 39
  • 1
    I like that answer and I hate it. Its just i'm using Netbeans on ubuntu and it actually does everything for me in building the project. but doing it on centos via terminal !! I just tried and I got a lot of errors starting with "/usr/local/include/cppconn/connection.h:31:29: error: boost/variant.hpp: No such file or directory" – medo ampir Jun 08 '14 at 10:57
  • It looks like you need to install the dependencies on your server. I personally like CMake and it seems that you can make it play nice with Netbeans. Maybe you should consider using it so that you can have one project which works for both your server (from command line) and from your nice UI. :) – wojciii Jun 08 '14 at 11:05
  • when I installed the cpp connector i used "cmake . -DBOOST_ROOT:STRING=/boost_1_55_0" so the installation recognize the boost directory. what else should I do. or should I start another question :) – medo ampir Jun 08 '14 at 11:09
  • 1
    You should start another question as there will be more people who will be able to help. – wojciii Jun 08 '14 at 11:11
1

In general, there is no guarantee that a binary built on a Linux system will work on a different Linux system (either a different distribution or a different version of the same distribution). For some applications it's enough to copy the library files (lib*.so*) or linking it statically (gcc -static), but in general distributing programs for multiple Linux systems is more complicated without an easy solution.

One solution is to recompile your program for each system you want to run it on. For that you need to install the compiler and the library dependencies (including the *-devel packages) first to those systems.

pts
  • 80,836
  • 20
  • 110
  • 183