Mongodb linking error in Qt creator Windows

i tried linking lib by this link Adding Libraries to Projects | Qt Creator Manual.

after clicking and setting as external library
linking code came in pro file like this

win32:CONFIG(release, debug|release): LIBS += -LC:/mongo-cxx-driver/lib/ -llibmongocxx.dll
else:win32:CONFIG(debug, debug|release): LIBS += -LC:/mongo-cxx-driver/lib/ -llibmongocxx.dlld

INCLUDEPATH += C:/mongo-cxx-driver/include
DEPENDPATH += C:/mongo-cxx-driver/include

after that i added ```
#include <mongocxx/client.hpp>

in main.cpp but error coming no such file or directory...please check...!!!

@VIVEK_A Please provide the complete (verbose) compiler command that is being executed and the complete output, including exact error messages.

And show the directory content of

image

@Roberto_Sanchez hi, iam working on mongodbcxx with qt creator in Windows,

  1. Qt creator version Qt 5.11.2 (MSVC 2015, 32 bit)
  2. Project compiler is MingW 32bit.
  3. Build mongodb c & cxx driver with Mingw-64 -success.
  4. Added this library to Qt creator as external dynamic library.
    After that clean & Rebuilded.
    win32:CONFIG(release, debug|release): LIBS += -LC:/mongo-cxx-driver/lib/ -llibmongocxx.dll
    else:win32:CONFIG(debug, debug|release): LIBS += -LC:/mongo-cxx-driver/lib/ -llibmongocxx.dlld
  5. then error came -llibmongocxx.dlld no such file
  6. Then i removed last d from that -llibmongocxx.dlld.
  7. now build ok.
  8. Then i i added #include <mongocxx/client.hpp> and necessary headers
    Then added mongocxx::instance inst{};
    Then error came
    ./release\main.o:main.cpp:(.text+0x1d): undefined reference to _imp___ZN8mongocxx7v_noabi8instanceC1Ev'
    ./release\main.o:main.cpp:(.text+0xee): undefined reference to _imp___ZN8mongocxx7v_noabi8instanceD1Ev' ./release\main.o:main.cpp:(.text+0x14e): undefined reference to _imp___ZN8mongocxx7v_noabi8instanceD1Ev'

collect2.exe: error: ld returned 1 exit status

mingw32-make[1]: *** [release\RTLSController.exe] Error 1

@VIVEK_A I am not familiar with Qt creator, but it may be that you need to specify the library name as libmongocxx instead of libmongocxx.dll. It is also possible that you need to use mongocxx as the library name so that you end with -lmongocxx and -lmongocxxd as the command-line options to the compiler/linker. I say that because based on the pro file excerpt you provided, in the debug branch the option -llibmongocxx.dlld does not seem at all correct.

@Roberto_Sanchez see the content of mongodbcxx/lib folder is libmongocxx.dll.a (.a file).so the lib mention will be libmongocxx.dll right?? and there is feature in Qt creator to add external libraries . so we just need to select the file they will generate code for .pro file…

@VIVEK_A what commands did you use to build and install the C and C++ drivers on your system?

my compiler is mingw32bit and mongocxx driver build in 64 bit . so thats make problem , isolved it by installing 64bit Qt

1 Like

@VIVEK_A thanks for following up. I am glad that you were able to identify the issue with the 32-bit/64-bit mismatch.

2 Likes

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.