Qt Creator error “No such file or directory” when using boost in mongocxx
-
wrote on 25 Apr 2020, 09:13 last edited by
I've changed my .pro file to this now, but I still get the same error.
QT += quick CONFIG += c++17 DEFINES += QT_DEPRECATED_WARNINGS SOURCES += \ main.cpp \ signIn.cpp \ signUp.cpp INCLUDEPATH += C:/mongo-cxx-driver-3.4.1/include/bsoncxx/v_noabi \ C:/mongo-cxx-driver-3.4.1/include/mongocxx/v_noabi \ D:/boost_1_72_0 RESOURCES += qml.qrc TRANSLATIONS += \ LogIn_en_CA.ts QML_IMPORT_PATH = QML_DESIGNER_IMPORT_PATH = qnx: target.path = /tmp/$${TARGET}/bin else: unix:!android: target.path = /opt/$${TARGET}/bin !isEmpty(target.path): INSTALLS += target HEADERS += \ signIn.h \ signUp.h LIBS += -LC:/mongo-cxx-driver-3.4.1/lib -lbsoncxx \ -LC:/mongo-cxx-driver-3.4.1/lib -lmongocxx
-
I've changed my .pro file to this now, but I still get the same error.
QT += quick CONFIG += c++17 DEFINES += QT_DEPRECATED_WARNINGS SOURCES += \ main.cpp \ signIn.cpp \ signUp.cpp INCLUDEPATH += C:/mongo-cxx-driver-3.4.1/include/bsoncxx/v_noabi \ C:/mongo-cxx-driver-3.4.1/include/mongocxx/v_noabi \ D:/boost_1_72_0 RESOURCES += qml.qrc TRANSLATIONS += \ LogIn_en_CA.ts QML_IMPORT_PATH = QML_DESIGNER_IMPORT_PATH = qnx: target.path = /tmp/$${TARGET}/bin else: unix:!android: target.path = /opt/$${TARGET}/bin !isEmpty(target.path): INSTALLS += target HEADERS += \ signIn.h \ signUp.h LIBS += -LC:/mongo-cxx-driver-3.4.1/lib -lbsoncxx \ -LC:/mongo-cxx-driver-3.4.1/lib -lmongocxx
wrote on 25 Apr 2020, 11:06 last edited byThis post is deleted! -
I'm writing an application in Qt and want to add the mongocxx driver to access data in my db. I've added the libs and header files using LIBS and INCLUDEPATH. Now, mongocxx also requires boost. But now I get the error:
C:\mongo-cxx-driver-3.4.1\include\bsoncxx\v_noabi\bsoncxx\stdx\string_view.hpp:40: error: boost/version.hpp: No such file or directory #include <boost/version.hpp>
. When I include the file in main.cpp, everything works fine. What should I do?My .pro file:
QT += quick CONFIG += c++17 DEFINES += QT_DEPRECATED_WARNINGS SOURCES += \ main.cpp \ signIn.cpp \ signUp.cpp INCLUDEPATH += C:\mongo-cxx-driver-3.4.1\include\bsoncxx\v_noabi \ C:\mongo-cxx-driver-3.4.1\include\mongocxx\v_noabi \ D:\boost_1_72_0 RESOURCES += qml.qrc TRANSLATIONS += \ LogIn_en_CA.ts QML_IMPORT_PATH = QML_DESIGNER_IMPORT_PATH = qnx: target.path = /tmp/$${TARGET}/bin else: unix:!android: target.path = /opt/$${TARGET}/bin !isEmpty(target.path): INSTALLS += target HEADERS += \ signIn.h \ signUp.h LIBS += C:\mongo-cxx-driver-3.4.1\lib\bsoncxx.lib \ C:\mongo-cxx-driver-3.4.1\lib\mongocxx.lib
wrote on 25 Apr 2020, 13:46 last edited byNo such file or directory #include <boost/version.hpp>.
I guess you need to provide INCLUDEPATH with a path that points to a place where you can later finder a subfolder
boost
which insides has a fileversion.hpp
So since you provide
D:/boost_1_72_0
does it hold there?
I mean is your folder structure like this?:D: |---boost_1_72_0 |---boost |---version.hpp
-
wrote on 25 Apr 2020, 14:17 last edited by
@Pablo-J-Rogina
Yes, my folder structure looks excactly like you discribed it. The strange thing is that when I include it in the main file,
it doesn't cause any errors. I've set up an test application in Visual Studio and everything works fine there. -
@Pablo-J-Rogina
Yes, my folder structure looks excactly like you discribed it. The strange thing is that when I include it in the main file,
it doesn't cause any errors. I've set up an test application in Visual Studio and everything works fine there.What happens if you fix your include path?
INCLUDEPATH += C:/mongo-cxx-driver-3.4.1/include/bsoncxx/v_noabi \ C:/mongo-cxx-driver-3.4.1/include/mongocxx/v_noabi \ D:/boost_1_72_0
Also, please show the compile output line leading to this error so we can check the flags passed to the compiler.
-
wrote on 25 Apr 2020, 15:38 last edited by SimonR
Strange, it's compiling now. But when I try to access a database using
mongocxx::instance inst{ mongocxx::client conn{ mongocxx::uri{"connection string goes here"} }; bsoncxx::builder::stream::document document{};
, I get lots of errors. I think these are linking errors.
Please excuse that I ask a lot, but I'm new to Qt Creator.
-
Hi,
Are you sure that the libraries are of the correct architecture and built by the same compiler ?
-
wrote on 26 Apr 2020, 09:24 last edited by
The compiler used for building the driver was MSVC, so that might be an issue because Qt Creator uses MinGW. How can I change the compiler?
-
The compiler used for building the driver was MSVC, so that might be an issue because Qt Creator uses MinGW. How can I change the compiler?
@SimonR
Hi
Use Qt maintenance tool to install the visual studio version of Qt for 2017/2019 32/64 VS
and then go and download the compiler from Microsoft site. -
Well: go to the Microsoft website, download the Visual Studio installer, then execute it.
As for Qt Quick, the compiler has no role here. As long as you have the modules built, it will work.
-
wrote on 26 Apr 2020, 12:50 last edited by
So, I have Visual Studio now, anything else I have to do? The compiler is still MinGW.
-
As @mrjj already suggested, did you install the MSVC build of Qt ?
-
wrote on 26 Apr 2020, 13:33 last edited by
-
@SimonR Did you select Kit configured for MSVC compiler/Qt to build you project?
-
wrote on 27 Apr 2020, 06:09 last edited by SimonR
I've selected the right compiler now,
but when I try to run the program, I get an error.
When I open the kits section, it shows some warnings:
Is this normal? Or do I have to set up something else? Also, I found out that you can change it compiler, but it only shows amd64 and x86 architecture. I have an Intel processor, can I still use the amd64 because I haven't found the right settings for Intel processors?
-
I've selected the right compiler now,
but when I try to run the program, I get an error.
When I open the kits section, it shows some warnings:
Is this normal? Or do I have to set up something else? Also, I found out that you can change it compiler, but it only shows amd64 and x86 architecture. I have an Intel processor, can I still use the amd64 because I haven't found the right settings for Intel processors?
@SimonR Run it through debugger - looks like it is crashing.
-
wrote on 27 Apr 2020, 10:05 last edited by
So I've set up the compiler now, but when I run the application I get errors:
I don't know why the language is German, because it's set to English. But as far as I know, those errors are linking errors, so I guess the libraries are not included correctly.
Here is my .pro file:
QT += quick CONFIG += c++17 DEFINES += QT_DEPRECATED_WARNINGS SOURCES += \ main.cpp \ signIn.cpp \ signUp.cpp INCLUDEPATH += C:/mongo-cxx-driver-3.4.1/include/bsoncxx/v_noabi \ C:/mongo-cxx-driver-3.4.1/include/mongocxx/v_noabi \ D:/boost_1_72_0 RESOURCES += qml.qrc TRANSLATIONS += \ LogIn_en_CA.ts QML_IMPORT_PATH = QML_DESIGNER_IMPORT_PATH = qnx: target.path = /tmp/$${TARGET}/bin else: unix:!android: target.path = /opt/$${TARGET}/bin !isEmpty(target.path): INSTALLS += target HEADERS += \ signIn.h \ signUp.h LIBS += -LC:/mongo-cxx-driver-3.4.1/lib -lbsoncxx \ -LC:/mongo-cxx-driver-3.4.1/lib -lmongocxx
-
So I've set up the compiler now, but when I run the application I get errors:
I don't know why the language is German, because it's set to English. But as far as I know, those errors are linking errors, so I guess the libraries are not included correctly.
Here is my .pro file:
QT += quick CONFIG += c++17 DEFINES += QT_DEPRECATED_WARNINGS SOURCES += \ main.cpp \ signIn.cpp \ signUp.cpp INCLUDEPATH += C:/mongo-cxx-driver-3.4.1/include/bsoncxx/v_noabi \ C:/mongo-cxx-driver-3.4.1/include/mongocxx/v_noabi \ D:/boost_1_72_0 RESOURCES += qml.qrc TRANSLATIONS += \ LogIn_en_CA.ts QML_IMPORT_PATH = QML_DESIGNER_IMPORT_PATH = qnx: target.path = /tmp/$${TARGET}/bin else: unix:!android: target.path = /opt/$${TARGET}/bin !isEmpty(target.path): INSTALLS += target HEADERS += \ signIn.h \ signUp.h LIBS += -LC:/mongo-cxx-driver-3.4.1/lib -lbsoncxx \ -LC:/mongo-cxx-driver-3.4.1/lib -lmongocxx
@SimonR Looks like you're not linking properly against mongocxx. Which compiler was used to build those libraries and are they 32bit or 64bit?
-
wrote on 27 Apr 2020, 12:58 last edited by
12/28