2

I get this error while compiling my program: Error 1 error VGDB1000: undefined reference to

`mongocxx::v_noabi::uri::k_default_uri' C:\Users\XXXX\AppData\Local\VisualGDB\RemoteSourceCache\192.168.1.108\0004\include\bsoncxx\v_noabi\bsoncxx\string\view_or_value.hpp project-name

It is a linker error. I link with the libraries libbsoncxx and libmongocxx. I include these files:

#include <bsoncxx/builder/stream/document.hpp>
#include <bsoncxx/json.hpp>
#include <mongocxx/client.hpp>
#include <mongocxx/options/find.hpp>
#include <mongocxx/instance.hpp>
#include <mongocxx/uri.hpp>

I have no idea of how to fix this error message. Any help much appreciated!


Thanks, Easter postponed this one a bit. Here is the minimal example: github.com/xauxatz/LinuxTest

The link command is this:

g++ -o Debug/LinuxProject1 -Wl,-gc-sections -L/usr/local/lib -Wl,--start-group Debug/LinuxProject1.o -lbsoncxx -lmongocxx -Wl,--rpath='$ORIGIN' -Wl,--end-group

Complete error output:

Debug/LinuxProject1.o: In function `main':
/usr/local/include/bsoncxx/v_noabi/bsoncxx/string/view_or_value.hpp:70: undefined reference to `mongocxx::v_noabi::uri::k_default_uri'
collect2: error: ld returned 1 exit status

So obviously it has to do with "mongocxx::uri {}". If I remove this, it compiles fine.


Here is the minimal example: github.com/xauxatz/LinuxTest

The link command is this:

g++ -o Debug/LinuxProject1 -Wl,-gc-sections -L/usr/local/lib -Wl,--start-group Debug/LinuxProject1.o -lbsoncxx -lmongocxx -Wl,--rpath='$ORIGIN' -Wl,--end-group

Complete error output:

Debug/LinuxProject1.o: In function `main':
/usr/local/include/bsoncxx/v_noabi/bsoncxx/string/view_or_value.hpp:70: undefined reference to `mongocxx::v_noabi::uri::k_default_uri'
collect2: error: ld returned 1 exit status

So obviously it has to do with "mongocxx::uri {}". If I remove this, it compiles fine.

Xauxatz
  • 143
  • 2
  • 9
  • Please post a minimal compilable example, the link line that your build system generated to link your example, and the complete error output of the compiler and linker. – acm Mar 24 '16 at 11:47
  • I edited question above to add what you requested – Xauxatz Mar 29 '16 at 09:26
  • I actually managed to get it to work now. It had to do with incorrectly compiled and installed libraries for bson and mongocxx. When I couldn't get it to compile, I copied an installation of the libraries over from another server - apparently I shouldn't have done that. I managed to get the libraries to compile on this new server just now - and as a result the above example now compiles well. – Xauxatz Mar 29 '16 at 10:20

0 Answers0