[CMake] linking

Hector Franco Penya hecfran at alumni.uv.es
Thu Feb 8 12:26:56 EST 2007


I have a problem whith Cmake 2.4 linking a library:

When I use make, the console displays:

hector at hector-laptop:~/arisnova/aUtilityLib/src/aUtilityLib$ make
[ 11%] Building CXX object CMakeFiles/arisutil.dir/Precompiled.o
[ 22%] Building C object CMakeFiles/arisutil.dir/binreloc/binreloc.o
[ 33%] Building CXX object CMakeFiles/arisutil.dir/Exception/Exception.o
[ 44%] Building CXX object CMakeFiles/arisutil.dir/MD5/MD5.o
[ 55%] Building CXX object CMakeFiles/arisutil.dir/Counters/Counters.o
/home/hector/arisnova/aUtilityLib/src/aUtilityLib/Counters/SharedMemory.h:54:
warning: 'autil::SHARED_MEMORY_MAP_FILENAME' defined but not used
/home/hector/arisnova/aUtilityLib/src/aUtilityLib/Counters/SharedMemory.h:57:
warning: 'autil::HEADER_MAGIC' defined but not used
/home/hector/arisnova/aUtilityLib/src/aUtilityLib/Counters/SharedMemory.h:59:
warning: 'autil::HEADER_DATETIME_MASK' defined but not used
[ 66%] Building CXX object CMakeFiles/arisutil.dir/Counters/SharedMemory.o
[ 77%] Building CXX object CMakeFiles/arisutil.dir/Counters/Loader.o
[ 88%] Building CXX object CMakeFiles/arisutil.dir/Counters/Snapshot.o
/home/hector/arisnova/aUtilityLib/src/aUtilityLib/Counters/SharedMemory.h:54:
warning: 'autil::SHARED_MEMORY_MAP_FILENAME' defined but not used
/home/hector/arisnova/aUtilityLib/src/aUtilityLib/Counters/SharedMemory.h:57:
warning: 'autil::HEADER_MAGIC' defined but not used
/home/hector/arisnova/aUtilityLib/src/aUtilityLib/Counters/SharedMemory.h:59:
warning: 'autil::HEADER_DATETIME_MASK' defined but not used
../../include/aUtilityLib/Counters.h:60: warning:
'autil::AUTIL_COUNTERS_DATA_FILENAME' defined but not used
../../include/aUtilityLib/Counters.h:65: warning:
'autil::AUTIL_COUNTERS_CONFIG_FILENAME' defined but not used
[100%] Building CXX object CMakeFiles/arisutil.dir/Counters/Counters_Built-in.o
../../include/aUtilityLib/Counters.h:60: warning:
'autil::AUTIL_COUNTERS_DATA_FILENAME' defined but not used
../../include/aUtilityLib/Counters.h:65: warning:
'autil::AUTIL_COUNTERS_CONFIG_FILENAME' defined but not used
Linking CXX shared library libarisutil.so
c++: -soname: linker input file unused because linking not done
c++: libarisutil.so: linker input file unused because linking not done
c++: CMakeFiles/arisutil.dir/Precompiled.o: linker input file unused
because linking not done
c++: CMakeFiles/arisutil.dir/binreloc/binreloc.o: linker input file
unused because linking not done
c++: CMakeFiles/arisutil.dir/Exception/Exception.o: linker input file
unused because linking not done
c++: CMakeFiles/arisutil.dir/MD5/MD5.o: linker input file unused
because linking not done
c++: CMakeFiles/arisutil.dir/Counters/Counters.o: linker input file
unused because linking not done
c++: CMakeFiles/arisutil.dir/Counters/SharedMemory.o: linker input
file unused because linking not done
c++: CMakeFiles/arisutil.dir/Counters/Loader.o: linker input file
unused because linking not done
c++: CMakeFiles/arisutil.dir/Counters/Snapshot.o: linker input file
unused because linking not done
c++: CMakeFiles/arisutil.dir/Counters/Counters_Built-in.o: linker
input file unused because linking not done
[100%] Built target arisutil




so it displays that is not going to use the *.o files to build the library



I write these CMakeLists.txt file:




SET(CMAKE_CXX_FLAGS "-fPIC -D_REENTRANT -g -c -I./binreloc
-I../../include -I./Counters -Wall -Wextra -shared
-DGCC_HASCLASSVISIBILITY -DAUTILITYLIB_API_EXPORTS -DENABLE_BINRELOC
") #these sentence pass parameters to the compiler gcc


message("Using these parameters : ${CMAKE_CXX_FLAGS}")

include_directories("${PROJECT_BINARY_DIR}")

FOREACH (carpeta
	binreloc
	Exception
	MD5
	Counters
	)
	include_directories("${PROJECT_SOURCE_DIR}/${carpeta}") 	#It mast be
included all the directories that are used.

ENDFOREACH(carpeta)


add_library (arisutil SHARED  Precompiled.cpp binreloc/binreloc.c
Exception/Exception.cpp MD5/MD5.cpp Counters/Counters.cpp
Counters/SharedMemory.cpp Counters/Loader.cpp Counters/Snapshot.cpp
Counters/Counters_Built-in.cpp)


SET_TARGET_PROPERTIES(arisutil PROPERTIES LINK_FLAGS_DEBUG
"-Wl,-soname,libarisutil.so.0 -Wall -Wextra -D_REENTRANT -shared")





I don't underestand why gcc don't link these library.
thanks


More information about the CMake mailing list