Linker error building mongo-c-driver in Xcode

173 views
Skip to first unread message

Paul Melnikow

unread,
Mar 6, 2015, 4:08:43 AM3/6/15
to mongod...@googlegroups.com
Hi there, I'm trying to build mongo-c-driver for CocoaPods, which is the premier package manager for iOS and Mac OS. I'm following these steps which Jason Carey sent me:

If you're looking for a rundown of what you need to do to build the c driver sources as part of another project, it's basically:
  • Run autotools
    • You can either do this yourself by invoking ./autogen.sh on a system with autoconf, automake, libtool and autoreconf or...
    • You can download a release tarball from the mongo-c-driver releases page.  That get's you to ./configure and only relies on a compiler and make.
  • Run ./configure
    • ./autogen.sh runs this for you, so only needed if you downloaded a release tarball
  • Copy the headers and sources out of src/mongoc, src/libbson/src/bson and src/libbson/src/yajl
    • This is all of the *.c, *.h, *.def, *.defs files
  • Compile with "-DBSON_COMPILATION -DMONGOC_COMPILATION"
 
I’ve gotten to link time, and now have an issue I can’t resolve. Any idea what might be going wrong? I’ve got the .def and .defs files available and I’m compiling mongoc-counters.c. If I run nm on the .o or static library .a files, the symbols seem to be there.

Can you let me know what I might be doing wrong? Thanks!

Note that I'm configuring mongo with bson in "embedded" mode, then exclude the bson sources, and pull them in from the libbson pod instead. I don't think that is related to this linker error, though.

Version: 1.1.0
Host OS: iOS 8.1
Compiler: Xcode 6.1.1


Configuration:

   libbson was configured with the following options:

   Build configuration:
     Enable debugging (slow)                          : no
     Compile with debug symbols (slow)                : no
     Enable GCC build optimization                    : yes
     Enable automatic binary hardening                : yes
     Code coverage support                            : no
     Cross Compiling                                  : no
     Big endian                                       : no
     Link Time Optimization (experimental)            : no

   Documentation:
     man                                              : no
     HTML                                             : no

    *** IMPORTANT ***

    This is an unstable version of libmongoc.
    It is for test purposes only.

    Please, DO NOT use it in a production environment.
    It will probably crash and you will lose your data.

    Additionally, the API/ABI may change during the course
    of development.

    Thanks,

      The libmongoc team.

    *** END OF WARNING ***


   libmongoc was configured with the following options:

   Build configuration:
     Enable debugging (slow)                          : no
     Compile with debug symbols (slow)                : no
     Enable GCC build optimization                    : yes
     Enable automatic binary hardening                : yes
     Code coverage support                            : no
     Cross Compiling                                  : no
     Fast counters                                    : no
     SASL                                             : sasl2
     SSL                                              : yes
     Libbson                                          : bundled

   Documentation:
     man                                              : no
     HTML                                             : no

This is the podspec, which essentially specifies the build instructions:



Here's the error:

Undefined symbols for architecture x86_64:
  "___mongoc_counter_auth_failure", referenced from:
      _mongoc_counter_auth_failure_add in libPods-ObjCMongoDB-mongo-c-driver.a(mongoc-cluster.o)
  "___mongoc_counter_auth_success", referenced from:
      _mongoc_counter_auth_success_add in libPods-ObjCMongoDB-mongo-c-driver.a(mongoc-cluster.o)
  "___mongoc_counter_clients_active", referenced from:
      _mongoc_counter_clients_active_add in libPods-ObjCMongoDB-mongo-c-driver.a(mongoc-client.o)
  "___mongoc_counter_clients_disposed", referenced from:
      _mongoc_counter_clients_disposed_add in libPods-ObjCMongoDB-mongo-c-driver.a(mongoc-client.o)
  "___mongoc_counter_cursors_active", referenced from:
      _mongoc_counter_cursors_active_add in libPods-ObjCMongoDB-mongo-c-driver.a(mongoc-cursor.o)
  "___mongoc_counter_cursors_disposed", referenced from:
      _mongoc_counter_cursors_disposed_add in libPods-ObjCMongoDB-mongo-c-driver.a(mongoc-cursor.o)
  "___mongoc_counter_dns_failure", referenced from:
      _mongoc_counter_dns_failure_add in libPods-ObjCMongoDB-mongo-c-driver.a(mongoc-client.o)
  "___mongoc_counter_dns_success", referenced from:
      _mongoc_counter_dns_success_add in libPods-ObjCMongoDB-mongo-c-driver.a(mongoc-client.o)
  "___mongoc_counter_op_egress_delete", referenced from:
      _mongoc_counter_op_egress_delete_add in libPods-ObjCMongoDB-mongo-c-driver.a(mongoc-cluster.o)
  "___mongoc_counter_op_egress_getmore", referenced from:
      _mongoc_counter_op_egress_getmore_add in libPods-ObjCMongoDB-mongo-c-driver.a(mongoc-cluster.o)
  "___mongoc_counter_op_egress_insert", referenced from:
      _mongoc_counter_op_egress_insert_add in libPods-ObjCMongoDB-mongo-c-driver.a(mongoc-cluster.o)
  "___mongoc_counter_op_egress_killcursors", referenced from:
      _mongoc_counter_op_egress_killcursors_add in libPods-ObjCMongoDB-mongo-c-driver.a(mongoc-cluster.o)
  "___mongoc_counter_op_egress_msg", referenced from:
      _mongoc_counter_op_egress_msg_add in libPods-ObjCMongoDB-mongo-c-driver.a(mongoc-cluster.o)
  "___mongoc_counter_op_egress_query", referenced from:
      _mongoc_counter_op_egress_query_add in libPods-ObjCMongoDB-mongo-c-driver.a(mongoc-cluster.o)
  "___mongoc_counter_op_egress_reply", referenced from:
      _mongoc_counter_op_egress_reply_add in libPods-ObjCMongoDB-mongo-c-driver.a(mongoc-cluster.o)
  "___mongoc_counter_op_egress_total", referenced from:
      _mongoc_counter_op_egress_total_add in libPods-ObjCMongoDB-mongo-c-driver.a(mongoc-cluster.o)
  "___mongoc_counter_op_egress_update", referenced from:
      _mongoc_counter_op_egress_update_add in libPods-ObjCMongoDB-mongo-c-driver.a(mongoc-cluster.o)
  "___mongoc_counter_op_ingress_delete", referenced from:
      _mongoc_counter_op_ingress_delete_add in libPods-ObjCMongoDB-mongo-c-driver.a(mongoc-cluster.o)
  "___mongoc_counter_op_ingress_getmore", referenced from:
      _mongoc_counter_op_ingress_getmore_add in libPods-ObjCMongoDB-mongo-c-driver.a(mongoc-cluster.o)
  "___mongoc_counter_op_ingress_insert", referenced from:
      _mongoc_counter_op_ingress_insert_add in libPods-ObjCMongoDB-mongo-c-driver.a(mongoc-cluster.o)
  "___mongoc_counter_op_ingress_killcursors", referenced from:
      _mongoc_counter_op_ingress_killcursors_add in libPods-ObjCMongoDB-mongo-c-driver.a(mongoc-cluster.o)
  "___mongoc_counter_op_ingress_msg", referenced from:
      _mongoc_counter_op_ingress_msg_add in libPods-ObjCMongoDB-mongo-c-driver.a(mongoc-cluster.o)
  "___mongoc_counter_op_ingress_query", referenced from:
      _mongoc_counter_op_ingress_query_add in libPods-ObjCMongoDB-mongo-c-driver.a(mongoc-cluster.o)
  "___mongoc_counter_op_ingress_reply", referenced from:
      _mongoc_counter_op_ingress_reply_add in libPods-ObjCMongoDB-mongo-c-driver.a(mongoc-cluster.o)
  "___mongoc_counter_op_ingress_total", referenced from:
      _mongoc_counter_op_ingress_total_add in libPods-ObjCMongoDB-mongo-c-driver.a(mongoc-cluster.o)
  "___mongoc_counter_op_ingress_update", referenced from:
      _mongoc_counter_op_ingress_update_add in libPods-ObjCMongoDB-mongo-c-driver.a(mongoc-cluster.o)
  "___mongoc_counter_protocol_ingress_error", referenced from:
      _mongoc_counter_protocol_ingress_error_add in libPods-ObjCMongoDB-mongo-c-driver.a(mongoc-cluster.o)
  "___mongoc_counter_streams_active", referenced from:
      _mongoc_counter_streams_active_add in libPods-ObjCMongoDB-mongo-c-driver.a(mongoc-stream-buffered.o)
  "___mongoc_counter_streams_disposed", referenced from:
      _mongoc_counter_streams_disposed_add in libPods-ObjCMongoDB-mongo-c-driver.a(mongoc-stream-buffered.o)
  "___mongoc_counter_streams_egress", referenced from:
      _mongoc_counter_streams_egress_add in libPods-ObjCMongoDB-mongo-c-driver.a(mongoc-socket.o)
  "___mongoc_counter_streams_ingress", referenced from:
      _mongoc_counter_streams_ingress_add in libPods-ObjCMongoDB-mongo-c-driver.a(mongoc-socket.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

And finally, the full transcript:

Paul Melnikow

unread,
Mar 31, 2015, 1:56:42 PM3/31/15
to mongod...@googlegroups.com
Still looking to resolve this issue. Any thoughts?

Paul Melnikow

unread,
Apr 7, 2015, 1:55:05 AM4/7/15
to mongod...@googlegroups.com
Posting the solution here in case it's useful to anyone else: adding the required call to mongoc_init() fixes the error.

Reply all
Reply to author
Forward
0 new messages