linux - Edit CMakeLists.txt to compile with -fPIC -


i'm trying install drivers novint falcon called libnifalcon. used cmake create make file, when run make error:

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 used when making shared object; recompile -fpic   /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../lib/libboost_program_options-mt.a: 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   

i've tried many of techniques compile usinf -fpic none have worked. can tell me in makefile, , write in order compile using -fpic?

the makefile is:

            # cmake generated file: not edit!             # generated "unix makefiles" generator, cmake version 2.8              # default target executed when no arguments given make.             default_target:             .phony : default_target              #=============================================================================             # special targets provided cmake.              # disable implicit rules canonical targets work.             .suffixes:              # remove rules gmake .suffixes not remove.             suffixes =              .suffixes: .hpux_make_needs_suffix_list              # suppress display of executed commands.             $(verbose).silent:              # target out of date.             cmake_force:             .phony : cmake_force              #=============================================================================             # set environment variables build.              # shell in execute make rules.             #shell = /bin/sh              # cmake executable.             cmake_command = /usr/bin/cmake              # command remove file.             rm = /usr/bin/cmake -e remove -f              # program use edit cache.             cmake_edit_command = /usr/bin/ccmake              # top-level source directory on cmake run.             cmake_source_dir = /home/mikewrock/desktop/h3d/libnifalcon-1.0.1              # top-level build directory on cmake run.             cmake_binary_dir = /home/mikewrock/desktop/h3d/libnifalcon-1.0.1/linux              #=============================================================================             # targets provided globally cmake.              # special rule 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 target edit_cache             edit_cache/fast: edit_cache             .phony : edit_cache/fast              # special rule target install             install: preinstall                 @$(cmake_command) -e cmake_echo_color --switch=$(color) --cyan "install project..."                 /usr/bin/cmake -p cmake_install.cmake             .phony : install              # special rule target install             install/fast: preinstall/fast                 @$(cmake_command) -e cmake_echo_color --switch=$(color) --cyan "install project..."                 /usr/bin/cmake -p cmake_install.cmake             .phony : install/fast              # special rule target install/local             install/local: preinstall                 @$(cmake_command) -e cmake_echo_color --switch=$(color) --cyan "installing local directory..."                 /usr/bin/cmake -dcmake_install_local_only=1 -p cmake_install.cmake             .phony : install/local              # special rule target install/local             install/local/fast: install/local             .phony : install/local/fast              # special rule target install/strip             install/strip: preinstall                 @$(cmake_command) -e cmake_echo_color --switch=$(color) --cyan "installing project stripped..."                 /usr/bin/cmake -dcmake_install_do_strip=1 -p cmake_install.cmake             .phony : install/strip              # special rule target install/strip             install/strip/fast: install/strip             .phony : install/strip/fast              # special rule 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 target list_install_components             list_install_components/fast: list_install_components             .phony : list_install_components/fast              # special rule target rebuild_cache             rebuild_cache:                 @$(cmake_command) -e cmake_echo_color --switch=$(color) --cyan "running cmake regenerate build system..."                 /usr/bin/cmake -h$(cmake_source_dir) -b$(cmake_binary_dir)             .phony : rebuild_cache              # special rule target rebuild_cache             rebuild_cache/fast: rebuild_cache             .phony : rebuild_cache/fast              # main 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                 $(cmake_command) -e cmake_progress_start /home/mikewrock/desktop/h3d/libnifalcon-1.0.1/linux/cmakefiles 0             .phony :              # main clean target             clean:                 $(make) -f cmakefiles/makefile2 clean             .phony : clean              # main clean target             clean/fast: clean             .phony : clean/fast              # prepare targets installation.             preinstall:                 $(make) -f cmakefiles/makefile2 preinstall             .phony : preinstall              # prepare targets 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 targets named nifalcon_depend              # build rule target.             nifalcon_depend: cmake_check_build_system                 $(make) -f cmakefiles/makefile2 nifalcon_depend             .phony : nifalcon_depend              # fast build rule 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 targets named nifalcon_shared              # build rule target.             nifalcon_shared: cmake_check_build_system                 $(make) -f cmakefiles/makefile2 nifalcon_shared             .phony : nifalcon_shared              # fast build rule 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 targets named nifalcon_static              # build rule target.             nifalcon_static: cmake_check_build_system                 $(make) -f cmakefiles/makefile2 nifalcon_static             .phony : nifalcon_static              # fast build rule 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 targets named nifalcon_cli_base_depend              # build rule 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 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 targets named nifalcon_cli_base_shared              # build rule 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 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 targets named nifalcon_cli_base_static              # build rule 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 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 targets named nifalcon_device_boost_thread_depend              # build rule 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 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 targets named nifalcon_device_boost_thread_shared              # build rule 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 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 targets named nifalcon_device_boost_thread_static              # build rule 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 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 targets named barrow_mechanics              # build rule target.             barrow_mechanics: cmake_check_build_system                 $(make) -f cmakefiles/makefile2 barrow_mechanics             .phony : barrow_mechanics              # fast build rule 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 targets named falcon_led              # build rule target.             falcon_led: cmake_check_build_system                 $(make) -f cmakefiles/makefile2 falcon_led             .phony : falcon_led              # fast build rule 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 targets named falcon_test_cli              # build rule target.             falcon_test_cli: cmake_check_build_system                 $(make) -f cmakefiles/makefile2 falcon_test_cli             .phony : falcon_test_cli              # fast build rule 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 targets named findfalcons              # build rule target.             findfalcons: cmake_check_build_system                 $(make) -f cmakefiles/makefile2 findfalcons             .phony : findfalcons              # fast build rule target.             findfalcons/fast:                 $(make) -f examples/cmakefiles/findfalcons.dir/build.make examples/cmakefiles/findfalcons.dir/build             .phony : findfalcons/fast              #=============================================================================             # target rules targets named findfalcons_multi              # build rule target.             findfalcons_multi: cmake_check_build_system                 $(make) -f cmakefiles/makefile2 findfalcons_multi             .phony : findfalcons_multi              # fast build rule target.             findfalcons_multi/fast:                 $(make) -f examples/cmakefiles/findfalcons_multi.dir/build.make examples/cmakefiles/findfalcons_multi.dir/build             .phony : findfalcons_multi/fast              # target             help:                 @echo "the following of valid targets makefile:"                 @echo "... (the default if no target 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 :                #=============================================================================             # special targets cleanup operation of make.              # special rule run cmake check build system integrity.             # no rule depends on can have commands come listfiles             # because might 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 

thanks -michael

edit: recommended, i've tried modifying cmakelists.txt instead of makefiles generates. i'm still having same issue, here 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 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 np labs project compilation functions.\n"                 "make sure you've either put compily_buildd directory in same root repository directory, or you've used compily_buildd submodule (git submodule update --init).\n"                 "np labs build repository available @ 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 , 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 symbolic link [library_name]_s on static libraries (for ease in building staticly linked binaries under gcc)" off)             option(build_swig_bindings "build java/python bindings 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 , not libusb_1_found)               message(fatal_error "either ftd2xx or libusb-1.0 required build libnifalcon. check readme file info.")             endif(not libftd2xx_found , not libusb_1_found)              #find boost, used on 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 minimum of boost 1.33 headers 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 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 build libusb staticly on apple, need proper frameworks             if(build_static , apple)               list(append libnifalcon_exe_link_libs "-framework iokit" "-framework corefoundation")             endif(build_static , 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 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) 

you can add following makefile.

cflags += -fpic cppflags += -fpic 

but, really, should modifying code cmake, , regenerate makefile. there should way add cflags in cmake.

edit: seems can set cmake variables cmake_c_flags , cmake_cxx_flags in cmake input file.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -