0

I may be just missing something, but I'm trying to include a MongoDB C++ driver library build into my DLL project. I'm trying to follow this guide

I've tried including the folder in Configuration Properties->Linker->General->Additional Library Directories, and the .lib file in Linker->Input->Additional Dependencies. I've also added the /MT command-line option.

Now here comes my problem - how do I use the files? Do I just use #include "mongo/client/dbclient.h", because this doesn't seem to work (Cannot open source file). I can't find much of any helpful documentation on this subject.

Any ideas?

Deniz Zoeteman
  • 9,691
  • 26
  • 70
  • 97
  • 1
    Your second paragraph suggests you're trying to address a *link-time* issue, while your third paragraph suggests you're trying to address a *compile-time* issue. Please post the *exact* error message you're receiving. The build tool you're using (not just the menu options you're choosing) would be equally educational. – WhozCraig Aug 19 '13 at 23:13
  • The second paragraph isn't an issue - it works, I can include it - I don't have any confirmation of it actually building with my DLL yet though; it seems the same, but no error messages. My main issue is that I don't know how to, when I've included the static library in the project, how to use it. Just not including anything extra and using something like `mongo::DBClientConnection` gives an error (`IntelliSense: name followed by '::' must be a class or namespace name`) – Deniz Zoeteman Aug 19 '13 at 23:16
  • A shame the previous poster deleted his comment, because it sounds spot-on. You have to add the folder that houses the base `mongo` include path to your project include path; not the lib path. And at least the word IntelliSense tells us you're probably using Visual Studio. So [see the answers to this question](http://stackoverflow.com/questions/2676417/how-do-include-paths-work-in-visual-studio) noting I believe the *second* answer is the one that likely applies to you (if you're using VS2010 or later). – WhozCraig Aug 19 '13 at 23:21
  • I'm not using source files though - I'm just using a compiled version, with a mongoclient.lib and obj files for each folder the source had (i.e dbclient.obj - one I need). How does it work in that case? Or do I need the source? – Deniz Zoeteman Aug 19 '13 at 23:32
  • Also, you were spot on; I'm using Visual Studio 2012 Ultimate (64bit). – Deniz Zoeteman Aug 19 '13 at 23:33
  • You're using the *header files* and their now-built static library. Its how your program knows about the MongoDB toolkit. You include their header declarations, write your code using those, and link to their library (which provides the meat behind those declarations, statically linked to your DLL). – WhozCraig Aug 19 '13 at 23:38
  • So if I understand you right, I should still have the source files included? – Deniz Zoeteman Aug 20 '13 at 16:56
  • Again, after the toolkit is *built* you need only the headers (the roadmap for what is provided by the library), and the static libs. the source files (.c/cpp) used to build the library are not needed anymore. – WhozCraig Aug 20 '13 at 17:00
  • I see. I'll try that out! – Deniz Zoeteman Aug 20 '13 at 17:24
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/35856/discussion-between-gdscei-and-whozcraig) – Deniz Zoeteman Aug 20 '13 at 17:52

0 Answers0