build c++ script with err mysqlcppconn missing (no such file)

匿名 (未验证) 提交于 2019-12-03 09:14:57

问题:

there is a newbie to c++.

I want to prepare working environment for C++ development for Raspi 3. This includes C++ (netbeans IDE on windows, geany on Raspi), mysql (mariDB) and QT.

first step was a simple script "hello world" on raspi and make a build with help of cppconn. Second step was make the same script on windows in Netbeans IDE, and build it localy/remotely.

I have this simple script:

During build I get these Errors:

cd 'C:\Users\marek\Documents\c++ projects\hello-world-7-pc-mysql' C:\msys\1.0\bin\make.exe -f Makefile CONF=Debug "/C/msys/1.0/bin/make.exe" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf make.exe[1]: Entering directory `/c/Users/marek/Documents/c++ projects/hello-world-7-pc-mysql' "/C/msys/1.0/bin/make.exe"  -f nbproject/Makefile-Debug.mk dist/Debug/MinGW_Qt-Windows/hello-world-7-pc-mysql.exe make.exe[2]: Entering directory `/c/Users/marek/Documents/c++ projects/hello-world-7-pc-mysql' mkdir -p dist/Debug/MinGW_Qt-Windows g++     -o dist/Debug/MinGW_Qt-Windows/hello-world-7-pc-mysql build/Debug/MinGW_Qt-Windows/main.o -L/C/Program\ Files/MySQL/MySQL\ Connector\ C++\ 1.1.9/lib -L/C/Program\ Files/MySQL/MySQL\ Connector\ C++\ 1.1.9/include/cppconn -L/C/Program\ Files/MySQL/MySQL\ Connector\ C++\ 1.1.9/include -lmysqlcppconn-static -lmysqlcppconn "/C/Program Files/MySQL/MySQL Connector C++ 1.1.9/lib/opt/mysqlcppconn-static.lib" "/C/Program Files/MySQL/MySQL Connector C++ 1.1.9/lib/opt/mysqlcppconn.lib" -lmysqlcppconn   c:/Qt/Qt5.9.2/Tools/mingw530_32/bin/../lib/gcc/i686-w64-mingw32/5.3.0/../../../../i686-w64-mingw32/bin/ld.exe: cannot find -lmysqlcppconn-static c:/Qt/Qt5.9.2/Tools/mingw530_32/bin/../lib/gcc/i686-w64-mingw32/5.3.0/../../../../i686-w64-mingw32/bin/ld.exe: cannot find -lmysqlcppconn c:/Qt/Qt5.9.2/Tools/mingw530_32/bin/../lib/gcc/i686-w64-mingw32/5.3.0/../../../../i686-w64-mingw32/bin/ld.exe: cannot find -lmysqlcppconn collect2.exe: error: ld returned 1 exit status make.exe[2]: *** [dist/Debug/MinGW_Qt-Windows/hello-world-7-pc-mysql.exe] Error 1 make.exe[2]: Leaving directory `/c/Users/marek/Documents/c++ projects/hello-world-7-pc-mysql' make.exe[1]: *** [.build-conf] Error 2 make.exe[1]: Leaving directory `/c/Users/marek/Documents/c++ projects/hello-world-7-pc-mysql' make.exe": *** [.build-impl] Error 2  BUILD FAILED (exit value 2, total time: 858ms)

Totaly frustrated with setting up Mysql for C++ coding.

Please advice :)

Thank you, Marek

回答1:

I have reformatted your command line and your error message for better readability (specifically I put in line breaks, and normalized the path to ld).

g++ -o dist/Debug/MinGW_Qt-Windows/hello-world-7-pc-mysql \     build/Debug/MinGW_Qt-Windows/main.o \   -L/C/Program\ Files/MySQL/MySQL\ Connector\ C++\ 1.1.9/lib \   -L/C/Program\ Files/MySQL/MySQL\ Connector\ C++\ 1.1.9/include/cppconn \   -L/C/Program\ Files/MySQL/MySQL\ Connector C++\ 1.1.9/include \   -lmysqlcppconn-static \   -lmysqlcppconn \   "/C/Program Files/MySQL/MySQL Connector C++ 1.1.9/lib/opt/mysqlcppconn-static.lib" \   "/C/Program Files/MySQL/MySQL Connector C++ 1.1.9/lib/opt/mysqlcppconn.lib" \   -lmysqlcppconn c:/Qt/Qt5.9.2/Tools/i686-w64-mingw32/bin/ld.exe: cannot find -lmysqlcppconn-static c:/Qt/Qt5.9.2/Tools/i686-w64-mingw32/bin/ld.exe: cannot find -lmysqlcppconn c:/Qt/Qt5.9.2/Tools/i686-w64-mingw32/bin/ld.exe: cannot find -lmysqlcppconn

The first thing to say is that ld is failing to find files call -lmysqlconn. That is very strange, because normally, -l means "load the library called libmysqlconn with type .a or .so". However there are a number of very strange things about your command line:

Firstly -L is the command line option to specify where to find libraries (.lib, .so, .a, .dll) - so why are you specifing include directories?

Secondly, why are you specifying both -lmysqlconn-static and -lmysqlconn? You either want a static library, or a dynamic library - not both.

Thirdly, why are you trying to explicitly specify the library names (in the /C/... lines).

Fourthly, why do you specify -lmysqlcppconn twice?

I think you need to change the command line to be something like:

g++ -o dist/Debug/MinGW_Qt-Windows/hello-world-7-pc-mysql \    -L/C/Program\ Files/MySQL/MySQL\ Connector\ C++\ 1.1.9/lib \   -lmysqlcppconn \   build/Debug/MinGW_Qt-Windows/main.o

Finally, I think you need to read through the Qt tutorial carefully. At the moment, you seem to be just flailing around.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!