0

我有一个用 C++ 编写的嵌入式应用程序(在 Linux 环境中的 PowerPC 上运行),它访问外部数据库。所以我的应用程序需要 mysql++ 库,这些库需要使用 powerpc 编译器构建。在构建库之前,我想在我的 Ubuntu VM 上为 linux 构建 mysql++ 库以检查过程。我从官网下载了最新的包。然后我按照提到的步骤进行操作。

  1. 从根目录运行 ./configure,我收到以下错误。

*检查 MySQL 库目录...配置:错误:在 '/usr/lib64 /usr/lib /usr/lib64/mysql /usr/lib/mysql /usr/local/lib64 /usr/ 中找不到 mysqlclient 库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' *

我尝试查找 mysqlclient 并没有找到任何参考,因此我按照其他论坛中给出的说明并尝试使用以下命令安装 libmysqlclient15-dev。

sudo apt-get install libmysqlclient15-dev

输出如下图

读取包列表...完成构建依赖树
读取状态信息...完成注意,选择'libmysqlclient-dev'而不是'libmysqlclient15-dev' libmysqlclient-dev 已经是最新版本。

以下软件包已自动安装且不再需要: 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-jni0-common libcommons-lang-java libwebkitgtk-1.0-0 libjavascriptcoregtk-1.0-0 libjsch-java ant-optional libswt-gnome-gtk-3-jni0-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.

4

1 回答 1

0

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.

于 2013-03-27T18:27:34.463 回答