undefined reference to `_imp___ZN8mongocxx7v_noabi8instanceC1Ev in Qt?
-
hello iam solved my linking error of mongodb with qt creator , now i can include header file but when in command mongocxx::instance inst; error came
E:/vivek/dw_tdoa_controller5/dw_tdoa_controller/main.cpp:37: undefined reference to `_imp___ZN8mongocxx7v_noabi8instanceC1Ev'
my pro file
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.dll INCLUDEPATH += C:/mongo-cxx-driver/include/mongocxx/v_noabi DEPENDPATH += C:/mongo-cxx-driver/include/mongocxx/v_noabi win32:CONFIG(release, debug|release): LIBS += -LC:/mongo-cxx-driver/lib/ -llibbsoncxx.dll else:win32:CONFIG(debug, debug|release): LIBS += -LC:/mongo-cxx-driver/lib/ -llibbsoncxx.dll INCLUDEPATH += C:/mongo-cxx-driver/include/bsoncxx/v_noabi DEPENDPATH += C:/mongo-cxx-driver/include/bsoncxx/v_noabi
how to fix it
-
@Vivek_A Please take a look at https://doc.qt.io/qt-5/qmake-variable-reference.html#libs
and fix your LIBS (hint: you need to add .lib not .dll). -
LIBS += C:/mongo-cxx-driver/lib/llibbsoncxx.dll INCLUDEPATH += C:/mongo-cxx-driver/include/mongocxx/v_noabi DEPENDPATH += C:/mongo-cxx-driver/include/mongocxx/v_noabi
Output:
g++: error: C:\mongo-cxx-driver\lib\llibbsoncxx.dll: No such file or directory Makefile.Release:233: recipe for target 'release\RTLSController.exe' failed
-
@Vivek_A said in undefined reference to `_imp___ZN8mongocxx7v_noabi8instanceC1Ev in Qt?:
C:\mongo-cxx-driver\lib\llibbsoncxx.dll
So, does this file exist? And I mean exact this path.
-
@Vivek_A said in undefined reference to `_imp___ZN8mongocxx7v_noabi8instanceC1Ev in Qt?:
g++: error: C:\mongo-cxx-driver\lib\llibbsoncxx.dll: No such file or directory
Originally you had
-llibbsoncxx.dll
. I am thinking the leading-l
was an argument to the linker, followed by the DLL file name? Which would make itLIBS += C:/mongo-cxx-driver/lib/libbsoncxx.dll
(only onel
)?However, this is a separate matter from whether you should be specifying a
.dll
here, I thought you would need either a.lib
(MSVC) or a.a
(MinGW)...? -
@jsulm
A.lib
will not do him, as he is using MinGW/gcc. I now see he wrote earlier:full file is llibmongocxx.dll.a
That is an unusual naming convention! If that is really the case, and applies to
llibbsoncxx.dll.a
too, then it would indeed seem to be as he wrote. But the error messageg++: error: C:\mongo-cxx-driver\lib\llibbsoncxx.dll: No such file or directory
shows what MinGW seems actually to be looking for, no mention of a
.a
suffix. So I'm not sure what is going on.... -
@jsulm ok, i understand idid this
LIBS += C:/mongo-cxx-driver/lib/libbsoncxx.dll.a INCLUDEPATH += C:/mongo-cxx-driver/include/mongocxx/v_noabi DEPENDPATH += C:/mongo-cxx-driver/include/mongocxx/v_noabi
included but error that said first remains
./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'
if you dont know about windows side of this , then its ok.
@JonB i have doubt , the compiler is mingw 32 and i build the mongdb in mingw 64 is this makes any issues -
@Vivek_A said in undefined reference to `_imp___ZN8mongocxx7v_noabi8instanceC1Ev in Qt?:
LIBS += C:/mongo-cxx-driver/lib/libbsoncxx.dll.a
This looks much more reasonable than before!
Now as @jsulm says it looks like you need some further similars for other library files required to link successfully.
@JonB i have doubt , the compiler is mingw 32 and i build the mongdb in mingw 64 is this makes any issues
I am not sure what you are saying. It will not be possible to mix 64-bit-compiled code with 32-bit-compiled code in one executable. The compiler's bit-ness is not at issue, rather only whichever bit-ness it is generating code for.
Start by trying what @jsulm has pointed out, then deal with bit-ness if there is still an error.....
-
@JonB modified
LIBS += C:/mongo-cxx-driver/lib/libbsoncxx.dll.a LIBS += C:/mongo-cxx-driver/lib/libmongocxx.dll.a INCLUDEPATH += C:/mongo-cxx-driver/include/mongocxx/v_noabi DEPENDPATH += C:/mongo-cxx-driver/include/mongocxx/v_noabi INCLUDEPATH += C:/mongo-cxx-driver/include/bsoncxx/v_noabi DEPENDPATH += C:/mongo-cxx-driver/include/bsoncxx/v_noabi
clean & rebuilded
Output:./release\main.o:main.cpp:(.text+0x19): undefined reference to `_imp___ZN8mongocxx7v_noabi8instanceC1Ev' ./release\main.o:main.cpp:(.text+0x23): undefined reference to `_imp___ZN8mongocxx7v_noabi8instanceD1Ev' collect2.exe: error: ld returned 1 exit status
-
@Vivek_A anybody help...is that compiler problem
./debug\main.o: In function `Z5qMainiPPc': E:/vivek/dw_tdoa_controller7/dw_tdoa_controller/main.cpp:36: undefined reference to `_imp___ZN8mongocxx7v_noabi8instanceC1Ev' E:/vivek/dw_tdoa_controller7/dw_tdoa_controller/main.cpp:36: undefined reference to `_imp___ZN8mongocxx7v_noabi8instanceD1Ev' E:/vivek/dw_tdoa_controller7/dw_tdoa_controller/main.cpp:36: undefined reference to `_imp___ZN8mongocxx7v_noabi8instanceD1Ev' collect2.exe: error: ld returned 1 exit status Makefile:36: recipe for target 'debug' failed mingw32-make[1]: *** [debug\RTLSController.exe] Error 1 mingw32-make: *** [debug] Error 2 17:25:51: The process "C:\Qt\Qt5.11.2\Tools\mingw530_32\bin\mingw32-make.exe" exited with code 2. Error while building/deploying project dw_controller (kit: Desktop Qt 5.11.2 MinGW 32bit) When executing step "Make"
-
Try inverting the order of the libraries you are linking.