[CXX-119] dll attributes should not be applied to the static library build Created: 04/Mar/14  Updated: 09/Apr/14  Resolved: 05/Mar/14

Status: Closed
Project: C++ Driver
Component/s: None
Affects Version/s: None
Fix Version/s: legacy-0.0-26compat-2.6.0-rc0

Type: Bug Priority: Major - P3
Reporter: Andrew Morrow (Inactive) Assignee: Andrew Morrow (Inactive)
Resolution: Done Votes: 0
Labels: legacy-cxx
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

A mongo client header file, when included by a consumer, cannot know whether the link step will target a static or shared version of libmongoclient. As a result, it cannot independently determine whether to apply __declspec(dllimport) or not. An incorrect application results in a huge number of warnings.

Since we don't expect the static library to work well in the first place, the best solution is to create a new #define macro that if present inhibits the application of any import or export macros. Clients intending to use the static library must define this symbol.

When we observe the symbol in dbclient.h or bson.h, we inhibit MONGOCLIENT_CONSUMER.



 Comments   
Comment by Andrew Morrow (Inactive) [ 04/Mar/14 ]

https://github.com/mongodb/mongo-cxx-driver/pull/10/files

Comment by Andrew Morrow (Inactive) [ 04/Mar/14 ]

Basically, the block I want to add to dbclient.h and bson.h looks like this:

// Consumers of the MongoDB C++ client library must define STATIC_LIBMONGOCLIENT when including
// this header if they intend to link against the static version of the library on windows.
#ifndef STATIC_LIBMONGOCLIENT
#define LIBMONGOCLIENT_CONSUMER
#endif
#if defined(STATIC_LIBMONGOCLIENT) && defined(LIBMONGOCLIENT_CONSUMER)
#error "Must not define both STATIC_LIBMONGOCLIENT and LIBMONGOCLIENT_CONSUMER"
#endif

Generated at Wed Feb 07 21:58:15 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.