[CDRIVER-891] Fix MinGW build Created: 30/Sep/15  Updated: 13/Jan/17  Resolved: 18/Jan/16

Status: Closed
Project: C Driver
Component/s: libbson, mingw
Affects Version/s: 1.1.2
Fix Version/s: 1.3.1

Type: Bug Priority: Major - P3
Reporter: Demelier David Assignee: A. Jesse Jiryu Davis
Resolution: Cannot Reproduce Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Windows, using MinGW-w64


Issue Links:
Related
is related to CDRIVER-959 mingw build & test in Evergreen Closed

 Description   

The build system for libbson and libmongoc must keep straight the distinction between "compiling on Windows" and "compiling with Microsoft Visual C". There are many ifdefs that check for BSON_OS_WIN32 and then include MSVC-specific code. This breaks under MinGW since BSON_OS_WIN32 is true in MinGW but mostly, compiling with MinGW is the same as compiling on Unix.

Most ifdefs that currently check for BSON_OS_WIN32 should instead check for _MSC_VER to

------

Original report:

bson-stdint.h not found when using MinGW:

The bson.h requires including bson-stdint.h which is renamed to bson-stdint-win32.h on Windows.

This is because the _MSC_VER is not defined (and is only defined with MSVC).

I propose to change the following code :

#ifdef _MSC_VER
# include "bson-stdint-win32.h"
// ... as before

to something like this :

#if defined(_WIN32)
#  include "bson-stdint.h-win32.h"
#endif
 
#if defined(_MSC_VER)
// ... as before specific for MSVC
#endif



 Comments   
Comment by A. Jesse Jiryu Davis [ 18/Jan/16 ]

I'm going to close this for the moment, but please reopen and add more info when we get a chance so that we can figure out why the build broke on your system. Thanks.

Comment by A. Jesse Jiryu Davis [ 13/Jan/16 ]

markand I thought I could reproduce this, but in fact it seems that the current release tarball works with MinGW-W64:

https://github.com/mongodb/libbson/releases/download/1.3.0/libbson-1.3.0.tar.gz

Can you tell me more about:

  • How did you install MinGW?
  • What does "gcc --version" report?
  • What is the exact command line and error you see?

Thanks!

Comment by A. Jesse Jiryu Davis [ 08/Jan/16 ]

I have a fix for a variety of MinGW problems in code review now. libbson will build and work with MinGW 4.9.1. Still to be determined:

  • is -lws2_32 really required for gethostbyname in MinGW? If so, why do I have to copy ws2_32.dll to libws2_32.dll to make MinGW find and link to it?
  • In this commit, adam.midvidy claimed to fix "older mingw". Is that fix still needed?
  • What range of MinGW versions do we support?
Comment by Demelier David [ 30/Sep/15 ]

Update : after looking at bson-stdint-win32.h it seems absolutely not compatible with MinGW, maybe the build system can just copy the same bson-stdint.h as unix systems?

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