I am altering a CMake file which works on Windows to create a shared object in Linux.
The CMake file generates a makefile and when I did "make" on Linux, it built objects of foo libraries and it displays linking of all four libraries. For example:
Linking CXX static library lib_foo_d.a
and the final shared object
Linking CXX static library lib_scen_files_d.a
but at the end it displays
/usr/bin/ld: lib_foo3/lib_foo3_d.a(chap_alt_scence_defs.cpp.o):
relocation R_X86_64_32 against `.rodata' can not be used when making a shared object;
recompile with -fPIC
lib_foo3/lib_foo3_d.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
I have tried a few other options, but no joy. Below is my CMakeLists.txt. Any help/criticism will be beneficial to me.
CMAKE_MINIMUM_REQUIRED( VERSION 2.8 )
CMAKE_POLICY( SET CMP0017 NEW )
PROJECT( disk_space_model )
INCLUDE( ../libs/helper_functions.cmake )
INCLUDE_THIRD_PARTY_SFC()
find_path_for_libs()
add_s_library( lib_foo1 )
add_s_library( lib_foo2)
add_s_library( lib_foo3)
add_s_library( lib_foo4)
SET( HEADER_FILES
stdafx.h
INS_sensor_model.h
)
SET( SOURCE_FILES
Disk_space_model.cpp
)
SET( RESOURCE_FILES
"Disk Space DLL.rc"
resource.h
)
COMMON_SETUP()
set( LIB_FILES
lib_foo
lib_foo1
lib_foo3
lib_foo4 )
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--export-all-symbols")
ADD_LIBRARY( disk_space_model SHARED ${SOURCE_FILES} ${HEADER_FILES} ${RESOURCE_FILES} ${CMAKE_HELPER_FILES} )
SET_OUTPUT_DIRS( disk_space_model )
TARGET_LINK_LIBRARIES( disk_space_model ${LIB_FILES} )
Thanks ...