[CDRIVER-2070] Can not build static library on macOS Created: 24/Feb/17  Updated: 27/Oct/23  Resolved: 27/Feb/17

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

Type: Bug Priority: Major - P3
Reporter: Hongcai Deng Assignee: A. Jesse Jiryu Davis
Resolution: Works as Designed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

OS: macOS 10.12.3



 Description   

When build for static library

GCC: Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1 --enable-static=yes
Apple LLVM version 8.0.0 (clang-800.0.42.1)
Target: x86_64-apple-darwin16.4.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

it says

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: .libs/libbson.a(libbson_la-bson-atomic.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: .libs/libbson.a(libbson_la-bson-atomic.o) has no symbols
  CCLD     libbson-1.0.la
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: .libs/libbson-1.0.a(libbson_la-bson-atomic.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: .libs/libbson-1.0.a(libbson_la-bson-atomic.o) has no symbols

and no .a file is generated.



 Comments   
Comment by A. Jesse Jiryu Davis [ 27/Feb/17 ]

Conclusion: I had been confused, as you were, that the ".a" file isn't built on Mac OS X until "make install". I saw the AC_DISABLE_STATIC macro in SetupLibtool.m4 and I thought it was to blame. It turns out that the macro correctly disables the static build by default, but if you pass --enable-static then the build system correctly generates a static archive.

Comment by A. Jesse Jiryu Davis [ 27/Feb/17 ]

Great, thanks for letting us know.

Comment by Hongcai Deng [ 27/Feb/17 ]

sorry, I forgot that .a file is generated by libtool...I missed the `make install` step, and now everything is fine. Thanks for your support.

Comment by A. Jesse Jiryu Davis [ 24/Feb/17 ]

Actually I can't reproduce this, when I compile:

> ./configure --enable-static=yes --prefix=/tmp/bson && make -j8 && make install
... lots of output ...
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
... lots of output ...
> ls /tmp/bson/lib
libbson-1.0.0.dylib libbson-1.0.a       libbson-1.0.dylib   libbson-1.0.la      pkgconfig

The static archive libbson-1.0.a is installed.

  • Can you paste the ./configure and make output here please?
  • Can you paste the output of "brew list --versions automake autoconf libtool pkgconfig" here please?
Comment by A. Jesse Jiryu Davis [ 24/Feb/17 ]

The warnings are nothing to worry about - if "bson-atomic.o" has no symbols, that's because libbson is using your compiler's builtin support for atomic operations, so none of libbson's custom atomic operations are compiled.

However, there does seem to be a bug in build/autotools/SetupLibtool.m4, it shouldn't have AC_DISABLE_STATIC.

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