I have an embedded application written in C++ (running on a PowerPC in linux environment) which accesses an external database. So my application needs mysql++ libraries which needs to be built using a powerpc compiler. Before building the libraries, I wanted to build mysql++ libraries for linux on my Ubuntu VM to check the procedure. I downloaded the latest package from Official Website. Then I followed the steps mentioned.

  1. Ran ./configure from the root directory, I got the below error.

*checking for MySQL library directory... configure: error: Didn't find mysqlclient library in '/usr/lib64 /usr/lib /usr/lib64/mysql /usr/lib/mysql /usr/local/lib64 /usr/local/lib /usr/local/lib/mysql /usr/local/mysql/lib /usr/local/mysql/lib/mysql /usr/mysql/lib/mysql /opt/mysql/lib /opt/mysql/lib/mysql /sw/lib /sw/lib/mysql'*

I tried locate mysqlclient and did not find any references, hence I followed instructions given in other forums and tried to install the libmysqlclient15-dev using the below command.

sudo apt-get install libmysqlclient15-dev

The output is as shown below

Reading package lists... Done Building dependency tree
Reading state information... Done Note, selecting 'libmysqlclient-dev' instead of 'libmysqlclient15-dev' libmysqlclient-dev is already the newest version.

The following packages were automatically installed and are no longer required: libcommons-collections3-java junit4 libecj-java libdb5.1-java libasm3-java libgcj-bc gcj-4.6-jre-lib libgnomeui-common libcommons-el-java junit linux-headers-3.2.0-32 linux-headers-3.2.0-29 libcommons-compress-java libregexp-java libdb-java libswt-cairo-gtk-3-jni libjasper-java libbonoboui2-common libbonoboui2-0 libdb5.1-java-gcj libcommons-httpclient-java libservlet2.4-java liblucene2-java libswt-gtk-3-java libcommons-cli-java libslf4j-java libgcj12 libxml-commons-external-java libswt-webkit-gtk-3-jni linux-headers-3.2.0-29-generic-pae libswt-gtk-3-jni ant gcj-4.6-base libcommons-logging-java default-jdk libswt-glx-gtk-3-jni libcommons-codec-java jarwrapper libequinox-osgi-java libgcj-common libapache-pom-java libgnomeui-0 libjetty-java libjline-java libxerces2-java sat4j libcommons-beanutils-java libdb-je-java fastjar libcommons-digester-java libcommons-parent-java libhamcrest-java libjtidy-java libxml-commons-resolver1.1-java libicu4j-java linux-headers-3.2.0-32-generic-pae libicu4j-4.4-java libwebkitgtk-1.0-common libcommons-lang-java libwebkitgtk-1.0-0 libjavascriptcoregtk-1.0-0 libjsch-java ant-optional libswt-gnome-gtk-3-jni

Use 'apt-get autoremove' to remove them. 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

After this I tried to locate libmysqlclient and I still couldn't find the libraries (.so files). I tried ./configure again and it failed in the same location with the same error message. How can I install libmysqlclient ?

Once this is solved I will rebuild the mysql++ library using my toolchain for powerpc. Has anyone tried this ? To build mysql++ library I need mysqlclient, in the earlier example I would install it by executing the command apt-get, but the libraries would be compiled using a gnu compiler ? How to cross compile mysqlclient for powerpc ? I guess I need to do the below

  1. Build mysqlclient for powerpc.
  2. Use those libraries and build mysql++ libraries for powerpc.
  3. Use mysql++ and mysqlclient libraries in my application and compile for powerpc.

I am new to linux and databases.

有帮助吗?

解决方案

I finally solved this problem. I did the below.

  1. Downloaded the Connector/C (libmysql) source files from here
  2. Cross compiled it for powerpc, below is the command given to cmake

    cmake -DCMAKE_INSTALL_PREFIX="~/mysqlclient_C/lib" -DCMAKE_C_COMPILER="ppc_4xx-gcc" -DCMAKE_C_FLAGS="-I/opt/ELDK/4.2/ppc_4xx/usr/include/" -DCMAKE_CXX_COMPILER="ppc_4xx-g++" -DCMAKE_CXX_FLAGS="-I/opt/ELDK/4.2/ppc_4xx/usr/include/" -DCMAKE_EXE_LINKER_FLAGS="-lm"
    

Then a simple make generated the libmysql libraries.

  1. Downloaded mysql++ source files from here
  2. Cross compiled it for powerpc, below is my configure command

    ./configure --target=powerpc-linux --host=powerpc-linux  --prefix="$HOME/mysql++/lib" --enable-thread-check --with-mysql="$HOME/mysqlclient_C/lib" CC=ppc_4xx-gcc CXX=ppc_4xx-g++ LDFLAGS=-lm CFFLAGS="-I/opt/ELDK/4.2/ppc_4xx/usr/include" CXXFLAGS="-I/opt/ELDK/4.2/ppc_4xx/usr/include"
    
  3. The mysql++ libraries is generated now.

I have not tested the built libraries yet.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top