编辑CMakeLists.txt与-fPIC编译

我正在尝试安装名为libnifalcon的NOVINT Falcon的驱动程序。 我用cmake来创build一个make文件,但是当我运行make时,我得到错误:

Linking CXX shared library ../../lib/libnifalcon_cli_base.so /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../lib/libboost_program_options-mt.a(cmdline.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../lib/libboost_program_options-mt.a: could not read symbols: Bad value collect2: ld returned 1 exit status make[2]: ** [lib/libnifalcon_cli_base.so.1.0.1] Error 1 make[1]: ** [src/util/CMakeFiles/nifalcon_cli_base_SHARED.dir/all] Error 2 make: *** [all] Error 2 

我已经尝试了许多技术来编译usinf -fPIC,但都没有工作。 任何人都可以告诉我在哪里在生成文件,以及要编写使用-fPIC编译?

生成文件是:

  # CMAKE generated file: DO NOT EDIT! # Generated by "Unix Makefiles" Generator, CMake Version 2.8 # Default target executed when no arguments are given to make. default_target: all .PHONY : default_target #============================================================================= # Special targets provided by cmake. # Disable implicit rules so canonical targets will work. .SUFFIXES: # Remove some rules from gmake that .SUFFIXES does not remove. SUFFIXES = .SUFFIXES: .hpux_make_needs_suffix_list # Suppress display of executed commands. $(VERBOSE).SILENT: # A target that is always out of date. cmake_force: .PHONY : cmake_force #============================================================================= # Set environment variables for the build. # The shell in which to execute make rules. #SHELL = /bin/sh # The CMake executable. CMAKE_COMMAND = /usr/bin/cmake # The command to remove a file. RM = /usr/bin/cmake -E remove -f # The program to use to edit the cache. CMAKE_EDIT_COMMAND = /usr/bin/ccmake # The top-level source directory on which CMake was run. CMAKE_SOURCE_DIR = /home/mikewrock/Desktop/h3d/libnifalcon-1.0.1 # The top-level build directory on which CMake was run. CMAKE_BINARY_DIR = /home/mikewrock/Desktop/h3d/libnifalcon-1.0.1/linux #============================================================================= # Targets provided globally by CMake. # Special rule for the target edit_cache edit_cache: @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake cache editor..." /usr/bin/ccmake -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) .PHONY : edit_cache # Special rule for the target edit_cache edit_cache/fast: edit_cache .PHONY : edit_cache/fast # Special rule for the target install install: preinstall @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Install the project..." /usr/bin/cmake -P cmake_install.cmake .PHONY : install # Special rule for the target install install/fast: preinstall/fast @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Install the project..." /usr/bin/cmake -P cmake_install.cmake .PHONY : install/fast # Special rule for the target install/local install/local: preinstall @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Installing only the local directory..." /usr/bin/cmake -DCMAKE_INSTALL_LOCAL_ONLY=1 -P cmake_install.cmake .PHONY : install/local # Special rule for the target install/local install/local/fast: install/local .PHONY : install/local/fast # Special rule for the target install/strip install/strip: preinstall @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Installing the project stripped..." /usr/bin/cmake -DCMAKE_INSTALL_DO_STRIP=1 -P cmake_install.cmake .PHONY : install/strip # Special rule for the target install/strip install/strip/fast: install/strip .PHONY : install/strip/fast # Special rule for the target list_install_components list_install_components: @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Available install components are: \"Unspecified\"" .PHONY : list_install_components # Special rule for the target list_install_components list_install_components/fast: list_install_components .PHONY : list_install_components/fast # Special rule for the target rebuild_cache rebuild_cache: @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake to regenerate build system..." /usr/bin/cmake -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) .PHONY : rebuild_cache # Special rule for the target rebuild_cache rebuild_cache/fast: rebuild_cache .PHONY : rebuild_cache/fast # The main all target all: cmake_check_build_system $(CMAKE_COMMAND) -E cmake_progress_start /home/mikewrock/Desktop/h3d/libnifalcon-1.0.1/linux/CMakeFiles /home/mikewrock/Desktop/h3d/libnifalcon-1.0.1/linux/CMakeFiles/progress.marks $(MAKE) -f CMakeFiles/Makefile2 all $(CMAKE_COMMAND) -E cmake_progress_start /home/mikewrock/Desktop/h3d/libnifalcon-1.0.1/linux/CMakeFiles 0 .PHONY : all # The main clean target clean: $(MAKE) -f CMakeFiles/Makefile2 clean .PHONY : clean # The main clean target clean/fast: clean .PHONY : clean/fast # Prepare targets for installation. preinstall: all $(MAKE) -f CMakeFiles/Makefile2 preinstall .PHONY : preinstall # Prepare targets for installation. preinstall/fast: $(MAKE) -f CMakeFiles/Makefile2 preinstall .PHONY : preinstall/fast # clear depends depend: $(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 1 .PHONY : depend #============================================================================= # Target rules for targets named nifalcon_DEPEND # Build rule for target. nifalcon_DEPEND: cmake_check_build_system $(MAKE) -f CMakeFiles/Makefile2 nifalcon_DEPEND .PHONY : nifalcon_DEPEND # fast build rule for target. nifalcon_DEPEND/fast: $(MAKE) -f src/CMakeFiles/nifalcon_DEPEND.dir/build.make src/CMakeFiles/nifalcon_DEPEND.dir/build .PHONY : nifalcon_DEPEND/fast #============================================================================= # Target rules for targets named nifalcon_SHARED # Build rule for target. nifalcon_SHARED: cmake_check_build_system $(MAKE) -f CMakeFiles/Makefile2 nifalcon_SHARED .PHONY : nifalcon_SHARED # fast build rule for target. nifalcon_SHARED/fast: $(MAKE) -f src/CMakeFiles/nifalcon_SHARED.dir/build.make src/CMakeFiles/nifalcon_SHARED.dir/build .PHONY : nifalcon_SHARED/fast #============================================================================= # Target rules for targets named nifalcon_STATIC # Build rule for target. nifalcon_STATIC: cmake_check_build_system $(MAKE) -f CMakeFiles/Makefile2 nifalcon_STATIC .PHONY : nifalcon_STATIC # fast build rule for target. nifalcon_STATIC/fast: $(MAKE) -f src/CMakeFiles/nifalcon_STATIC.dir/build.make src/CMakeFiles/nifalcon_STATIC.dir/build .PHONY : nifalcon_STATIC/fast #============================================================================= # Target rules for targets named nifalcon_cli_base_DEPEND # Build rule for target. nifalcon_cli_base_DEPEND: cmake_check_build_system $(MAKE) -f CMakeFiles/Makefile2 nifalcon_cli_base_DEPEND .PHONY : nifalcon_cli_base_DEPEND # fast build rule for target. nifalcon_cli_base_DEPEND/fast: $(MAKE) -f src/util/CMakeFiles/nifalcon_cli_base_DEPEND.dir/build.make src/util/CMakeFiles/nifalcon_cli_base_DEPEND.dir/build .PHONY : nifalcon_cli_base_DEPEND/fast #============================================================================= # Target rules for targets named nifalcon_cli_base_SHARED # Build rule for target. nifalcon_cli_base_SHARED: cmake_check_build_system $(MAKE) -f CMakeFiles/Makefile2 nifalcon_cli_base_SHARED .PHONY : nifalcon_cli_base_SHARED # fast build rule for target. nifalcon_cli_base_SHARED/fast: $(MAKE) -f src/util/CMakeFiles/nifalcon_cli_base_SHARED.dir/build.make src/util/CMakeFiles/nifalcon_cli_base_SHARED.dir/build .PHONY : nifalcon_cli_base_SHARED/fast #============================================================================= # Target rules for targets named nifalcon_cli_base_STATIC # Build rule for target. nifalcon_cli_base_STATIC: cmake_check_build_system $(MAKE) -f CMakeFiles/Makefile2 nifalcon_cli_base_STATIC .PHONY : nifalcon_cli_base_STATIC # fast build rule for target. nifalcon_cli_base_STATIC/fast: $(MAKE) -f src/util/CMakeFiles/nifalcon_cli_base_STATIC.dir/build.make src/util/CMakeFiles/nifalcon_cli_base_STATIC.dir/build .PHONY : nifalcon_cli_base_STATIC/fast #============================================================================= # Target rules for targets named nifalcon_device_boost_thread_DEPEND # Build rule for target. nifalcon_device_boost_thread_DEPEND: cmake_check_build_system $(MAKE) -f CMakeFiles/Makefile2 nifalcon_device_boost_thread_DEPEND .PHONY : nifalcon_device_boost_thread_DEPEND # fast build rule for target. nifalcon_device_boost_thread_DEPEND/fast: $(MAKE) -f src/util/CMakeFiles/nifalcon_device_boost_thread_DEPEND.dir/build.make src/util/CMakeFiles/nifalcon_device_boost_thread_DEPEND.dir/build .PHONY : nifalcon_device_boost_thread_DEPEND/fast #============================================================================= # Target rules for targets named nifalcon_device_boost_thread_SHARED # Build rule for target. nifalcon_device_boost_thread_SHARED: cmake_check_build_system $(MAKE) -f CMakeFiles/Makefile2 nifalcon_device_boost_thread_SHARED .PHONY : nifalcon_device_boost_thread_SHARED # fast build rule for target. nifalcon_device_boost_thread_SHARED/fast: $(MAKE) -f src/util/CMakeFiles/nifalcon_device_boost_thread_SHARED.dir/build.make src/util/CMakeFiles/nifalcon_device_boost_thread_SHARED.dir/build .PHONY : nifalcon_device_boost_thread_SHARED/fast #============================================================================= # Target rules for targets named nifalcon_device_boost_thread_STATIC # Build rule for target. nifalcon_device_boost_thread_STATIC: cmake_check_build_system $(MAKE) -f CMakeFiles/Makefile2 nifalcon_device_boost_thread_STATIC .PHONY : nifalcon_device_boost_thread_STATIC # fast build rule for target. nifalcon_device_boost_thread_STATIC/fast: $(MAKE) -f src/util/CMakeFiles/nifalcon_device_boost_thread_STATIC.dir/build.make src/util/CMakeFiles/nifalcon_device_boost_thread_STATIC.dir/build .PHONY : nifalcon_device_boost_thread_STATIC/fast #============================================================================= # Target rules for targets named barrow_mechanics # Build rule for target. barrow_mechanics: cmake_check_build_system $(MAKE) -f CMakeFiles/Makefile2 barrow_mechanics .PHONY : barrow_mechanics # fast build rule for target. barrow_mechanics/fast: $(MAKE) -f examples/CMakeFiles/barrow_mechanics.dir/build.make examples/CMakeFiles/barrow_mechanics.dir/build .PHONY : barrow_mechanics/fast #============================================================================= # Target rules for targets named falcon_led # Build rule for target. falcon_led: cmake_check_build_system $(MAKE) -f CMakeFiles/Makefile2 falcon_led .PHONY : falcon_led # fast build rule for target. falcon_led/fast: $(MAKE) -f examples/CMakeFiles/falcon_led.dir/build.make examples/CMakeFiles/falcon_led.dir/build .PHONY : falcon_led/fast #============================================================================= # Target rules for targets named falcon_test_cli # Build rule for target. falcon_test_cli: cmake_check_build_system $(MAKE) -f CMakeFiles/Makefile2 falcon_test_cli .PHONY : falcon_test_cli # fast build rule for target. falcon_test_cli/fast: $(MAKE) -f examples/CMakeFiles/falcon_test_cli.dir/build.make examples/CMakeFiles/falcon_test_cli.dir/build .PHONY : falcon_test_cli/fast #============================================================================= # Target rules for targets named findfalcons # Build rule for target. findfalcons: cmake_check_build_system $(MAKE) -f CMakeFiles/Makefile2 findfalcons .PHONY : findfalcons # fast build rule for target. findfalcons/fast: $(MAKE) -f examples/CMakeFiles/findfalcons.dir/build.make examples/CMakeFiles/findfalcons.dir/build .PHONY : findfalcons/fast #============================================================================= # Target rules for targets named findfalcons_multi # Build rule for target. findfalcons_multi: cmake_check_build_system $(MAKE) -f CMakeFiles/Makefile2 findfalcons_multi .PHONY : findfalcons_multi # fast build rule for target. findfalcons_multi/fast: $(MAKE) -f examples/CMakeFiles/findfalcons_multi.dir/build.make examples/CMakeFiles/findfalcons_multi.dir/build .PHONY : findfalcons_multi/fast # Help Target help: @echo "The following are some of the valid targets for this Makefile:" @echo "... all (the default if no target is provided)" @echo "... clean" @echo "... depend" @echo "... edit_cache" @echo "... install" @echo "... install/local" @echo "... install/strip" @echo "... list_install_components" @echo "... rebuild_cache" @echo "... nifalcon_DEPEND" @echo "... nifalcon_SHARED" @echo "... nifalcon_STATIC" @echo "... nifalcon_cli_base_DEPEND" @echo "... nifalcon_cli_base_SHARED" @echo "... nifalcon_cli_base_STATIC" @echo "... nifalcon_device_boost_thread_DEPEND" @echo "... nifalcon_device_boost_thread_SHARED" @echo "... nifalcon_device_boost_thread_STATIC" @echo "... barrow_mechanics" @echo "... falcon_led" @echo "... falcon_test_cli" @echo "... findfalcons" @echo "... findfalcons_multi" .PHONY : help #============================================================================= # Special targets to cleanup operation of make. # Special rule to run CMake to check the build system integrity. # No rule that depends on this can have commands that come from listfiles # because they might be regenerated. cmake_check_build_system: $(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 0 .PHONY : cmake_check_build_system 

感谢您的帮助 – 迈克尔

编辑:build议,我已经尝试修改CMakeLists.txt而不是它生成的makefiles。 我仍然有同样的问题,所以这里是CMakeLists.txt:

  ###################################################################################### # CMake directives ###################################################################################### #Require 2.6 or higher. CMAKE_MINIMUM_REQUIRED(VERSION 2.6.0 FATAL_ERROR) #See if we've got our cmake modules checked out. If not, advise to do so. IF(EXISTS "${CMAKE_SOURCE_DIR}/../compily_buildd/cmake") SET(BUILDSYS_CMAKE_DIR "${CMAKE_SOURCE_DIR}/../compily_buildd/cmake") MESSAGE(STATUS "Using outside compily_buildd directory ${BUILDSYS_CMAKE_DIR}") ELSEIF(EXISTS "${CMAKE_SOURCE_DIR}/compily_buildd/cmake") SET(BUILDSYS_CMAKE_DIR "${CMAKE_SOURCE_DIR}/compily_buildd/cmake") MESSAGE(STATUS "Using compily_buildd git submodule ${BUILDSYS_CMAKE_DIR}") ELSE(EXISTS "${CMAKE_SOURCE_DIR}/compily_buildd/cmake") MESSAGE(FATAL_ERROR "Cannot find compily_buildd directory for np labs project compilation functions.\n" "Make sure you've either put the compily_buildd directory in the same root as your repository directory, or that you've used the compily_buildd submodule (git submodule update --init).\n" "NP Labs build repository is available at git://github.com/qdot/compily_buildd.git" ) ENDIF(EXISTS "${CMAKE_SOURCE_DIR}/../compily_buildd/cmake") LIST(APPEND CMAKE_MODULE_PATH ${BUILDSYS_CMAKE_DIR}) INCLUDE( ${BUILDSYS_CMAKE_DIR}/BuildSysCMakeLib.cmake ) #setting link directory policy IF(COMMAND cmake_policy) CMAKE_POLICY(SET CMP0003 NEW) ENDIF(COMMAND cmake_policy) ###################################################################################### # Project declaration and options ###################################################################################### #Project declaration PROJECT(LIBNIFALCON) set(CMAKE_C_COMPILER "gcc") set(CMAKE_CXX_COMPILER "g++") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC" ) INITIALIZE_BUILD() #Common Options OPTION_LIBRARY_BUILD_STATIC(ON) #We can't build shared on MSVC yet IF(NOT MSVC) OPTION_LIBRARY_BUILD_SHARED(ON) ENDIF(NOT MSVC) OPTION_FAST_MATH(ON) OPTION_ARCH_OPTS(ON) OPTION_GPROF(OFF) #OPTION_LOG4CXX(OFF LIBNIFALCON_REQ_LIBS) #OPTION_CREATE_VERSION_FILE(ON "${CMAKE_CURRENT_SOURCE_DIR}/src/version.cc") #Project specific options OPTION(FORCE_FTD2XX_BUILD "Force building FTD2XX libraries on non-windows platforms" OFF) OPTION(STATIC_LINK_SUFFIXES "Add a symbolic link with [library_name]_s on static libraries (for ease in building staticly linked binaries under gcc)" OFF) OPTION(BUILD_SWIG_BINDINGS "Build Java/Python bindings for libnifalcon" OFF) OPTION(BUILD_EXAMPLES "Build libnifalcon examples" ON) ###################################################################################### # Project specific package finding ###################################################################################### #Find communications libraries IF(WIN32 OR FORCE_FTD2XX_BUILD) FIND_PACKAGE(libftd2xx) IF(LIBFTD2XX_FOUND) INCLUDE_DIRECTORIES(${LIBFTD2XX_INCLUDE_DIRS}) SET(LIBNIFALCON_REQ_LIBS ${LIBFTD2XX_LIBRARIES}) ENDIF(LIBFTD2XX_FOUND) ENDIF(WIN32 OR FORCE_FTD2XX_BUILD) IF(NOT LIBFTD2XX_FOUND) FIND_PACKAGE(libusb-1.0) IF(LIBUSB_1_FOUND) INCLUDE_DIRECTORIES(${LIBUSB_1_INCLUDE_DIRS}) SET(LIBNIFALCON_REQ_LIBS ${LIBUSB_1_LIBRARIES}) ENDIF(LIBUSB_1_FOUND) ENDIF(NOT LIBFTD2XX_FOUND) IF(NOT LIBFTD2XX_FOUND AND NOT LIBUSB_1_FOUND) MESSAGE(FATAL_ERROR "Either ftd2xx or libusb-1.0 is required to build libnifalcon. Check the README file for info.") ENDIF(NOT LIBFTD2XX_FOUND AND NOT LIBUSB_1_FOUND) #Find boost, used all over the place SET(Boost_USE_MULTITHREADED ON) SET(Boost_USE_STATIC_LIBS ON) FIND_PACKAGE(Boost REQUIRED) IF(NOT Boost_FOUND) MESSAGE(FATAL_ERROR "libnifalcon requires a minimum of the Boost 1.33 headers to build") ENDIF(NOT Boost_FOUND) FIND_PACKAGE(Boost COMPONENTS program_options thread) ###################################################################################### # Project specific globals ###################################################################################### #library definitions SET(LIBNIFALCON_MAJOR_VERSION 1) SET(LIBNIFALCON_MINOR_VERSION 0) SET(LIBNIFALCON_BUILD_VERSION 1) # BUILDSYS_CPACK_INFO( # NAME "libnifalcon" # MAJOR_VERSION ${LIBNIFALCON_MAJOR_VERSION} # MINOR_VERSION ${LIBNIFALCON_MINOR_VERSION} # BUILD_VERSION ${LIBNIFALCON_BUILD_VERSION} # VENDOR "Nonpolynomial Labs" # DESCRIPTION "Open Source Driver for the Novint Falcon Haptic Controller" # ) # INCLUDE(CPack) SET(LIBNIFALCON_VERSION ${LIBNIFALCON_MAJOR_VERSION}.${LIBNIFALCON_MINOR_VERSION}.${LIBNIFALCON_BUILD_VERSION}) #library name definitions CREATE_LIBRARY_LINK_NAME(nifalcon) CREATE_LIBRARY_LINK_NAME(nifalcon_cli_base) CREATE_LIBRARY_LINK_NAME(nifalcon_device_boost_thread) SET(LIBNIFALCON_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/include") INCLUDE_DIRECTORIES(${LIBNIFALCON_INCLUDE_DIR} ${Boost_INCLUDE_DIRS}) LINK_DIRECTORIES(${LIBRARY_OUTPUT_PATH}) #If we build libusb staticly on apple, we need the proper frameworks IF(BUILD_STATIC AND APPLE) LIST(APPEND LIBNIFALCON_EXE_LINK_LIBS "-framework IOKit" "-framework CoreFoundation") ENDIF(BUILD_STATIC AND APPLE) LIST(APPEND LIBNIFALCON_EXE_LINK_LIBS ${libnifalcon_LIBRARY} ${LIBNIFALCON_REQ_LIBS} ) ADD_SUBDIRECTORY(include) ADD_SUBDIRECTORY(src) IF(BUILD_EXAMPLES) ADD_SUBDIRECTORY(examples) ENDIF(BUILD_EXAMPLES) IF(BUILD_SWIG_BINDINGS) ADD_SUBDIRECTORY(lang/swig) ENDIF(BUILD_SWIG_BINDINGS) # pkg-config (use the CPack information) # FIND_PACKAGE(PkgConfig) # if(PKG_CONFIG_EXECUTABLE) # set(PC_SHORT_NAME "${BUILDSYS_CPACK_NAME}") # set(PC_LONG_NAME "${BUILDSYS_CPACK_NAME}") # set(PC_LIBRARY_NAME "${LIBNIFALCON_CPP}") # set(PC_DESCRIPTION "${CPACK_PACKAGE_DESCRIPTION_SUMMARY}") # set(PC_VERSION "${LIBNIFALCON_MAJOR_VERSION}.${LIBNIFALCON_MINOR_VERSION}.${LIBNIFALCON_BUILD_VERSION}") # if(LIBUSB_1_FOUND) # set(PC_REQUIRES "${PC_REQUIRES}libusb-1.0 ") # set(PC_LINK_FLAGS "${PC_LINK_FLAGS}-lnifalcon_comm_libusb ") # endif(LIBUSB_1_FOUND) # set(PC_LINK_FLAGS "${lib${PC_LIBRARY_NAME}_LINK_FLAGS} ${PC_LINK_FLAGS}") # set(PC_LINK_FLAGS "-l${PC_LIBRARY_NAME} ${PC_LINK_FLAGS}") # set(PC_COMPILE_FLAGS "${lib${PC_LIBRARY_NAME}_COMPILE_FLAGS}") # set(PC_CONFIGURED_FILE # ${CMAKE_BINARY_DIR}/libnifalcon.pc # ) # MESSAGE("-- Generating ${PC_CONFIGURED_FILE}") # configure_file( # ${CMAKE_SOURCE_DIR}/libnifalcon.pc.cmake # ${PC_CONFIGURED_FILE} # @ONLY # ) # set(PKG_CONFIG_DIR "${CMAKE_INSTALL_PREFIX}/lib/pkgconfig") # install(FILES ${PC_CONFIGURED_FILE} DESTINATION ${PKG_CONFIG_DIR}) # endif(PKG_CONFIG_EXECUTABLE) 

您可以将以下内容添加到Makefile中。

 CFLAGS += -fPIC CPPFLAGS += -fPIC 

但是,实际上,您应该修改cmake的代码,然后重新生成Makefile。 应该有一种方法来添加到cmake中的CFLAGS。

编辑:看起来像你可以在cmake输入文件中设置cmake变量CMAKE_C_FLAGS和CMAKE_CXX_FLAGS。

问题是CMakeLists.txt中SET(Boost_USE_STATIC_LIBS ON),当更改为SET(Boost_USE_STATIC_LIBS OFF)时,makefile工作正常。

感谢大家的帮助

我的东西你连接到错误的提升库(libboost_program_options-mt.a)。 它是静态的(.a),可能不是使用fPIC编译的。 尝试使用共享版本(.so)。