[CDRIVER-4743] Fix Windows tasks linking to libmongocrypt Created: 16/Oct/23  Updated: 31/Oct/23  Resolved: 31/Oct/23

Status: Closed
Project: C Driver
Component/s: None
Affects Version/s: None
Fix Version/s: 1.25.0

Type: Task Priority: Unknown
Reporter: Kevin Albertson Assignee: Kevin Albertson
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Problem/Incident
is caused by CDRIVER-4705 Better control over static/dynamic co... Closed

 Description   

Windows tasks linking to libmongocrypt fail with this error:

bson-static-1.0.lib(bson-error.obj) : error LNK2005: bson_set_error already defined in mongocrypt.lib(mongocrypt.dll) [C:\data\mci\a7f5819a07b0a787fb58c6c761152444\mongoc\src\libmongoc\test-libmongoc.vcxproj]

Here is an example task: cse-sasl-cyrus-winssl-windows-2019-vs2017-x64-compile

Task history shows failure started on this commit: https://github.com/mongodb/mongo-c-driver/commit/4592ca54f76019905b32995c8bcf032c54d34be7

Commit has not yet been released. Resolve before releasing 1.25.0 in case this is a regression.



 Comments   
Comment by Githook User [ 31/Oct/23 ]

Author:

{'name': 'Kevin Albertson', 'email': 'kevin.albertson@mongodb.com', 'username': 'kevinAlbs'}

Message: CDRIVER-4743 Define `BSON_STATIC` for `bson_static` build (#1453)

  • remove `bson_obj`

Separate sources built by `bson_shared` and `bson_static`. This is intended to build `bson_static` sources with no `dllexport` and `bson_shared` with `dllexport`.

  • define `BSON_STATIC` when building

To suppress `dllexport`. When `dllexport` is defined, it appears to export the symbols in a consumer.

  • revise comments

BSON_STATIC and MONGOC_STATIC are defined for static builds.
Exporting functions in static build has an effect.
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/25f6bdf938050bf3506c75b7fc8eb7f20b3b3d52

Comment by Kevin Albertson [ 16/Oct/23 ]

Issue may be caused by libbson symbols being exported in libmongocrypt. libmongocrypt is installed referencing the local mongo-c-driver directory.

Before 4592ca, running `dumpbin /EXPORTS mongocrypt.lib` does not show libbson symbols.

After 4592ca, running `dumpbin /EXPORTS mongocrypt.lib` shows libbson symbols:

> dumpbin /EXPORTS mongocrypt.lib
Microsoft (R) COFF/PE Dumper Version 14.16.27043.0
Copyright (C) Microsoft Corporation.  All rights reserved.
 
 
Dump of file mongocrypt.lib
 
File Type: LIBRARY
 
     Exports
 
       ordinal    name
 
                  bcon_append
                  bcon_append_ctx
                  bcon_append_ctx_init
                  (... more libbson API ...)

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