Uploaded image for project: 'C Driver'
  1. C Driver
  2. CDRIVER-1970

Conflicting symbols "MAX" and "MIN" on FreeBSD

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 1.5.2
    • Affects Version/s: 1.5.1
    • Component/s: libmongoc
    • None
    • Environment:

      I used pecl to install 1.1.9 mongodb driver without issue.

      I'm trying to upgrade to 1.2.2, but libmongoc is causing me issues.

      This commit changed hardcoded defaults in mongoc-cursor.c to mongoc-cursor-private.h

      https://github.com/mongodb/mongo-c-driver/commit/b14c511dbb756ecb19f2decb59f59fbe7541d863

      This should work just fine, since that file is #include'd in mongoc-cursor.c, but for some reason when I try to build it, it fails with these errors:

      /tmp/pear/mongodb/src/libmongoc/src/mongoc/mongoc-cursor.c:1016:32: error: use of undeclared identifier 'MAX'
            } else if (!strcmp (key, MAX)) {
                                     ^
      /tmp/pear/mongodb/src/libmongoc/src/mongoc/mongoc-cursor.c:1027:32: error: use of undeclared identifier 'MIN'
            } else if (!strcmp (key, MIN)) {
                                     ^
      /tmp/pear/mongodb/src/libmongoc/src/mongoc/mongoc-cursor.c:1354:24: error: use of undeclared identifier 'MAX'
         } else if (!strcmp (MAX, query_field)) {
                             ^
      /tmp/pear/mongodb/src/libmongoc/src/mongoc/mongoc-cursor.c:1355:20: error: use of undeclared identifier 'MAX'
            *cmd_field = MAX;
                         ^
      /tmp/pear/mongodb/src/libmongoc/src/mongoc/mongoc-cursor.c:1357:24: error: use of undeclared identifier 'MIN'
         } else if (!strcmp (MIN, query_field)) {
                             ^
      /tmp/pear/mongodb/src/libmongoc/src/mongoc/mongoc-cursor.c:1358:20: error: use of undeclared identifier 'MIN'
            *cmd_field = MIN;
                         ^
      6 errors generated.
      *** Error code 1
      

      I'm not sure if I'm using the wrong make (I tried gmake 4.2.1 but no change) or the wrong cc (I tried gcc 4.8.5 but no change), or if there is some other issue going on.

      Here's the output of the build – ignore the extra -L CFLAGS definition, was just trying shotgun ideas, to no avail. I've attached as a text file.

      downloading mongodb-1.2.2.tar ...
      Starting to download mongodb-1.2.2.tar (4,976,128 bytes)
      ...........................................done: 4,976,128 bytes
      400 source files, building
      running: phpize
      Configuring for:
      PHP Api Version:         20131106
      Zend Module Api No:      20131226
      Zend Extension Api No:   220131226
      building in /tmp/pear/pear-build-rootsplUam/mongodb-1.2.2
      running: /tmp/pear/mongodb/configure
      checking for grep that handles long lines and -e... /usr/bin/grep
      checking for egrep... /usr/bin/grep -E
      checking for a sed that does not truncate output... /usr/bin/sed
      checking for cc... cc
      checking whether the C compiler works... yes
      checking for C compiler default output file name... a.out
      checking for suffix of executables...
      checking whether we are cross compiling... no
      checking for suffix of object files... o
      checking whether we are using the GNU C compiler... yes
      checking whether cc accepts -g... yes
      checking for cc option to accept ISO C89... none needed
      checking how to run the C preprocessor... cc -E
      checking for icc... no
      checking for suncc... no
      checking whether cc understands -c and -o together... yes
      checking for system library directory... lib
      checking if compiler supports -R... no
      checking if compiler supports -Wl,-rpath,... yes
      checking build system type... amd64-unknown-freebsd10.2
      checking host system type... amd64-unknown-freebsd10.2
      checking target system type... amd64-unknown-freebsd10.2
      checking for PHP prefix... /usr/local
      checking for PHP includes... -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib
      checking for PHP extension directory... /usr/local/lib/php/20131226
      checking for PHP installed headers prefix... /usr/local/include/php
      checking if debug is enabled... no
      checking if zts is enabled... no
      checking for re2c... no
      configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.
      checking for gawk... no
      checking for nawk... nawk
      checking if nawk is broken... no
      checking whether to enable mongodb support... yes, shared
      checking OpenSSL dir for mongodb... yes
      checking whether to use system default cipher list instead of hardcoded value... no
      checking PHP version... 50627
      checking whether to enable developer build flags... no
      checking whether to enable code coverage... no
      checking whether to use system libbson... no
      checking configuring libmongoc... ...
      checking whether to use system libmongoc... no
      checking for pkg-config... /usr/local/bin/pkg-config
      checking for pcre-dir install prefix... yes, shared
      checking for pcre... found in /usr/local
      checking for Cyrus SASL support... auto
      checking for SASL... found in /usr/local
      checking for sasl_version in -lsasl2... yes
      checking for sasl_client_done in -lsasl2... yes
      checking if weak symbols are supported... yes
      checking if compiler needs -Werror to reject unknown flags... no
      checking for the pthreads library -lpthreads... no
      checking whether pthreads work without any flags... no
      checking whether pthreads work with -Kthread... no
      checking whether pthreads work with -kthread... no
      checking for the pthreads library -llthread... no
      checking whether pthreads work with -pthread... yes
      checking for joinable pthread attribute... PTHREAD_CREATE_JOINABLE
      checking if more special flags are required for pthreads... -D_THREAD_SAFE
      checking for PTHREAD_PRIO_INHERIT... yes
      checking for shm_open... yes
      checking for __sync_add_and_fetch_4... yes
      checking for __sync_add_and_fetch_8... yes
      checking for strnlen... yes
      checking for reallocf... yes
      checking for syscall... yes
      checking for SYS_gettid... no
      checking for snprintf... yes
      checking for _set_output_format... no
      checking for struct timespec... yes
      checking for library containing clock_gettime... none required
      checking for pthread_join in LIBS= with CFLAGS=-D_THREAD_SAFE -pthread... yes
      checking if compiler needs -Werror to reject unknown flags... no
      checking for joinable pthread attribute... PTHREAD_CREATE_JOINABLE
      checking if more special flags are required for pthreads... -D_THREAD_SAFE
      checking for PTHREAD_PRIO_INHERIT... (cached) yes
      checking whether PTHREAD_ONCE_INIT needs braces... no
      checking for stdint-types....... "(putting them into /tmp/pear/mongodb/src/libbson/src/bson/bson-stdint.h)"
      checking for uintptr_t... yes
      checking for uint64_t... yes
      ... seen our uintptr_t in stdint.h (uint64_t too)
      creating /tmp/pear/mongodb/src/libbson/src/bson/bson-stdint.h : __TMP_PEAR_MONGODB_SRC_LIBBSON_SRC_BSON_BSON_STDINT_H
      checking for int_least32_t... yes
      checking for int_fast32_t... yes
      ..adding include stdint.h
      ... seen good stdint.h inttypes
      ... seen good uint64_t
      ... DONE /tmp/pear/mongodb/src/libbson/src/bson/bson-stdint.h
      checking whether byte ordering is bigendian... no
      checking for ANSI C header files... yes
      checking for sys/types.h... yes
      checking for sys/stat.h... yes
      checking for stdlib.h... yes
      checking for string.h... yes
      checking for memory.h... yes
      checking for strings.h... yes
      checking for inttypes.h... yes
      checking for stdint.h... yes
      checking for unistd.h... yes
      checking for stdbool.h that conforms to C99... yes
      checking for _Bool... yes
      checking for clock_gettime... yes
      checking for strnlen... yes
      checking for snprintf... (cached) yes
      configure: Current version (from VERSION_CURRENT file): 1.5.0
      configure: creating ./config.status
      config.status: creating /tmp/pear/mongodb/src/libmongoc/src/mongoc/mongoc-config.h
      configure: creating ./config.status
      config.status: creating /tmp/pear/mongodb/src/libmongoc/src/mongoc/mongoc-config.h
      config.status: creating /tmp/pear/mongodb/src/libmongoc/src/mongoc/mongoc-version.h
      configure: Current version (from VERSION_CURRENT file): 1.5.0
      configure: creating ./config.status
      config.status: creating /tmp/pear/mongodb/src/libmongoc/src/mongoc/mongoc-config.h
      config.status: creating /tmp/pear/mongodb/src/libmongoc/src/mongoc/mongoc-version.h
      config.status: creating /tmp/pear/mongodb/src/libbson/src/bson/bson-config.h
      configure: creating ./config.status
      config.status: creating /tmp/pear/mongodb/src/libmongoc/src/mongoc/mongoc-config.h
      config.status: creating /tmp/pear/mongodb/src/libmongoc/src/mongoc/mongoc-version.h
      config.status: creating /tmp/pear/mongodb/src/libbson/src/bson/bson-config.h
      config.status: creating /tmp/pear/mongodb/src/libbson/src/bson/bson-version.h
      checking for ld used by cc... /usr/bin/ld
      checking if the linker (/usr/bin/ld) is GNU ld... yes
      checking for /usr/bin/ld option to reload object files... -r
      checking for BSD-compatible nm... /usr/local/bin/nm -B
      checking whether ln -s works... yes
      checking how to recognize dependent libraries... pass_all
      checking dlfcn.h usability... yes
      checking dlfcn.h presence... yes
      checking for dlfcn.h... yes
      checking the maximum length of command line arguments... 196608
      checking command to parse /usr/local/bin/nm -B output from cc object... ok
      checking for objdir... .libs
      checking for ar... ar
      checking for ranlib... ranlib
      checking for strip... strip
      checking if cc supports -fno-rtti -fno-exceptions... yes
      checking for cc option to produce PIC... -fPIC
      checking if cc PIC flag -fPIC works... yes
      checking if cc static flag -static works... yes
      checking if cc supports -c -o file.o... yes
      checking whether the cc linker (/usr/bin/ld) supports shared libraries... yes
      checking whether -lc should be explicitly linked in... no
      checking dynamic linker characteristics... freebsd10.2 ld.so
      checking how to hardcode library paths into programs... immediate
      checking whether stripping libraries is possible... yes
      checking if libtool supports shared libraries... yes
      checking whether to build shared libraries... yes
      checking whether to build static libraries... no
      
      creating libtool
      appending configuration tag "CXX" to libtool
      configure: creating ./config.status
      
      mongodb was configured with the following options:
      
      Build configuration:
        CFLAGS                                           : -L/usr/local/lib -I/usr/local/include -L/usr/lib -I /usr/include
        Extra CFLAGS                                     :  -D_THREAD_SAFE -pthread
        Developers flags (slow)                          :
        Code Coverage flags (extra slow)                 :
        System mongoc                                    : no
        System libbson                                   : no
        LDFLAGS                                          :
        EXTRA_LDFLAGS                                    :
        MONGODB_SHARED_LIBADD                            : -Wl,-rpath,/usr/local/lib -L/usr/local/lib -lsasl2 -Wl,-rpath,/usr/local/lib -L/usr/local/lib  -lssl -lcrypto
      
      Please submit bugreports at:
        https://jira.mongodb.org/browse/PHPC
      
      
      config.status: creating /tmp/pear/mongodb/src/libmongoc/src/mongoc/mongoc-config.h
      config.status: creating /tmp/pear/mongodb/src/libmongoc/src/mongoc/mongoc-version.h
      config.status: creating /tmp/pear/mongodb/src/libbson/src/bson/bson-config.h
      config.status: creating /tmp/pear/mongodb/src/libbson/src/bson/bson-version.h
      config.status: creating config.h
      running: make
      /bin/sh /tmp/pear/pear-build-rootsplUam/mongodb-1.2.2/libtool --mode=compile cc    -I. -I/tmp/pear/mongodb -DPHP_ATOM_INC -I/tmp/pear/pear-build-rootsplUam/mongodb-1.2.2/include -I/tmp/pear/pear-build-rootsplUam/mongodb-1.2.2/main -I/tmp/pear/mongodb -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -I/usr/local/include -I/usr/local -I/tmp/pear/mongodb/src/BSON/ -I/tmp/pear/mongodb/src/MongoDB/ -I/tmp/pear/mongodb/src/MongoDB/Exception/ -I/tmp/pear/mongodb/src/contrib/ -I/tmp/pear/mongodb/src/libmongoc/src/mongoc/ -I/tmp/pear/mongodb/src/libbson/src/ -I/tmp/pear/mongodb/src/libbson/src/yajl/ -I/tmp/pear/mongodb/src/libbson/src/bson/  -L/usr/local/lib -I/usr/local/include -DBSON_COMPILATION -DMONGOC_COMPILATION -DMONGOC_TRACE -DHAVE_CONFIG_H  -L/usr/local/lib -I/usr/local/include -L/usr/lib -I /usr/include -D_THREAD_SAFE -pthread  -c /tmp/pear/mongodb/src/bson.c -o src/bson.lo
      

            Assignee:
            bjori Hannes Magnusson
            Reporter:
            ooglek Peter Beckman
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: