Solved Qt Creator error “No such file or directory” when using boost in mongocxx
-
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. -
@mrjj
Can you please provide me better guide how to change the compiler? I've looked it up in the internet but I haven't found anything useful. Ans can I still compile QML applications with MSVC? -
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.
-
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 ?
-
When I open Qt Maintenance Tool, it looks like this:
-
@SimonR Did you select Kit configured for MSVC compiler/Qt to build you project?
-
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.
-
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?
-
I've played with the setting a bit and now, it compiles, but it doesn't run and shows an error:
And when it try do run the debugger, it also shows an error:
-
@SimonR The last error says what is wrong and what needs to be done
-
So, i can compile the project now with MSVC, but when I try to make an connection using
mongocxx::instance inst{}; mongocxx::client conn{ mongocxx::uri{"my connection string"} }; bsoncxx::builder::stream::document document{};
it throws the same error as before:
When I delete the libs part in the .pro file, it works again and keeps working, until I include the libs again and try to use something from mongocxx. -
As a test, copy the dlls from that library in the same folder as your executable.
-
@SGaist no, that didn't help. Still the same error.
-
Then check that you have all the related dependencies available.
-
I've created a project in Visual Studio 2019 now with the same settings as in Qt Creator, and it works. Included all the header files, libs and dlls and it works. Don't know why this isn't working in Qt Creator. I've tried this but I get the same error. I have to delete the LIBS part and then it runs again. All the dlls are in the folder, but it crashes all the time.