[CXX-1016] problem compiling helloworld.cpp Created: 04/Sep/16 Updated: 11/Sep/19 Resolved: 06/Oct/16 |
|
| Status: | Closed |
| Project: | C++ Driver |
| Component/s: | Build |
| Affects Version/s: | 3.0.1 |
| Fix Version/s: | None |
| Type: | Task | Priority: | Major - P3 |
| Reporter: | Johnny Vana [X] | Assignee: | Unassigned |
| Resolution: | Incomplete | Votes: | 0 |
| Labels: | c++ | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
cmake-gui & VS2015 |
||
| Description |
|
I follow this tutorial https://github.com/mongodb/mongo-cxx-driver/wiki/Quickstart-Guide-(New-Driver). I build and install bson and mongoc library. When I build the hellomongo.cpp, I have this issue : Thanks for helps ! |
| Comments |
| Comment by Andrew Morrow (Inactive) [ 05/Oct/16 ] | |||||||||||
|
Johnny - That looks like a problem with libmongo-c, not mongocxx. Could we move this discussion to mongodb-user? I really don't think there is a problem with the driver build system - we are running automated regression tests of the build on windows, so we know it works, and many other users have built the driver on windows. There doesn't seem to be a specific issue to be addressed in this ticket - more overall difficulty using CMake on Windows. Is it OK with you if I close this ticket and we move to mongodb-user? | |||||||||||
| Comment by Johnny Vana [X] [ 03/Oct/16 ] | |||||||||||
|
I up to libmongoc 1.4.2. | |||||||||||
| Comment by Johnny Vana [X] [ 26/Sep/16 ] | |||||||||||
|
Yes, I build the install target in both Realease and Debug. | |||||||||||
| Comment by Andrew Morrow (Inactive) [ 25/Sep/16 ] | |||||||||||
|
Johnny - Did you build the INSTALL target? See https://github.com/mongodb/mongo-cxx-driver/blob/master/appveyor.yml#L33. You need to do this so that the header files are properly installed somewhere. Note that you cannot simply rename config.hpp.in to config.hpp: the config.hpp.in file is a template file that CMake interpolates values into to produce a custom config.hpp header file. Once you have installed the driver somewhere (configure this with -DCMAKE_INSTALL_PREFIX argument to CMake), you should have a properly made config,hpp file. | |||||||||||
| Comment by Johnny Vana [X] [ 25/Sep/16 ] | |||||||||||
|
I up to 3.0.2 I try and I think the compiler find the libson and libmongoc libraries. | |||||||||||
| Comment by Andrew Morrow (Inactive) [ 24/Sep/16 ] | |||||||||||
|
Hi Johnny - I'm closing this ticket as I think the errors you are getting are expected, and I've provided a workaround. If you need further help with this issue, please let us know and we can re-open the ticket. | |||||||||||
| Comment by Andrew Morrow (Inactive) [ 21/Sep/16 ] | |||||||||||
|
Johnny - I think I know what is going on. You are linking against the static library version of libbsoncxx (I know this because the static version is installed as lib/libmongocxx.lib, whereas the .lib for the DLL is installed as lib/mongocxx.lib. When you link an application statically to the bsoncxx or mongocxx libraries, you must also link it to libbson and libmongoc, respectively. This is simply how static linking works - the libbsoncxx.lib and libmongocxx.lib static libraries only contain the symbols from the .cpp files that were compiled into it. The definitions for the libbson and libmongoc layer must be separately provided when linking your application. In general, the C++11 driver tries hard to make the use of libmongoc and libbson opaque, but it cannot do this at link time. My recommendations are to either:
Could you please try one of the above and let me know if it resolves the issues for you? | |||||||||||
| Comment by Johnny Vana [X] [ 20/Sep/16 ] | |||||||||||
|
the first 10 errors are : error LNK2019: symbole externe non résolu _bson_iter_init référencé dans la fonction "public: void __thiscall bsoncxx::v_noabi::builder::core::concatenate(class bsoncxx::v_noabi::document::view const &)" (?concatenate@core@builder@v_noabi@bsoncxx@@QAEXABVview@document@34@@Z) | |||||||||||
| Comment by Andrew Morrow (Inactive) [ 16/Sep/16 ] | |||||||||||
|
Johnny - Could you please paste the first 10 or so errors from your new clean build? | |||||||||||
| Comment by Johnny Vana [X] [ 15/Sep/16 ] | |||||||||||
|
the both compile. I update VS2015 (update3.1), delete all driver files and restart compilation. | |||||||||||
| Comment by Andrew Morrow (Inactive) [ 15/Sep/16 ] | |||||||||||
|
Johnny - Which one is working, the one with the mongocxx/client.hpp include, or the one without? Could you try both? | |||||||||||
| Comment by Johnny Vana [X] [ 15/Sep/16 ] | |||||||||||
|
If I compile your hello word code, it is working | |||||||||||
| Comment by Andrew Morrow (Inactive) [ 15/Sep/16 ] | |||||||||||
|
Johnny - I believe that most recent error you posted has been fixed on the HEAD of the master branch, which is about to be released as 3.0.2. Could you please re-try with that. I still don't understand why you are getting messages that std::cout is not defined. What happens if you just reduce your example to just:
What happens if you then extend it to:
| |||||||||||
| Comment by Johnny Vana [X] [ 12/Sep/16 ] | |||||||||||
|
The first 3 errors are : | |||||||||||
| Comment by Andrew Morrow (Inactive) [ 10/Sep/16 ] | |||||||||||
|
Johnny - Are these the first errors emitted in the build? Are there any earlier errors? In particular, errors about not being able to find headers to satisfy the #include statements? Also, please note that "error C2039: 'cout' : n'est pas membre de 'std'" is very strange - it suggests that the compiler doesn't even see cout as a member of the std namespace. | |||||||||||
| Comment by Johnny Vana [X] [ 07/Sep/16 ] | |||||||||||
|
I have configured, built and installed the driver with cmake-gui and VS2015, not by batch. The helloworld.cpp file : #include <bsoncxx/builder/stream/document.hpp> #include <mongocxx/client.hpp> int main(int, char**) { bsoncxx::builder::stream::document document{}; auto collection = conn["testdb"]["testcollection"]; collection.insert_one(document.view()); for (auto&& doc : cursor) { std::cout << bsoncxx::to_json(doc) << std::endl; }} I have 51 issue :s Sorry for the French language | |||||||||||
| Comment by David Golden [ 07/Sep/16 ] | |||||||||||
|
Hello. Thanks for posting your issue. Could you please include the lines you used to configure, build and install the mongocxx driver? Also, could you please post the full helloworld.cpp file, the command line you used to compile it, and the full compiler output? Thank you! |