Forum: help
Monitor Forum | Start New ThreadMac build problem, "-single_module" flag [ Reply ] By: Dan Stowell on 2012-02-09 15:24 | [forum:109208] |
Hi - Compiling on Mac 10.4.11 (intel) is failing here. All dependencies installed, cmake configures happily, then "make" results in a fail after building the first item: Linking CXX executable ../../bin/make_regression_constants /usr/bin/ld: -single_module or -multi_module flags can only be used when -dylib is also specified collect2: ld returned 1 exit status Now, the reason seems to be this line in the ./CMakeLists.txt: SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -single_module -headerpad_max_install_names ${COVERAGE_LIB}") I suspect that "-single_module" should be a linker flag not a CXX flag. (CMAKE_MODULE_LINKER_FLAGS perhaps?) But I'm not 100% sure how to proceed. I tried this: --- ../CMakeLists.orig.txt 2012-02-09 15:24:56.000000000 +0000 +++ ../CMakeLists.txt 2012-02-09 15:25:07.000000000 +0000 @@ -104,7 +104,12 @@ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -single_module -headerpad_max_install_names ${COVERAGE_LIB}") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC") ELSE(CMAKE_SYSTEM_PROCESSOR STREQUAL "ia64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -single_module -headerpad_max_install_names ${COVERAGE_LIB}") + + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -headerpad_max_install_names ${COVERAGE_LIB}") + SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS} -single_module") + SET(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS} -single_module") + + ENDIF(CMAKE_SYSTEM_PROCESSOR STREQUAL "ia64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") ELSE(APPLE) IF(CMAKE_SYSTEM_PROCESSOR STREQUAL "ia64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") This goes a long way towards compiling things, but eventually errors out with: [ 79%] Built target getopt Linking CXX executable ../../bin/cmpd /usr/bin/ld: multiple definitions of symbol _getopt /usr/lib//libdl.dylib(getopt.So) definition of _getopt ../../lib/liblibgetopt.a(getopt.o) definition of _getopt in section (__TEXT,__text) /usr/bin/ld: multiple definitions of symbol _opterr /usr/lib//libdl.dylib(getopt.So) definition of _opterr ../../lib/liblibgetopt.a(getopt.o) definition of _opterr in section (__DATA,__data) /usr/bin/ld: multiple definitions of symbol _optind /usr/lib//libdl.dylib(getopt.So) definition of _optind ../../lib/liblibgetopt.a(getopt.o) definition of _optind in section (__DATA,__data) /usr/bin/ld: multiple definitions of symbol _optopt /usr/lib//libdl.dylib(getopt.So) definition of _optopt ../../lib/liblibgetopt.a(getopt.o) definition of _optopt in section (__DATA,__data) collect2: ld returned 1 exit status make[2]: *** [bin/cmpd] Error 1 This multiple definition problem is probably what the single_module option prevents - so what is the proper way to set this up? Any suggestions gratefully received. Best Dan |