When I’m trying to compile the following code I’m getting so many issues. But mongoc and mongocxx drivers are installed on my pc.
code :
#include <cstdint>
#include <iostream>
#include <vector>
#include <bsoncxx/json.hpp>
#include <mongocxx/client.hpp>
#include <mongocxx/stdx.hpp>
#include <mongocxx/uri.hpp>
#include <mongocxx/instance.hpp>
#include <bsoncxx/builder/stream/helpers.hpp>
#include <bsoncxx/builder/stream/document.hpp>
#include <bsoncxx/builder/stream/array.hpp>
using bsoncxx::builder::stream::close_array;
using bsoncxx::builder::stream::close_document;
using bsoncxx::builder::stream::document;
using bsoncxx::builder::stream::finalize;
using bsoncxx::builder::stream::open_array;
using bsoncxx::builder::stream::open_document;
int main()
{
mongocxx::instance instance{}; // This should be done only once.
mongocxx::uri uri("mongodb://localhost:27017");
mongocxx::client client(uri);
mongocxx::database db = client["sliit"];
return 0;
}
compiling command :
g++ --std=c++17 main.cpp -o test -IC:/mongo-cxx-driver/include/mongocxx/v_noabi -IC:/mongo-cxx-driver/include/bsoncxx/v_noabi -LC:/mongo-cxx-driver /lib -lmongocxx -lbsoncxx -IC:\local\boost_1_60_0
Error :
c:/users/tharindu/downloads/programs/mingw/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\Tharindu\AppData\Local\Temp\ccRL6mIk.o:main.cpp:(
.text+0x2d): undefined reference to `__imp__ZN8mongocxx7v_noabi8instanceC1Ev'
c:/users/tharindu/downloads/programs/mingw/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\Tharindu\AppData\Local\Temp\ccRL6mIk.o:main.cpp:(
.text+0x36): undefined reference to `__imp__ZN8mongocxx7v_noabi3uri13k_default_uriB5cxx11E'
c:/users/tharindu/downloads/programs/mingw/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\Tharindu\AppData\Local\Temp\ccRL6mIk.o:main.cpp:(
.text+0x54): undefined reference to `__imp__ZN8mongocxx7v_noabi3uriC1EN7bsoncxx7v_noabi6string13view_or_valueE'
c:/users/tharindu/downloads/programs/mingw/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\Tharindu\AppData\Local\Temp\ccRL6mIk.o:main.cpp:(
.text+0x94): undefined reference to `__imp__ZN8mongocxx7v_noabi6clientC1ERKNS0_3uriERKNS0_7options6clientE'
c:/users/tharindu/downloads/programs/mingw/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\Tharindu\AppData\Local\Temp\ccRL6mIk.o:main.cpp:(
.text+0xb0): undefined reference to `__imp__ZN8mongocxx7v_noabi3uriD1Ev'
c:/users/tharindu/downloads/programs/mingw/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\Tharindu\AppData\Local\Temp\ccRL6mIk.o:main.cpp:(
.text+0xe4): undefined reference to `__imp__ZN8mongocxx7v_noabi6clientD1Ev'
c:/users/tharindu/downloads/programs/mingw/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\Tharindu\AppData\Local\Temp\ccRL6mIk.o:main.cpp:(
.text+0xf4): undefined reference to `__imp__ZN8mongocxx7v_noabi8instanceD1Ev'
c:/users/tharindu/downloads/programs/mingw/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\Tharindu\AppData\Local\Temp\ccRL6mIk.o:main.cpp:(
.text+0x11a): undefined reference to `__imp__ZN8mongocxx7v_noabi3uriD1Ev'
c:/users/tharindu/downloads/programs/mingw/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\Tharindu\AppData\Local\Temp\ccRL6mIk.o:main.cpp:(
.text+0x140): undefined reference to `__imp__ZN8mongocxx7v_noabi6clientD1Ev'
c:/users/tharindu/downloads/programs/mingw/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\Tharindu\AppData\Local\Temp\ccRL6mIk.o:main.cpp:(
.text+0x155): undefined reference to `__imp__ZN8mongocxx7v_noabi8instanceD1Ev'
c:/users/tharindu/downloads/programs/mingw/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\Tharindu\AppData\Local\Temp\ccRL6mIk.o:main.cpp:(
.text$_ZN7bsoncxx7v_noabi7builder6stream8documentC1Ev[_ZN7bsoncxx7v_noabi7builder6stream8documentC1Ev]+0x33): undefined reference to `__imp__ZN7bsoncxx7v_noabi7builder4coreC1Eb'
c:/users/tharindu/downloads/programs/mingw/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\Tharindu\AppData\Local\Temp\ccRL6mIk.o:main.cpp:(
.text$_ZN7bsoncxx7v_noabi7builder6stream8documentD1Ev[_ZN7bsoncxx7v_noabi7builder6stream8documentD1Ev]+0x1a): undefined reference to `__imp__ZN7bsoncxx7v_noabi7builder4coreD1Ev'
Can someone please help me regarding this issue?