Here is a MakeFile for my project, since I'm using CLion for as my IDE, I need a Cmake configuration. I could not convert the following Makefile correctly.
all: VisualCryptography
VisualCryptography: VisualCryptographyGPU.o VisualCryptographyMC.o ExtVisualCryptographyCPU.o ExtVisualCryptographyGPU.o ExtVisualCryptographyMC.o VisualCryptographyCPUTest.o
g++ *.o -L/usr/local/cuda/lib64 -lcudart -lpthread ./lib/libVC.a -o VisualCryptography
rm -rf *.o
VisualCryptographyMC.o: ./source/VisualCryptographyMC.c
g++ -lpthread -c ./source/VisualCryptographyMC.c
VisualCryptographyCPUTest.o: ./source/VisualCryptographyCPUTest.c
g++ -lpthread -c ./source/VisualCryptographyCPUTest.c
VisualCryptographyGPU.o: ./source/VisualCryptographyGPU.cu
/usr/local/cuda/bin/nvcc -c -arch=compute_20 -code=sm_20 -lm ./source/VisualCryptographyGPU.cu
ExtVisualCryptographyCPU.o: ./source/ExtVisualCryptographyCPU.c
g++ -c ./source/ExtVisualCryptographyCPU.c
ExtVisualCryptographyGPU.o: ./source/ExtVisualCryptographyGPU.cu
/usr/local/cuda/bin/nvcc -c -arch=compute_20 -code=sm_20 -lm ./source/ExtVisualCryptographyGPU.cu
ExtVisualCryptographyMC.o: ./source/ExtVisualCryptographyMC.c
g++ -lpthread -c ./source/ExtVisualCryptographyMC.c
clean:
rm -rf *.o VisualCryptography
Here is my CMakeList.txt file:
cmake_minimum_required(VERSION 3.7)
project(VC)
set(CMAKE_CXX_STANDARD 11)
find_package (Threads)
find_package(CUDA REQUIRED)
link_directories(${CMAKE_BINARY_DIR}/lib)
set(SOURCE_FILES
source/common.h
source/ExtVisualCryptographyGPU.cu
source/ExtVisualCryptographyCPU.c
source/ExtVisualCryptographyMC.c
source/preprocess.h
source/VisualCryptographyCPUDefault.h
source/VisualCryptographyCPUTest.c
source/VisualCryptographyCPUTest.h
source/VisualCryptographyMC.c
source/VisualCryptographyGPU.cu
source/VisualCryptographyGPU.h
source/VisualCryptographyMC.h)
add_executable(VC ${SOURCE_FILES})
target_link_libraries(VC ${CMAKE_THREAD_LIBS_INIT} libVC.a)
Where am I doing wrong?
This is the error that I'm getting:
/usr/bin/ld: cannot find -lVC
collect2: error: ld returned 1 exit status
CMakeFiles/VC.dir/build.make:172: recipe for target 'VC' failed
make[3]: *** [VC] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/VC.dir/all' failed
make[2]: *** [CMakeFiles/VC.dir/all] Error 2
CMakeFiles/Makefile2:79: recipe for target 'CMakeFiles/VC.dir/rule' failed
make[1]: *** [CMakeFiles/VC.dir/rule] Error 2
Makefile:118: recipe for target 'VC' failed
make: *** [VC] Error 2
I also should note that the libVC.a is in lib sub dir of my project, and all other source codes are in source sub dir. the main function is also in libVC.a, which is static.
Try changing the name as oLen suggested, this behavior is seen in some versions of Cmake. You can check another version if you insist on using the same name.
Related
I am moving an already existing project from Atmel Studio 7.0 with arm-gnu toolchain to CMake with MinGW generator.
I have configured the CXX and C compiler flags as follows:
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-D__SAMD21G18A__ -DARM_MATH_CM0 -DF_CPU=48000000L -DARDUINO=10808 -DARDUINO_SAMD_ZERO -DARDUINO_ARCH_SAMD -DUSB_VID=0x239A -DUSB_PID=0x800B -DUSB_PRODUCT="\"Feather M0\"" -DUSB_MANUFACTURER="\"Adafruit\"" -DUSBCON -DDEBUG -DDEBUG_PRINT -DADAFRUIT_FONA_DEBUG -DMQTT_DEBUG -DMQTT_ERROR -ffunction-sections -fno-rtti -fno-exceptions -mlong-calls -Wall -Wa -mcpu=cortex-m0plus -std=gnu99")
set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} "-x c D__SAMD21G18A__ -DARM_MATH_CM0 -DF_CPU=48000000L -DARDUINO=10808 -DARDUINO_SAMD_ZERO -DARDUINO_ARCH_SAMD -DUSB_VID=0x239A -DUSB_PID=0x800B -DUSB_PRODUCT="\"Feather M0\"" -DUSB_MANUFACTURER="\"Adafruit\"" -DUSBCON -DDEBUG -DDEBUG_PRINT -DADAFRUIT_FONA_DEBUG -DMQTT_DEBUG -DMQTT_ERROR -ffunction-sections -mlong-calls -Wall -mcpu=cortex-m0plus -Wa-c -std=gnu99")
Here is the exact verbose command that generates the error.
:\svn\ATSAMD21_FLowTube_CMAKE\uart2lte\build --check-build-system CMakeFiles\Makefile.cmake 0
"C:\Program Files\CMake\bin\cmake.exe" -E cmake_progress_start C:\svn\ATSAMD21_FLowTube_CMAKE\uart2lte\build\CMakeFiles C:\svn\ATSAMD21_FLowTube_CMAKE\uart2lte\build\\CMakeFiles\progress.marks
C:/ProgramData/chocolatey/lib/make/tools/install/bin/make.exe -f CMakeFiles\Makefile2 all
make[1]: Entering directory 'C:/svn/ATSAMD21_FLowTube_CMAKE/uart2lte/build'
C:/ProgramData/chocolatey/lib/make/tools/install/bin/make.exe -f Library\CMakeFiles\Library.dir\build.make Library/CMakeFiles/Library.dir/depend
make[2]: Entering directory 'C:/svn/ATSAMD21_FLowTube_CMAKE/uart2lte/build'
"C:\Program Files\CMake\bin\cmake.exe" -E cmake_depends "MinGW Makefiles" C:\svn\ATSAMD21_FLowTube_CMAKE\uart2lte C:\svn\ATSAMD21_FLowTube_CMAKE\uart2lte\Library C:\svn\ATSAMD21_FLowTube_CMAKE\uart2lte\build C:\svn\ATSAMD21_FLowTube_CMAKE\uart2lte\build\Library C:\svn\ATSAMD21_FLowTube_CMAKE\uart2lte\build\Library\CMakeFiles\Library.dir\DependInfo.cmake --color=
make[2]: Leaving directory 'C:/svn/ATSAMD21_FLowTube_CMAKE/uart2lte/build'
C:/ProgramData/chocolatey/lib/make/tools/install/bin/make.exe -f Library\CMakeFiles\Library.dir\build.make Library/CMakeFiles/Library.dir/build
make[2]: Entering directory 'C:/svn/ATSAMD21_FLowTube_CMAKE/uart2lte/build'
[ 1%] Building CXX object Library/CMakeFiles/Library.dir/src/Adafruit_SleepyDog/utility/WatchdogSAMD.cpp.obj
cd /d C:\svn\ATSAMD21_FLowTube_CMAKE\uart2lte\build\Library && C:\MinGW\bin\g++.exe #CMakeFiles/Library.dir/includes_CXX.rsp -march=native -mno-avx -D__SAMD21G18A__ -DARM_MATH_CM0 -DF_CPU=48000000L -DARDUINO=10808 -DARDUINO_SAMD_ZERO -DARDUINO_ARCH_SAMD -DUSB_VID=0x239A -DUSB_PID=0x800B -DUSB_PRODUCT=;"Feather;M0"" -DUSB_MANUFACTURER=""Adafruit"" -DUSBCON -DDEBUG -DDEBUG_PRINT -DADAFRUIT_FONA_DEBUG -DMQTT_DEBUG -DMQTT_ERROR -ffunction-sections -fno-rtti -fno-exceptions -mlong-calls -Wall -Wa -mcpu=cortex-m0plus -std=gnu99" -o CMakeFiles\Library.dir\src\Adafruit_SleepyDog\utility\WatchdogSAMD.cpp.obj -c C:\svn\ATSAMD21_FLowTube_CMAKE\uart2lte\Library\src\Adafruit_SleepyDog\utility\WatchdogSAMD.cpp
C:\Users\rajusa\AppData\Local\Temp\ccAWF2FJ.s: Assembler messages:
C:\Users\rajusa\AppData\Local\Temp\ccAWF2FJ.s:47: Error: number of operands mismatch for `ds'
C:\Users\rajusa\AppData\Local\Temp\ccAWF2FJ.s:53: Error: no such instruction: `isb 0xF'
C:\Users\rajusa\AppData\Local\Temp\ccAWF2FJ.s:527: Error: number of operands mismatch for `ds'
C:\Users\rajusa\AppData\Local\Temp\ccAWF2FJ.s:533: Error: no such instruction: `wfi'
Any idea what might be the reason - in terms of toolchain - assembler ? Is there any way to specify assembler flags in CMake?
You're using MinGW GCC, which essentially targets Windows.
So I don't believe you can target other platforms..
What you need is a GCC compiler that runs on windows that supports the target platform(s) you need.
For Atmel ARM you can try something like this: http://winavr.sourceforge.net/ (though maybe something more recent may exist).
I have a problem with CMake: A static library and an executable are made but the build process is out of order. Thus, the library does not exist when the executable tries to link. I have read similar questions but did not find a solution. My project uses one root-CMakelists.txt that includes the other two:
Root: dev/CMakeLists.txt:
# Library project
include(${CMAKE_CURRENT_SOURCE_DIR}/src_lib/CMakeLists.txt)
# Client project
include(${CMAKE_CURRENT_SOURCE_DIR}/src_client/CMakeLists.txt)
Library: dev/src_lib/CMakeLists.txt
add_library(wof_static STATIC ${LIB_SRC})
TARGET_LINK_LIBRARIES(wof_static ${CMAKE_CURRENT_SOURCE_DIR}/3rdParty/lex/libs/amd64/libLexActivator.a pthread libnss3.so /usr/lib/x86_64-linux-gnu/libssl3.so /usr/lib/x86_64-linux-gnu/libnspr4.so )
Executable: dev/src_client/CMakeLists.txt
add_executable(wof ${CLIENT_SRC})
TARGET_LINK_LIBRARIES( wof
${CMAKE_CURRENT_SOURCE_DIR}/build/libwof_static.a
${CMAKE_CURRENT_SOURCE_DIR}/src_lib/3rdParty/lex/libs/amd64/libLexActivator.a
gmp
pthread
libnss3.so
/usr/lib/x86_64-linux-gnu/libssl3.so
/usr/lib/x86_64-linux-gnu/libnspr4.so
)
The above TARGET_LINK_LIBRARIES command uses the filename libwof_static.a, and thus, the build is out of order (i.e., it works only when I call make twice). Thus, I need to let CMake know that the executable depends on the library-target wof_static, right? I tried to do so:
Executable: dev/src_client/CMakeLists.txt (variant)
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/build/ ${CMAKE_CURRENT_SOURCE_DIR}/src_lib/3rdParty/lex/libs/amd64/)
add_executable(wof ${CLIENT_SRC})
TARGET_LINK_LIBRARIES( wof
wof_static
${CMAKE_CURRENT_SOURCE_DIR}/src_lib/3rdParty/lex/libs/amd64/libLexActivator.a
gmp
pthread
libnss3.so
/usr/lib/x86_64-linux-gnu/libssl3.so
/usr/lib/x86_64-linux-gnu/libnspr4.so
)
The intention of the above is to let CMake know the target name wof_static. That seems to work because the compilation of the executable wof starts when the library is ready. But I assumed that CMake would know and use the output file libwof_static.a of the target wof_static. This does not seem to be true. The error I get is:
[ 94%] Linking CXX static library libwof_static.a
/usr/local/bin/cmake -P CMakeFiles/wof_static.dir/cmake_clean_target.cmake
/usr/local/bin/cmake -E cmake_link_script CMakeFiles/wof_static.dir/link.txt --verbose=1
/usr/bin/ar qc libwof_static.a CMakeFiles/wof_static.dir/src_lib/AngleEntry.cpp.o CMakeFiles/wof_static.dir/src_lib/CEdge.cpp.o CMakeFiles/wof_static.dir/src_lib/CMesh.cpp.o CMakeFiles/wof_static.dir/src_lib/CPatch.cpp.o CMakeFiles/wof_static.dir/src_lib/CTriangle.cpp.o CMakeFiles/wof_static.dir/src_lib/Calc.cpp.o CMakeFiles/wof_static.dir/src_lib/Casx.cpp.o CMakeFiles/wof_static.dir/src_lib/Chain.cpp.o CMakeFiles/wof_static.dir/src_lib/ChainMgr.cpp.o CMakeFiles/wof_static.dir/src_lib/Cloud.cpp.o CMakeFiles/wof_static.dir/src_lib/CloudMgr.cpp.o CMakeFiles/wof_static.dir/src_lib/Hal.cpp.o CMakeFiles/wof_static.dir/src_lib/Histogram.cpp.o CMakeFiles/wof_static.dir/src_lib/HoleFiller.cpp.o CMakeFiles/wof_static.dir/src_lib/HoleToCCD.cpp.o CMakeFiles/wof_static.dir/src_lib/Inspector.cpp.o CMakeFiles/wof_static.dir/src_lib/Iso.cpp.o CMakeFiles/wof_static.dir/src_lib/IsoStore.cpp.o CMakeFiles/wof_static.dir/src_lib/LexSample.cpp.o CMakeFiles/wof_static.dir/src_lib/Loop.cpp.o CMakeFiles/wof_static.dir/src_lib/Performance.cpp.o CMakeFiles/wof_static.dir/src_lib/Pixel.cpp.o CMakeFiles/wof_static.dir/src_lib/Plane.cpp.o CMakeFiles/wof_static.dir/src_lib/Posix.cpp.o CMakeFiles/wof_static.dir/src_lib/Rotx.cpp.o CMakeFiles/wof_static.dir/src_lib/Segment3.cpp.o CMakeFiles/wof_static.dir/src_lib/Smooth.cpp.o CMakeFiles/wof_static.dir/src_lib/Surve.cpp.o CMakeFiles/wof_static.dir/src_lib/Top.cpp.o CMakeFiles/wof_static.dir/src_lib/TopMelt.cpp.o CMakeFiles/wof_static.dir/src_lib/Vector3.cpp.o CMakeFiles/wof_static.dir/src_lib/Visualizer3.cpp.o CMakeFiles/wof_static.dir/src_lib/Voro.cpp.o CMakeFiles/wof_static.dir/src_lib/Wof.cpp.o CMakeFiles/wof_static.dir/src_lib/WofMesh.cpp.o CMakeFiles/wof_static.dir/src_lib/api.cpp.o CMakeFiles/wof_static.dir/src_lib/api_io.cpp.o CMakeFiles/wof_static.dir/src_lib/devStuff.cpp.o CMakeFiles/wof_static.dir/src_lib/freeFunctions.cpp.o CMakeFiles/wof_static.dir/src_lib/geom_locate3/Node.cpp.o CMakeFiles/wof_static.dir/src_lib/geom_locate3/RTree.cpp.o CMakeFiles/wof_static.dir/src_lib/geom_octree/OctNode.cpp.o CMakeFiles/wof_static.dir/src_lib/geom_octree/Octree.cpp.o CMakeFiles/wof_static.dir/src_lib/geom_tools/GSS_HC2.cpp.o CMakeFiles/wof_static.dir/src_lib/geom_tools/GSS_HC3.cpp.o CMakeFiles/wof_static.dir/src_lib/testDataGenerators.cpp.o CMakeFiles/wof_static.dir/src_lib/tinyply.cpp.o CMakeFiles/wof_static.dir/src_lib/tools.cpp.o
/usr/bin/ranlib libwof_static.a
make[2]: Leaving directory '/home/geom/repoWOF/dev/build'
[ 94%] Built target wof_static
make -f CMakeFiles/wof.dir/build.make CMakeFiles/wof.dir/depend
make[2]: Entering directory '/home/geom/repoWOF/dev/build'
cd /home/geom/repoWOF/dev/build && /usr/local/bin/cmake -E cmake_depends "Unix Makefiles" /home/geom/repoWOF/dev /home/geom/repoWOF/dev /home/geom/repoWOF/dev/build /home/geom/repoWOF/dev/build /home/geom/repoWOF/dev/build/CMakeFiles/wof.dir/DependInfo.cmake --color=
make[2]: Leaving directory '/home/geom/repoWOF/dev/build'
make -f CMakeFiles/wof.dir/build.make CMakeFiles/wof.dir/build
make[2]: Entering directory '/home/geom/repoWOF/dev/build'
[ 96%] Building CXX object CMakeFiles/wof.dir/src_client/Params.cpp.o
[ 98%] Building CXX object CMakeFiles/wof.dir/src_client/main.cpp.o
make[2]: *** No rule to make target '../3rdParty/lex/libs/amd64/libLexActivator.a', needed by 'wof'. Stop.
make[2]: *** Waiting for unfinished jobs....
/usr/bin/c++ -I/home/geom/repoWOF/dev/include -O3 -DNDEBUG -std=c++11 -fstrict-aliasing -Wno-unused-local-typedefs -Wno-long-long -O3 -Wextra -Wunused -Wall -pedantic-errors -frounding-math -funroll-loops -Wl,-s -o CMakeFiles/wof.dir/src_client/Params.cpp.o -c /home/geom/repoWOF/dev/src_client/Params.cpp
/usr/bin/c++ -I/home/geom/repoWOF/dev/include -O3 -DNDEBUG -std=c++11 -fstrict-aliasing -Wno-unused-local-typedefs -Wno-long-long -O3 -Wextra -Wunused -Wall -pedantic-errors -frounding-math -funroll-loops -Wl,-s -o CMakeFiles/wof.dir/src_client/main.cpp.o -c /home/geom/repoWOF/dev/src_client/main.cpp
make[2]: Leaving directory '/home/geom/repoWOF/dev/build'
CMakeFiles/Makefile2:112: recipe for target 'CMakeFiles/wof.dir/all' failed
make[1]: *** [CMakeFiles/wof.dir/all] Error 2
make[1]: Leaving directory '/home/geom/repoWOF/dev/build'
Makefile:86: recipe for target 'all' failed
make: *** [all] Error 2
In your file dev/src_client/CMakeLists.txt, this line:
${CMAKE_CURRENT_SOURCE_DIR}/src_lib/3rdParty/lex/libs/amd64/libLexActivator.a
evaluates to the path:
dev/src_client/src_lib/3rdParty/lex/libs/amd64/libLexActivator.a
I don't think that is what you intend, as this path is different from the path you use in the dev/src_lib/CMakeLists.txt file.
Instead of CMAKE_CURRENT_SOURCE_DIR, use the CMake variable that points to the root source directory: CMAKE_SOURCE_DIR. Try something like this:
TARGET_LINK_LIBRARIES( wof
wof_static
${CMAKE_SOURCE_DIR}/src_lib/3rdParty/lex/libs/amd64/libLexActivator.a
gmp
pthread
libnss3.so
/usr/lib/x86_64-linux-gnu/libssl3.so
/usr/lib/x86_64-linux-gnu/libnspr4.so
)
I'm trying to build a project that includes log4c for the Jetson Nano. log4c is dependent on expat. expat has a CMakeLists.txt file and plays nicely with CMake. I'm having trouble telling log4c where the build output of expat lives to complete the link phase.
I have my main CMakeLists.txt file performing the following:
add_subdirectory(dependencies/libexpat/expat)
add_subdirectory(dependencies/libuuid-1.0.3)
add_subdirectory(dependencies/log4c-1.2.4)
expat builds with no issues. My CMakeLists.txt file for log4c is listed below:
# ------------------------------------------------------- MINIMUM CMAKE VERSION
cmake_minimum_required(VERSION 3.10)
include(ExternalProject)
# ---------------------------------------------------------------- PROJECT NAME
set(THIS log4c)
# ------------------------------------------------------------ EXTERNAL PROJECT
if("${BUILD_PLATFORM}" STREQUAL "nano")
set(HOST "--host=aarch64-linux-gnu")
endif()
file(GLOB_RECURSE SRC_FILES
${CMAKE_CURRENT_LIST_DIR}/*
)
file(TOUCH ${SRC_FILES})
ExternalProject_Add(${THIS}_build
SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}
CONFIGURE_COMMAND ${CMAKE_CURRENT_LIST_DIR}/configure --prefix=${CMAKE_INSTALL_PREFIX}/usr ${HOST}
BUILD_COMMAND make
DEPENDS expat)
#add_dependencies(${THIS}_build expat)
# --------------------------------------------------------------------- LIBRARY
add_library(${THIS} INTERFACE)
target_link_libraries(${THIS} INTERFACE ${CMAKE_INSTALL_PREFIX}/usr/lib/liblog4c.so)
target_include_directories(${THIS} INTERFACE ${CMAKE_INSTALL_PREFIX}/usr/include)
log4c configures and builds correctly, but it fails to link with the following error messages:
home/nlbutts/maza/vision2000/dependencies/log4c-1.2.4/src/log4c/rollingpolicy_type_sizewin.c: In function 'sizewin_rollover':
/home/nlbutts/maza/vision2000/dependencies/log4c-1.2.4/src/log4c/rollingpolicy_type_sizewin.c:116:14: warning: format '%s' expects argument of type 'char *', but argument 2 has type 'void *' [-Wformat=]
sd_error("rollingpolicy '%s' not yet configured (logdir,prefix etc.)",
^
/home/nlbutts/maza/vision2000/dependencies/log4c-1.2.4/src/log4c/rollingpolicy_type_sizewin.c: In function 'sizewin_init':
/home/nlbutts/maza/vision2000/dependencies/log4c-1.2.4/src/log4c/rollingpolicy_type_sizewin.c:227:12: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long int' [-Wformat=]
sd_debug("last index '%d'", swup->sw_last_index);
^
libtool: compile: aarch64-linux-gnu-gcc -DHAVE_CONFIG_H -I. -I/home/nlbutts/maza/vision2000/dependencies/log4c-1.2.4/src/log4c -I../../src -I/home/nlbutts/maza/vision2000/dependencies/log4c-1.2.4/src -DLOG4C_RCPATH=\"/home/nlbutts/maza/vision2000/build/nano/staging/usr/etc\" -g -O2 -Wall -MT rollingpolicy_type_sizewin.lo -MD -MP -MF .deps/rollingpolicy_type_sizewin.Tpo -c /home/nlbutts/maza/vision2000/dependencies/log4c-1.2.4/src/log4c/rollingpolicy_type_sizewin.c -o rollingpolicy_type_sizewin.o >/dev/null 2>&1
libtool: link: aarch64-linux-gnu-gcc -shared -fPIC -DPIC .libs/rc.o .libs/init.o .libs/appender_type_stream.o .libs/appender_type_stream2.o .libs/appender_type_syslog.o .libs/layout_type_basic.o .libs/layout_type_dated.o .libs/layout_type_dated_local.o .libs/layout_type_basic_r.o .libs/layout_type_dated_r.o .libs/layout_type_dated_local_r.o .libs/version.o .libs/logging_event.o .libs/priority.o .libs/appender.o .libs/layout.o .libs/category.o .libs/appender_type_rollingfile.o .libs/rollingpolicy.o .libs/rollingpolicy_type_sizewin.o -Wl,--whole-archive ../sd/.libs/liblog4c_sd.a -Wl,--no-whole-archive -lexpat -lpthread -O2 -Wl,-soname -Wl,liblog4c.so.3 -o .libs/liblog4c.so.3.3.1
/usr/lib/gcc-cross/aarch64-linux-gnu/5/../../../../aarch64-linux-gnu/bin/ld: cannot find -lexpat
collect2: error: ld returned 1 exit status
Makefile:480: recipe for target 'liblog4c.la' failed
make[7]: *** [liblog4c.la] Error 1
Makefile:436: recipe for target 'all-recursive' failed
make[6]: *** [all-recursive] Error 1
Makefile:353: recipe for target 'all' failed
make[5]: *** [all] Error 2
Makefile:602: recipe for target 'all-recursive' failed
make[4]: *** [all-recursive] Error 1
Makefile:399: recipe for target 'all' failed
make[3]: *** [all] Error 2
dependencies/log4c-1.2.4/CMakeFiles/log4c_build.dir/build.make:111: recipe for target 'dependencies/log4c-1.2.4/log4c_build-prefix/src/log4c_build-stamp/log4c_build-build' failed
make[2]: *** [dependencies/log4c-1.2.4/log4c_build-prefix/src/log4c_build-stamp/log4c_build-build] Error 2
CMakeFiles/Makefile2:395: recipe for target 'dependencies/log4c-1.2.4/CMakeFiles/log4c_build.dir/all' failed
make[1]: *** [dependencies/log4c-1.2.4/CMakeFiles/log4c_build.dir/all] Error 2
Makefile:129: recipe for target 'all' failed
make: *** [all] Error 2
How do I tell log4c where expat was built at.
I get the source code of percona-server from github. And I install boost 1.59 and gcc gcc-c ncurses-devel. I enter the directory of percona-server and run "cmake --DWITH_BOOST=/data/boost" but get the following error. I cannot find some solution so I came to here. Thanks!!
-- Performing Test HAVE_UNUSED_PARAMETER - Success
-- Googletest was not found. gtest-based unit tests will be disabled. You can run cmake . -DENABLE_DOWNLOADS=1 to automatically download and build required components from source.
-- If you are inside a firewall, you may need to use an https proxy: export https_proxy=http://example.com:80
-- Performing Test HAVE_MISLEADING_INDENTATION
-- Performing Test HAVE_MISLEADING_INDENTATION - Failed
-- executable target mysqld debug_target /home/teg/Downloads/debug/sql/mysqld
-- Library mysqlserver depends on OSLIBS -lpthread;/usr/lib64/libz.so;m;rt;crypt;dl;aio;numa
-- MERGE_CONVENIENCE_LIBRARIES TARGET mysqlserver
-- MERGE_CONVENIENCE_LIBRARIES LIBS dbug;strings;regex;mysys;mysys_ssl;vio;/usr/lib64/libz.so;yassl;taocrypt;crypt;dl;archive_embedded;b lackhole_embedded;csv_embedded;federated_embedded; heap_embedded;innobase_embedded;lz4_lib;numa;myisa m_embedded;myisammrg_embedded;partition_embedded;n gram_parser_embedded;sql_embedded
-- MERGE_CONVENIENCE_LIBRARIES MYLIBS dbug;strings;regex;mysys;mysys_ssl;vio;yassl;taocr ypt;archive_embedded;blackhole_embedded;csv_embedd ed;federated_embedded;heap_embedded;innobase_embed ded;lz4_lib;myisam_embedded;myisammrg_embedded;par tition_embedded;ngram_parser_embedded;sql_embedded
-- library target mysqlserver debug_target /home/teg/Downloads/debug/archive_output_directory/libmysqld.a
-- INSTALL perconaserverclient.pc lib/pkgconfig
-- Skipping deb packaging on unsupported platform Core.
-- CMAKE_BUILD_TYPE: RelWithDebInfo
-- COMPILE_DEFINITIONS: _GNU_SOURCE;_FILE_OFFSET_BITS=64;HAVE_CONFIG_H;HAV E_LIBEVENT1
-- CMAKE_C_FLAGS: -Wall -Wextra -Wformat-security -Wvla -Wwrite-strings -Wdeclaration-after-statement
-- CMAKE_CXX_FLAGS: -std=gnu++03 -Wall -Wextra -Wformat-security -Wvla -Woverloaded-virtual -Wno-unused-parameter
-- CMAKE_C_LINK_FLAGS:
-- CMAKE_CXX_LINK_FLAGS:
-- CMAKE_C_FLAGS_RELWITHDEBINFO: -O3 -D_FORTIFY_SOURCE=2 -g -fabi-version=2 -fno-omit-frame-pointer -fno-strict-aliasing -DDBUG_OFF -DNDEBUG
-- CMAKE_CXX_FLAGS_RELWITHDEBINFO: -O3 -D_FORTIFY_SOURCE=2 -g -fabi-version=2 -fno-omit-frame-pointer -fno-strict-aliasing -DDBUG_OFF -DNDEBUG
-- Configuring incomplete, errors occurred!
See also "/home/teg/Downloads/percona-server-5.7/CMakeFiles/CMakeOutput.log".
See also "/home/teg/Downloads/percona-server-5.7/CMakeFiles/CMakeError.log".
.................................................. .........................
And I open the /home/teg/Downloads/percona-server-5.7/CMakeFiles/CMakeError.log and find the following errors. There are too many errors and I only list part of it.
Run Build Command:/usr/bin/gmake "cmTryCompileExec1295500228/fast"
/usr/bin/gmake -f CMakeFiles/cmTryCompileExec1295500228.dir/build.make CMakeFiles/cmTryCompileExec1295500228.dir/build
gmake[1]: Entering directory `/home/teg/Downloads/percona-server-5.7/CMakeFiles/CMakeTmp'
/usr/bin/cmake -E cmake_progress_report /home/teg/Downloads/percona-server-5.7/CMakeFiles/CMakeTmp/CMakeFiles 1
Building C object CMakeFiles/cmTryCompileExec1295500228.dir/CheckSymbolExists.c.o
/usr/bin/cc -o CMakeFiles/cmTryCompileExec1295500228.dir/CheckSymbolExists.c.o -c /home/teg/Downloads/percona-server-5.7/CMakeFiles/CMakeTmp/CheckSymbolExists.c
Linking C executable cmTryCompileExec1295500228
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTryCompileExec1295500228.dir/link.txt --verbose=1
/usr/bin/cc CMakeFiles/cmTryCompileExec1295500228.dir/CheckSymbolExists.c.o -o cmTryCompileExec1295500228 -rdynamic
CMakeFiles/cmTryCompileExec1295500228.dir/CheckSymbolExists.c.o: In function `main':
CheckSymbolExists.c.text+0x16): undefined reference to `pthread_create'
collect2: error: ld returned 1 exit status
gmake[1]: Leaving directory `/home/teg/Downloads/percona-server-5.7/CMakeFiles/CMakeTmp'
gmake[1]: *** [cmTryCompileExec1295500228] Error 1
gmake: *** [cmTryCompileExec1295500228/fast] Error 2
File /home/teg/Downloads/percona-server-5.7/CMakeFiles/CMakeTmp/CheckSymbolExists.c:
Run Build Command:/usr/bin/gmake "cmTryCompileExec1916958743/fast"
/usr/bin/gmake -f CMakeFiles/cmTryCompileExec1916958743.dir/build.make CMakeFiles/cmTryCompileExec1916958743.dir/build
gmake[1]: Entering directory `/home/teg/Downloads/percona-server-5.7/CMakeFiles/CMakeTmp'
/usr/bin/cmake -E cmake_progress_report /home/teg/Downloads/percona-server-5.7/CMakeFiles/CMakeTmp/CMakeFiles 1
Building C object CMakeFiles/cmTryCompileExec1916958743.dir/CheckFunctionExists.c.o
/usr/bin/cc -DCHECK_FUNCTION_EXISTS=pthread_create -o CMakeFiles/cmTryCompileExec1916958743.dir/CheckFunctionExists.c.o -c /usr/share/cmake/Modules/CheckFunctionExists.c
Linking C executable cmTryCompileExec1916958743
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTryCompileExec1916958743.dir/link.txt --verbose=1
/usr/bin/cc -DCHECK_FUNCTION_EXISTS=pthread_create CMakeFiles/cmTryCompileExec1916958743.dir/CheckFunctionExists.c.o -o cmTryCompileExec1916958743 -rdynamic -lpthreads
/usr/bin/ld: cannot find -lpthreads
collect2: error: ld returned 1 exit status
gmake[1]: Leaving directory `/home/teg/Downloads/percona-server-5.7/CMakeFiles/CMakeTmp'
gmake[1]: *** [cmTryCompileExec1916958743] Error 1
gmake: *** [cmTryCompileExec1916958743/fast] Error 2
Determining if the function floor exists failed with the following output:
Change Dir: /home/teg/Downloads/percona-server-5.7/CMakeFiles/CMakeTmp
Run Build Command:/usr/bin/gmake "cmTryCompileExec1596718479/fast"
/usr/bin/gmake -f CMakeFiles/cmTryCompileExec1596718479.dir/build.make CMakeFiles/cmTryCompileExec1596718479.dir/build
gmake[1]: Entering directory `/home/teg/Downloads/percona-server-5.7/CMakeFiles/CMakeTmp'
/usr/bin/cmake -E cmake_progress_report /home/teg/Downloads/percona-server-5.7/CMakeFiles/CMakeTmp/CMakeFiles 1
Building C object CMakeFiles/cmTryCompileExec1596718479.dir/CheckFunctionExists.c.o
/usr/bin/cc -DCHECK_FUNCTION_EXISTS=floor -o CMakeFiles/cmTryCompileExec1596718479.dir/CheckFunctionExists.c.o -c /usr/share/cmake/Modules/CheckFunctionExists.c
<command-line>:0:23: warning: conflicting types for built-in function ‘floor’ [enabled by default]
/usr/share/cmake/Modules/CheckFunctionExists.c:3:6: note: in expansion of macro ‘CHECK_FUNCTION_EXISTS’
char CHECK_FUNCTION_EXISTS();
^
Linking C executable cmTryCompileExec1596718479
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTryCompileExec1596718479.dir/link.txt --verbose=1
/usr/bin/cc -DCHECK_FUNCTION_EXISTS=floor CMakeFiles/cmTryCompileExec1596718479.dir/CheckFunctionExists.c.o -o cmTryCompileExec1596718479 -rdynamic
CMakeFiles/cmTryCompileExec1596718479.dir/CheckFunctionExists.c.o: In function `main':
CheckFunctionExists.c.text+0x15): undefined reference to `floor'
collect2: error: ld returned 1 exit status
gmake[1]: Leaving directory `/home/teg/Downloads/percona-server-5.7/CMakeFiles/CMakeTmp'
gmake[1]: *** [cmTryCompileExec1596718479] Error 1
gmake: *** [cmTryCompileExec1596718479/fast] Error 2
it seems you haven't all needed dependencies installed.
These are the steps which are needed:
sudo yum install epel-release
sudo yum install git gcc gcc-c++ openssl check cmake bison boost-devel asio-devel
libaio-devel ncurses-devel readline-devel pam-devel wget perl-Env time numactl-devel
rpmdevtools rpm-build curl-devel
git clone https://github.com/percona/percona-server.git
cd percona-server
git submodule init
git submodule update
cmake . -DDOWNLOAD_BOOST=1 -DWITH_BOOST=<PATCH_TO_BOOST_DIR>
Then boost will be downloaded automatically
I am trying to compile a Fortran program using CMake on an IBM BlueGene machine. This is my source:
> tree
.
├── CMakeLists.txt
└── src
└── test1.f90
where test1.f90 simply is:
program main
use mpi
integer :: me, ierr
call MPI_Init(ierr)
call MPI_Comm_rank(MPI_COMM_WORLD, me, ierr)
write (*,"(I4,A)") me, ": hello"
call MPI_Finalize(ierr)
end program main
I would like to create a static executable. Therefore I created this CMakeLists.txt:
cmake_minimum_required(VERSION 2.5)
project(STB)
file(GLOB_RECURSE sources src/*.f90)
SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
SET(BUILD_SHARED_LIBRARIES OFF)
SET(CMAKE_EXE_LINKER_FLAGS "-static")
add_executable(test.x ${sources})
enable_language(Fortran)
set(CMAKE_Fortran_COMPILER_ID "IBM")
if(CMAKE_Fortran_COMPILER_ID MATCHES "IBM")
MESSAGE(STATUS "IBM")
set(CMAKE_Fortran_COMPILER mpixlf2008)
set(dialect "-O2 -qarch=qp -qtune=qp -ufmt_littleendian={23}")
set(debug "-C")
endif()
set(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG} ${bounds}")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${dialect}")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
MESSAGE( STATUS "cmake_module_path: " ${CMAKE_MODULE_PATH})
this results in:
make VERBOSE=1
/usr/bin/cmake -H/work/jias12/jias1217/test -B/work/jias12/jias1217/test --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start /work/jias12/jias1217/test/CMakeFiles /work/jias12/jias1217/test/CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory `/work/jias12/jias1217/test'
make -f CMakeFiles/test.x.dir/build.make CMakeFiles/test.x.dir/depend
make[2]: Entering directory `/work/jias12/jias1217/test'
cd /work/jias12/jias1217/test && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /work/jias12/jias1217/test /work/jias12/jias1217/test /work/jias12/jias1217/test /work/jias12/jias1217/test /work/jias12/jias1217/test/CMakeFiles/test.x.dir/DependInfo.cmake --color=
make[2]: Leaving directory `/work/jias12/jias1217/test'
make -f CMakeFiles/test.x.dir/build.make CMakeFiles/test.x.dir/requires
make[2]: Entering directory `/work/jias12/jias1217/test'
make[2]: Nothing to be done for `CMakeFiles/test.x.dir/requires'.
make[2]: Leaving directory `/work/jias12/jias1217/test'
make -f CMakeFiles/test.x.dir/build.make CMakeFiles/test.x.dir/build
make[2]: Entering directory `/work/jias12/jias1217/test'
/usr/bin/cmake -E cmake_progress_report /work/jias12/jias1217/test/CMakeFiles 1
[100%] Building Fortran object CMakeFiles/test.x.dir/src/test1.o
mpixlf2008 -O2 -qarch=qp -qtune=qp -ufmt_littleendian={23} -c /work/jias12/jias1217/test/src/test1.f90 -o CMakeFiles/test.x.dir/src/test1.o
** main === End of Compilation 1 ===
1501-510 Compilation successful for file test1.f90.
Linking Fortran executable test.x
/usr/bin/cmake -E cmake_link_script CMakeFiles/test.x.dir/link.txt --verbose=1
mpixlf2008 -static -O2 -qarch=qp -qtune=qp -ufmt_littleendian={23} CMakeFiles/test.x.dir/src/test1.o -o test.x -rdynamic
/opt/ibmcmp/xlf/bg/14.1/bin/.orig/bgxlf2008: 1501-210 (S) command option ynamic contains an incorrect subargument
make[2]: *** [test.x] Error 40
make[2]: Leaving directory `/work/jias12/jias1217/test'
make[1]: *** [CMakeFiles/test.x.dir/all] Error 2
make[1]: Leaving directory `/work/jias12/jias1217/test'
make: *** [all] Error 2
If I rerun the last argument without the -rdynamic
mpixlf2008 -static -O2 -qarch=qp -qtune=qp -ufmt_littleendian={23} CMakeFiles/test.x.dir/src/test1.o -o test.x
I get the error:
/bgsys/drivers/ppcfloor/gnu-linux/powerpc64-bgq-linux/bin/ld: -f may not be used without -shared
How can I compile my program using statically using CMake? If I simply run:
mpixlf2008 -c src/test1.f90
mpixlf2008 test1.o -o bla.x
The compilation works fine and the size(45M) suggest, that it's compiled statically.
Edit:
If I remove the little endian flag:
set(dialect "-O2 -qarch=qp -qtune=qp")
I can run the cmake created makefile and then manually remove the -rdynamic
mpixlf2008 -static -O2 -qarch=qp -qtune=qp CMakeFiles/test.x.dir/src/test1.o -o test.x
Which then successfully compiles. How can I remove the -rdynamic from the CMake Makefile?
Try adding -qstaticlink to your link line instead of adding -static / -rdynamic directly. When you use the mpixlf2008 command, the compiler inserts its own -static / -rdynamic options to link in its own libraries, so the options you added are probably interfering with the ones the compiler is using. The -qstaticlink option tells the compiler you want a completely static binary. The option also has suboptions that would allow you to only statically link the gcc libraries.
Also, the specific error you're getting is because you specified "-rdynamic". XLF doesn't know this option, so it assumes it's a grouping of smaller options. So it parses it as: "-r -d -ynamic". -r is for creating a nonexecutable output file, -d is for saving preprocessed output, -y is for specifying compile-time rounding mode. The -y option takes a suboption for the rounding mode, e.g. -yn for nearest. The error you're getting is that namic is not a known suboption of -y. To pass -rdynamic to the linker, put -Wl, before it. i.e. "-Wl,-rdynamic".
Adding
set(CMAKE_SHARED_LIBRARY_LINK_Fortran_FLAGS)
allows me to remove the '-rdynamic'. This might be a bit manual, but for older CMake versions it works.