Important: Please read the Qt Code of Conduct -

QMake seemingly Unable to add MySQL connector in windows port.

  • Good day

    I have been spending time on improving a private project during idle times lately. What I am currently doing is an attempt to port my project to windows, using the MSVC compiler.

    The project consists of two parts: The server and the client. Originally the client part was made using the Qt GUI frameworks, but I've since ported the client to java. However the server is still c++ based, relying almost entirely on the STL save for a tiny bit of MySQL database interaction.

    Which leads me to my point: I can't get QMake to behave when I try to include the library on my windows version of Qt creator(version 4.4). Or well I think the problem is QMake, the MSVC linker only gives the cryptic "LNK1104: cannot open file 'mysqlcppconn-static.lib' ". That mysqlcppconn refers to this: The MySQL connector is needed in order to connect to MySQL databases.

    According to this: 1104 can mean quite a few things, not being able to find the file being just one of them, so I am unsure if the compiler even finds the file. Deliberately changing the name of the file to something that's obviously wrong results in the same error message.

    I've tried adding the library in all three ways: internal, external and system. Nothing works.

    An interesting observation though, when adding the library as external, I get the following error message:

    dependent 'C:\Users\pette\Dropbox\c++2015\2016\Prosjekt2016Server\..\..\..\..\..\..\Program Files\MySQL\MySQL Connector C++ 1.1.9\lib\opt\mysqlcppconn-staticd.lib' does not exist.

    Which is wierd, 'mysqlcppconn-staticd.lib' doesn't exist, which indicates that it fails the first check. I am beginning to think qmake is incapable of navigating windows file systems properly. At any rate, I am adding the entire .pro file:

    TEMPLATE = app
    TARGET = G_Holdem_Serv
    CONFIG += console
    CONFIG -= app_bundle
    CONFIG -= qt
    unix: LIBS += -pthread
    unix: LIBS += -lrt
    unix: LIBS += -L/usr/lib -lmysqlcppconn
    unix: INCLUDEPATH += -I/usr/include/cppconn
    QMAKE_CXXFLAGS += -std=c++11
    QMAKE_CXXFLAGS += -std=c++11 -pthread
    SOURCES += \
        holdempokergame.cpp \
        pokerevaluatorengine.cpp \
        card.cpp \
        deckofcards.cpp \
        protocolenums.cpp \
        playerrepresentation.cpp \
        potdata.cpp \
        scoreobject.cpp \
        profilemanager.cpp \
        configloader.cpp \
        UNIXserver.cpp \
    HEADERS += \
        server.h \
        holdempokergame.h \
        pokerevaluatorengine.h \
        card.h \
        deckofcards.h \
        protocolenums.h \
        playerrepresentation.h \
        potdata.h \
        scoreobject.h \
        profilemanager.h \
    #created when added as a external library.
    win32:CONFIG(release, debug|release): LIBS += -L$$PWD/'../../../../../../Program Files/MySQL/MySQL Connector C++ 1.1.9/lib/opt/' -lmysqlcppconn-static
    else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/'../../../../../../Program Files/MySQL/MySQL Connector C++ 1.1.9/lib/opt/' -lmysqlcppconn-staticd
    INCLUDEPATH += $$PWD/'../../../../../../Program Files/MySQL/MySQL Connector C++ 1.1.9/lib/opt'
    DEPENDPATH += $$PWD/'../../../../../../Program Files/MySQL/MySQL Connector C++ 1.1.9/lib/opt'
    win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/'../../../../../../Program Files/MySQL/MySQL Connector C++ 1.1.9/lib/opt/libmysqlcppconn-static.a'
    else:win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/'../../../../../../Program Files/MySQL/MySQL Connector C++ 1.1.9/lib/opt/libmysqlcppconn-staticd.a'
    else:win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/'../../../../../../Program Files/MySQL/MySQL Connector C++ 1.1.9/lib/opt/mysqlcppconn-static.lib'
    else:win32:!win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/'../../../../../../Program Files/MySQL/MySQL Connector C++ 1.1.9/lib/opt/mysqlcppconn-staticd.lib'
    #created when added as a system library.
    #win32: LIBS += -lmysqlcppconn-static
    #internal isn't completable.
    #full path to the mysql library directory, has a include and a lib folder, plus some readme files.
    #C:\Program Files\MySQL\MySQL Connector C++ 1.1.9\

    I am not sure what else I can say, hopefully you can give me pointer as to what's wrong.

  • Lifetime Qt Champion

    @Petter-Gjerstad I downloaded the archive: there is no mysqlcppconn-staticd.lib only mysqlcppconn-static.lib

  • @jsulm yes! That's precisely my point, it means it can't locate the non-d version either, which does exist.

    My line of thinking was that it confirms that it is unable to read a file that we know exists. The question then is this: Is the code used by the dialog unable to properly navigate windows file systems? To reiterate: I did not write that code, it was generated by Qt itself. I selected the mysqlcppconn-static.lib file in the dialog, still qmake, or the compiler(I don't know which it is) is unable to find it.

Log in to reply