Percona5.7 cmake failed on centos 7 - cmake

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

Related

Errors in p4est and cmake when install dealii

Can anyone help me with this issue?
In order to use dealii, I tried to install p4est using the command
./configure && make && make install
and
cmake .. -DP4EST_DIR=/usr/local -DDEAL_II_WITH_P4EST=ON -DDEAL_II_WITH_MPI=ON -DCMAKE_INSTALL_PREFIX=/usr/local
under "build" folder, but some error occurs.
I also opened the file dealii-9.0.0/build/CMakeFiles/CMakeError.log, it says:
Source file was:
int main() { return 0; }
Performing C++ SOURCE FILE Test rt_LIBRARY failed with the following output:
Change Dir: /Users/chuxiaoyun/Downloads/dealii-9.0.0/build/CMakeFiles/CMakeScratch/TryCompile-Fscvq9
Run Build Command(s):/usr/bin/make -f Makefile cmTC_bc7f9/fast && /Applications/Xcode.app/Contents/Developer/usr/bin/make -f CMakeFiles/cmTC_bc7f9.dir/build.make CMakeFiles/cmTC_bc7f9.dir/build
Building CXX object CMakeFiles/cmTC_bc7f9.dir/src.cxx.o
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -Drt_LIBRARY -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk -mmacosx-version-min=11.6 -MD -MT CMakeFiles/cmTC_bc7f9.dir/src.cxx.o -MF CMakeFiles/cmTC_bc7f9.dir/src.cxx.o.d -o CMakeFiles/cmTC_bc7f9.dir/src.cxx.o -c /Users/chuxiaoyun/Downloads/dealii-9.0.0/build/CMakeFiles/CMakeScratch/TryCompile-Fscvq9/src.cxx
Linking CXX executable cmTC_bc7f9
/opt/homebrew/Cellar/cmake/3.25.0/bin/cmake -E cmake_link_script CMakeFiles/cmTC_bc7f9.dir/link.txt --verbose=1
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk -mmacosx-version-min=11.6 -Wl,-search_paths_first -Wl,-headerpad_max_install_names CMakeFiles/cmTC_bc7f9.dir/src.cxx.o -o cmTC_bc7f9 -lrt
ld: library not found for -lrt
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [cmTC_bc7f9] Error 1
make: *** [cmTC_bc7f9/fast] Error 2
CMake Error at cmake/macros/macro_configure_feature.cmake:112 (MESSAGE):
Could not find the p4est library!
Insufficient p4est installation found!
p4est has to be configured with MPI enabled.
Please ensure that a suitable p4est library is installed on your computer.
If the library is not at a default location, either provide some hints for
autodetection,
$ P4EST_DIR="..." cmake <...>
$ cmake -DP4EST_DIR="..." <...>
or set the relevant variables by hand in ccmake.
Call Stack (most recent call first):
cmake/macros/macro_configure_feature.cmake:269 (FEATURE_ERROR_MESSAGE)
cmake/configure/configure_p4est.cmake:78 (CONFIGURE_FEATURE)
cmake/macros/macro_verbose_include.cmake:19 (INCLUDE)
CMakeLists.txt:124 (VERBOSE_INCLUDE)
I guess I haven't installed p4est correctly, so I configure it again.
# p4est-2.8 ./configure --enable-mpi.
( Here shows we are using MPI. I also tried p4est-2.8 ./configure --enable-mpi --prefix=/usr/local)
Then I tried to build and install p4est, but it gives me an error during installation:
# make
# ➜ p4est-2.8 make install
/Applications/Xcode.app/Contents/Developer/usr/bin/make install-recursive
Making install in sc
/Applications/Xcode.app/Contents/Developer/usr/bin/make install-am
build-aux/install-sh -c -d '/Users/xiaoyun/Downloads/p4est-2.8/local/lib'
/bin/sh ./libtool --mode=install /usr/bin/install -c src/libsc.la '/Users/xiaoyun/Downloads/p4est-2.8/local/lib'
libtool: install: /usr/bin/install -c src/.libs/libsc.0.dylib /Users/xiaoyun/Downloads/p4est-2.8/local/lib/libsc.0.dylib
install: /Users/xiaoyun/Downloads/p4est-2.8/local/lib/libsc.0.dylib: Permission denied
make[4]: *** [install-libLTLIBRARIES] Error 71
make[3]: *** [install-am] Error 2
make[2]: *** [install] Error 2
make[1]: *** [install-recursive] Error 1
I have no idea why the permission is denied, I also tried sudo make install:
objc[71909]: Class AMSupportURLConnectionDelegate is implemented in both /usr/lib/libauthinstall.dylib (0x20230f7e8) and /System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x10c9082c8). One of the two will be used. Which one is undefined.
objc[71909]: Class AMSupportURLSession is implemented in both /usr/lib/libauthinstall.dylib (0x20230f838) and /System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x10c908318). One of the two will be used. Which one is undefined.
shell-init: error retrieving current directory: getcwd: cannot access parent directories: Operation not permitted
job-working-directory: error retrieving current directory: getcwd: cannot access parent directories: Operation not permitted
make: getcwd: Operation not permitted
make: Nothing to be done for `install'.

CMake failed to link static CUDA library

I create a static library following an Nvidia example
Here is my CMakeLists.txt file
cmake_minimum_required(VERSION 3.8 FATAL_ERROR)
set(CMAKE_VERBOSE_MAKEFILE TRUE CACHE BOOL "")
set(CMAKE_CUDA_COMPILER "/usr/local/cuda/bin/nvcc" CACHE FILEPATH "")
set(CMAKE_CUDA_HOST_COMPILER "/opt/qos2.1.1-build4288/host/linux/x86_64/usr/bin/aarch64-unknown-nto-qnx7.0.0-gcc" CACHE FILEPATH "")
project(cmake_and_cuda LANGUAGES CUDA CXX)
add_library(particles STATIC
randomize.cpp
randomize.h
particle.cu
particle.h
v3.cu
v3.h
calc.h
calc.cu
)
target_link_libraries(particles PRIVATE stdc++)
set_target_properties(particles PROPERTIES LANGUAGE CUDA)
set_target_properties(particles PROPERTIES LINKER_LANGUAGE CUDA)
target_compile_options(particles PRIVATE $<$<COMPILE_LANGUAGE:CUDA>: "--std=c++11" >)
set_target_properties(particles PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
# build executable
add_executable(particle_test main.cpp)
set_target_properties(particle_test PROPERTIES LANGUAGE CXX)
set_target_properties(particle_test PROPERTIES LINKER_LANGUAGE CXX)
target_link_libraries(particle_test PRIVATE particles)
The build is successful. Here is the build log:
jenkins#ubuntu:~/git_repos/test/test_gpu/build$ make
/usr/bin/cmake -H/home/jenkins/git_repos/test/test_gpu -B/home/jenkins/git_repos/test/test_gpu/build --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start /home/jenkins/git_repos/test/test_gpu/build/CMakeFiles /home/jenkins/git_repos/test/test_gpu/build/CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory '/home/jenkins/git_repos/test/test_gpu/build'
make -f CMakeFiles/particles.dir/build.make CMakeFiles/particles.dir/depend
make[2]: Entering directory '/home/jenkins/git_repos/test/test_gpu/build'
cd /home/jenkins/git_repos/test/test_gpu/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/jenkins/git_repos/test/test_gpu /home/jenkins/git_repos/test/test_gpu /home/jenkins/git_repos/test/test_gpu/build /home/jenkins/git_repos/test/test_gpu/build /home/jenkins/git_repos/test/test_gpu/build/CMakeFiles/particles.dir/DependInfo.cmake --color=
Scanning dependencies of target particles
make[2]: Leaving directory '/home/jenkins/git_repos/test/test_gpu/build'
make -f CMakeFiles/particles.dir/build.make CMakeFiles/particles.dir/build
make[2]: Entering directory '/home/jenkins/git_repos/test/test_gpu/build'
[ 12%] Building CXX object CMakeFiles/particles.dir/randomize.cpp.o
/opt/qos2.1.1-build4288/host/linux/x86_64/usr/bin/ntoaarch64-g++ -o CMakeFiles/particles.dir/randomize.cpp.o -c /home/jenkins/git_repos/test/test_gpu/randomize.cpp
[ 25%] Building CUDA object CMakeFiles/particles.dir/particle.cu.o
/usr/local/cuda/bin/nvcc -ccbin=/opt/qos2.1.1-build4288/host/linux/x86_64/usr/bin/aarch64-unknown-nto-qnx7.0.0-gcc --std=c++11 -x cu -dc /home/jenkins/git_repos/test/test_gpu/particle.cu -o CMakeFiles/particles.dir/particle.cu.o
[ 37%] Building CUDA object CMakeFiles/particles.dir/v3.cu.o
/usr/local/cuda/bin/nvcc -ccbin=/opt/qos2.1.1-build4288/host/linux/x86_64/usr/bin/aarch64-unknown-nto-qnx7.0.0-gcc --std=c++11 -x cu -dc /home/jenkins/git_repos/test/test_gpu/v3.cu -o CMakeFiles/particles.dir/v3.cu.o
[ 50%] Building CUDA object CMakeFiles/particles.dir/calc.cu.o
/usr/local/cuda/bin/nvcc -ccbin=/opt/qos2.1.1-build4288/host/linux/x86_64/usr/bin/aarch64-unknown-nto-qnx7.0.0-gcc --std=c++11 -x cu -dc /home/jenkins/git_repos/test/test_gpu/calc.cu -o CMakeFiles/particles.dir/calc.cu.o
[ 62%] Linking CUDA static library libparticles.a
/usr/bin/cmake -P CMakeFiles/particles.dir/cmake_clean_target.cmake
/usr/bin/cmake -E cmake_link_script CMakeFiles/particles.dir/link.txt --verbose=1
/usr/bin/ar qc libparticles.a CMakeFiles/particles.dir/randomize.cpp.o CMakeFiles/particles.dir/particle.cu.o CMakeFiles/particles.dir/v3.cu.o CMakeFiles/particles.dir/calc.cu.o
/usr/bin/ranlib libparticles.a
make[2]: Leaving directory '/home/jenkins/git_repos/test/test_gpu/build'
[ 62%] Built target particles
make -f CMakeFiles/particle_test.dir/build.make CMakeFiles/particle_test.dir/depend
make[2]: Entering directory '/home/jenkins/git_repos/test/test_gpu/build'
cd /home/jenkins/git_repos/test/test_gpu/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/jenkins/git_repos/test/test_gpu /home/jenkins/git_repos/test/test_gpu /home/jenkins/git_repos/test/test_gpu/build /home/jenkins/git_repos/test/test_gpu/build /home/jenkins/git_repos/test/test_gpu/build/CMakeFiles/particle_test.dir/DependInfo.cmake --color=
Scanning dependencies of target particle_test
make[2]: Leaving directory '/home/jenkins/git_repos/test/test_gpu/build'
make -f CMakeFiles/particle_test.dir/build.make CMakeFiles/particle_test.dir/build
make[2]: Entering directory '/home/jenkins/git_repos/test/test_gpu/build'
[ 75%] Building CXX object CMakeFiles/particle_test.dir/main.cpp.o
/opt/qos2.1.1-build4288/host/linux/x86_64/usr/bin/ntoaarch64-g++ -o CMakeFiles/particle_test.dir/main.cpp.o -c /home/jenkins/git_repos/test/test_gpu/main.cpp
[ 87%] Linking CUDA device code CMakeFiles/particle_test.dir/cmake_device_link.o
/usr/bin/cmake -E cmake_link_script CMakeFiles/particle_test.dir/dlink.txt --verbose=1
/usr/local/cuda/bin/nvcc -ccbin=/opt/qos2.1.1-build4288/host/linux/x86_64/usr/bin/aarch64-unknown-nto-qnx7.0.0-gcc -Xcompiler=-fPIC -Wno-deprecated-gpu-targets -shared -dlink CMakeFiles/particle_test.dir/main.cpp.o -o CMakeFiles/particle_test.dir/cmake_device_link.o -L/usr/local/cuda/targets/aarch64-qnx/lib/stubs -L/usr/local/cuda/targets/aarch64-qnx/lib libparticles.a
[100%] Linking CXX executable particle_test
/usr/bin/cmake -E cmake_link_script CMakeFiles/particle_test.dir/link.txt --verbose=1
/opt/qos2.1.1-build4288/host/linux/x86_64/usr/bin/ntoaarch64-g++ CMakeFiles/particle_test.dir/main.cpp.o CMakeFiles/particle_test.dir/cmake_device_link.o -o particle_test -L/usr/local/cuda/targets/aarch64-qnx/lib/stubs -L/usr/local/cuda/targets/aarch64-qnx/lib libparticles.a -lstdc++ -lcudadevrt -lcudart_static
make[2]: Leaving directory '/home/jenkins/git_repos/test/test_gpu/build'
[100%] Built target particle_test
However, if I want to export libparticles.a and uses it in another project, it does not work.
target_link_libraries(another_project PRIVATE ${CMAKE_SOURCE_DIR}/libparticles.a)
The error log:
jenkins#ubuntu:~/git_repos/test/test_gpu/build$ make
/usr/bin/cmake -H/home/jenkins/git_repos/test/test_gpu -B/home/jenkins/git_repos/test/test_gpu/build --check-build-system CMakeFiles/Makefile.cmake 0
-- Configuring done
-- Generating done
-- Build files have been written to: /home/jenkins/git_repos/test/test_gpu/build
/usr/bin/cmake -E cmake_progress_start /home/jenkins/git_repos/test/test_gpu/build/CMakeFiles /home/jenkins/git_repos/test/test_gpu/build/CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory '/home/jenkins/git_repos/test/test_gpu/build'
make -f CMakeFiles/another_project.dir/build.make CMakeFiles/another_project.dir/depend
make[2]: Entering directory '/home/jenkins/git_repos/test/test_gpu/build'
cd /home/jenkins/git_repos/test/test_gpu/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/jenkins/git_repos/test/test_gpu /home/jenkins/git_repos/test/test_gpu /home/jenkins/git_repos/test/test_gpu/build /home/jenkins/git_repos/test/test_gpu/build /home/jenkins/git_repos/test/test_gpu/build/CMakeFiles/another_project.dir/DependInfo.cmake --color=
Scanning dependencies of target another_project
make[2]: Leaving directory '/home/jenkins/git_repos/test/test_gpu/build'
make -f CMakeFiles/particle_test.dir/build.make CMakeFiles/another_project.dir/build
make[2]: Entering directory '/home/jenkins/git_repos/test/test_gpu/build'
[ 50%] Linking CXX executable particle_test
/usr/bin/cmake -E cmake_link_script CMakeFiles/another_project.dir/link.txt --verbose=1
/opt/qos2.1.1-build4288/host/linux/x86_64/usr/bin/ntoaarch64-g++ CMakeFiles/another_project.dir/main.cpp.o -o another_project ../libparticles.a
../libparticles.a(calc.cu.o): In function `calc::calc_func()':
tmpxft_00036041_00000000-5_calc.cudafe1.cpp:(.text+0x58): undefined reference to `cudaGetLastError'
tmpxft_00036041_00000000-5_calc.cudafe1.cpp:(.text+0x70): undefined reference to `cudaGetErrorString'
tmpxft_00036041_00000000-5_calc.cudafe1.cpp:(.text+0x104): undefined reference to `cudaDeviceSynchronize'
tmpxft_00036041_00000000-5_calc.cudafe1.cpp:(.text+0x108): undefined reference to `cudaGetLastError'
tmpxft_00036041_00000000-5_calc.cudafe1.cpp:(.text+0x120): undefined reference to `cudaGetErrorString'
tmpxft_00036041_00000000-5_calc.cudafe1.cpp:(.text+0x15c): undefined reference to `cudaMemcpy'
tmpxft_00036041_00000000-5_calc.cudafe1.cpp:(.text+0x160): undefined reference to `cudaDeviceSynchronize'
tmpxft_00036041_00000000-5_calc.cudafe1.cpp:(.text+0x164): undefined reference to `cudaGetLastError'
tmpxft_00036041_00000000-5_calc.cudafe1.cpp:(.text+0x17c): undefined reference to `cudaGetErrorString'
tmpxft_00036041_00000000-5_calc.cudafe1.cpp:(.text+0x210): undefined reference to `__cudaPushCallConfiguration'
tmpxft_00036041_00000000-5_calc.cudafe1.cpp:(.text+0x22c): undefined reference to `cudaGetLastError'
tmpxft_00036041_00000000-5_calc.cudafe1.cpp:(.text+0x244): undefined reference to `cudaGetErrorString'
tmpxft_00036041_00000000-5_calc.cudafe1.cpp:(.text+0x25c): undefined reference to `cudaDeviceSynchronize'
tmpxft_00036041_00000000-5_calc.cudafe1.cpp:(.text+0x294): undefined reference to `cudaMemcpy'
../libparticles.a(calc.cu.o): In function `__cudaUnregisterBinaryUtil()':
tmpxft_00036041_00000000-5_calc.cudafe1.cpp:(.text+0x480): undefined reference to `__cudaUnregisterFatBinary'
../libparticles.a(calc.cu.o): In function `__nv_init_managed_rt_with_module(void**)':
tmpxft_00036041_00000000-5_calc.cudafe1.cpp:(.text+0x4a0): undefined reference to `__cudaInitModule'
../libparticles.a(calc.cu.o): In function `__device_stub__Z16advanceParticlesfP8particlei(float, particle*, int)':
tmpxft_00036041_00000000-5_calc.cudafe1.cpp:(.text+0x5bc): undefined reference to `__cudaPopCallConfiguration'
../libparticles.a(calc.cu.o): In function `__nv_cudaEntityRegisterCallback(void**)':
tmpxft_00036041_00000000-5_calc.cudafe1.cpp:(.text+0x708): undefined reference to `__cudaRegisterFunction'
../libparticles.a(calc.cu.o): In function `__sti____cudaRegisterAll()':
tmpxft_00036041_00000000-5_calc.cudafe1.cpp:(.text+0x744): undefined reference to `__cudaRegisterLinkedBinary_39_tmpxft_00036041_00000000_6_calc_cpp1_ii_78a77cc9'
../libparticles.a(calc.cu.o): In function `cudaError cudaMalloc<particle>(particle**, unsigned long)':
tmpxft_00036041_00000000-5_calc.cudafe1.cpp:(.text+0x76c): undefined reference to `cudaMalloc'
../libparticles.a(calc.cu.o): In function `cudaError cudaLaunchKernel<char>(char const*, dim3, dim3, void**, unsigned long, CUstream_st*)':
tmpxft_00036041_00000000-5_calc.cudafe1.cpp:(.text+0x7e8): undefined reference to `cudaLaunchKernel'
../libparticles.a(particle.cu.o): In function `__cudaUnregisterBinaryUtil()':
tmpxft_00035ff9_00000000-5_particle.cudafe1.cpp:(.text+0x1c4): undefined reference to `__cudaUnregisterFatBinary'
../libparticles.a(particle.cu.o): In function `__nv_init_managed_rt_with_module(void**)':
tmpxft_00035ff9_00000000-5_particle.cudafe1.cpp:(.text+0x1e4): undefined reference to `__cudaInitModule'
../libparticles.a(particle.cu.o): In function `__sti____cudaRegisterAll()':
tmpxft_00035ff9_00000000-5_particle.cudafe1.cpp:(.text+0x24c): undefined reference to `__cudaRegisterLinkedBinary_43_tmpxft_00035ff9_00000000_6_particle_cpp1_ii_bd5b23a5'
../libparticles.a(v3.cu.o): In function `__cudaUnregisterBinaryUtil()':
tmpxft_00036017_00000000-5_v3.cudafe1.cpp:(.text+0x3ac): undefined reference to `__cudaUnregisterFatBinary'
../libparticles.a(v3.cu.o): In function `__nv_init_managed_rt_with_module(void**)':
tmpxft_00036017_00000000-5_v3.cudafe1.cpp:(.text+0x3cc): undefined reference to `__cudaInitModule'
../libparticles.a(v3.cu.o): In function `__sti____cudaRegisterAll()':
tmpxft_00036017_00000000-5_v3.cudafe1.cpp:(.text+0x434): undefined reference to `__cudaRegisterLinkedBinary_37_tmpxft_00036017_00000000_6_v3_cpp1_ii_ec982148'
collect2: error: ld returned 1 exit status
CMakeFiles/particle_test.dir/build.make:98: recipe for target 'another_project' failed
make[2]: *** [particle_test] Error 1
make[2]: Leaving directory '/home/jenkins/git_repos/test/test_gpu/build'
CMakeFiles/Makefile2:70: recipe for target 'CMakeFiles/another_project.dir/all' failed
make[1]: *** [CMakeFiles/another_project.dir/all] Error 2
make[1]: Leaving directory '/home/jenkins/git_repos/test/test_gpu/build'
Makefile:86: recipe for target 'all' failed
make: *** [all] Error 2
I cannot understand the reason. In the end, I want to send libparticles.a to another developer and let him use it. Any help is really appreciated since I stuck at this problem for a while now.
Its about how GCC links library, if the name of lib is particles try this
target_link_directories(another_project PRIVATE /home/path_to_dir_containing_lib_a_file)
target_link_libraries(another_project PRIVATE particles)
Please see this manual:
https://gcc.gnu.org/onlinedocs/gcc/Link-Options.html
-l library
Search the library named library when linking. (The second alternative with the library as a separate argument is only for POSIX compliance and is not recommended.)
The -l option is passed directly to the linker by GCC. Refer to your linker documentation for exact details. The general description below applies to the GNU linker.
The linker searches a standard list of directories for the library. The directories searched include several standard system directories plus any that you specify with -L.
It means that dirs containing libraries are passed separatly (under another flag) from library name

CMake: cannot create target because another target with the same name already exists

I'm trying to install plexe-sumo with cmake. I followed the tutorial at plexe.car2x.org and here's the results:
-- CMAKE_BUILD_TYPE: Release
-- CMAKE_BINARY_DIR: /home/cc/src/plexe-sumo/build-release
-- CMAKE_SOURCE_DIR: /home/cc/src/plexe-sumo
--
-- Platform:
-- Host: Linux4.15.0-34-genericx86_64
-- CMake: 3.12.2
-- CMake generator: Unix Makefiles
-- CMake build tool: /usr/bin/make
--
-- Found Proj: /usr/lib/x86_64-linux-gnu/libproj.so
CMake Error at /usr/local/share/cmake-3.12/Modules/UseSWIG.cmake:627 (add_custom_target):
add_custom_target cannot create target "libsumo_swig_compilation" because
another target with the same name already exists. The existing target is a
custom target created in source directory
"/home/cc/src/plexe-sumo/src/libsumo". See documentation for policy
CMP0002 for more details.
Call Stack (most recent call first):
src/libsumo/CMakeLists.txt:39 (SWIG_ADD_LIBRARY)
-- Enabled features: Linux-4.15.0-34-generic Proj GUI GDAL OSG GL2PS SWIG
-- Configuring incomplete, errors occurred!
There is no file named 'libsumo_swig_compilation' under "/home/cc/src/plexe-sumo/src/libsumo".
Then I checked the error log file, but the errors shown are about pthread saying 'undefined reference to pthread_creat' and 'cannot find -lpthreads'. Actually my pthread library is installed at 'libc6: /lib/x86_64-linux-gnu/libpthread.so.0'.
So I was wondering what's the exact problem here and how to solve it. I'm using a virtual machine with ubuntu 16. I appreciate your help!
Following is the error log file:
Determining if the pthread_create exist failed with the following output:
Change Dir: /home/cc/src/plexe-sumo/build-release/CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/make" "cmTC_050d5/fast"
/usr/bin/make -f CMakeFiles/cmTC_050d5.dir/build.make CMakeFiles/cmTC_050d5.dir/build
make[1]: Entering directory '/home/cc/src/plexe-sumo/build-release/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_050d5.dir/CheckSymbolExists.c.o
/usr/bin/cc -Wall -pedantic -Wextra -o CMakeFiles/cmTC_050d5.dir/CheckSymbolExists.c.o -c /home/cc/src/plexe-sumo/build-release/CMakeFiles/CMakeTmp/CheckSymbolExists.c
/home/cc/src/plexe-sumo/build-release/CMakeFiles/CMakeTmp/CheckSymbolExists.c: In function ‘main’:
/home/cc/src/plexe-sumo/build-release/CMakeFiles/CMakeTmp/CheckSymbolExists.c:8:11: warning: ISO C forbids conversion of function pointer to object pointer type [-Wpedantic]
return ((int*)(&pthread_create))[argc];
^
Linking C executable cmTC_050d5
/usr/local/bin/cmake -E cmake_link_script CMakeFiles/cmTC_050d5.dir/link.txt --verbose=1
/usr/bin/cc -Wall -pedantic -Wextra -rdynamic CMakeFiles/cmTC_050d5.dir/CheckSymbolExists.c.o -o cmTC_050d5
CMakeFiles/cmTC_050d5.dir/CheckSymbolExists.c.o: In function `main':
CheckSymbolExists.c:(.text+0x16): undefined reference to `pthread_create'
collect2: error: ld returned 1 exit status
CMakeFiles/cmTC_050d5.dir/build.make:86: recipe for target 'cmTC_050d5' failed
make[1]: *** [cmTC_050d5] Error 1
make[1]: Leaving directory '/home/cc/src/plexe-sumo/build-release/CMakeFiles/CMakeTmp'
Makefile:121: recipe for target 'cmTC_050d5/fast' failed
make: *** [cmTC_050d5/fast] Error 2
File /home/cc/src/plexe-sumo/build-release/CMakeFiles/CMakeTmp/CheckSymbolExists.c:
/* */
#include <pthread.h>
int main(int argc, char** argv)
{
(void)argv;
#ifndef pthread_create
return ((int*)(&pthread_create))[argc];
#else
(void)argc;
return 0;
#endif
}
Determining if the function pthread_create exists in the pthreads failed with the following output:
Change Dir: /home/cc/src/plexe-sumo/build-release/CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/make" "cmTC_9f654/fast"
/usr/bin/make -f CMakeFiles/cmTC_9f654.dir/build.make CMakeFiles/cmTC_9f654.dir/build
make[1]: Entering directory '/home/cc/src/plexe-sumo/build-release/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_9f654.dir/CheckFunctionExists.c.o
/usr/bin/cc -Wall -pedantic -Wextra -DCHECK_FUNCTION_EXISTS=pthread_create -o CMakeFiles/cmTC_9f654.dir/CheckFunctionExists.c.o -c /usr/local/share/cmake-3.12/Modules/CheckFunctionExists.c
Linking C executable cmTC_9f654
/usr/local/bin/cmake -E cmake_link_script CMakeFiles/cmTC_9f654.dir/link.txt --verbose=1
/usr/bin/cc -Wall -pedantic -Wextra -DCHECK_FUNCTION_EXISTS=pthread_create -rdynamic CMakeFiles/cmTC_9f654.dir/CheckFunctionExists.c.o -o cmTC_9f654 -lpthreads
/usr/bin/ld: cannot find -lpthreads
collect2: error: ld returned 1 exit status
CMakeFiles/cmTC_9f654.dir/build.make:86: recipe for target 'cmTC_9f654' failed
make[1]: *** [cmTC_9f654] Error 1
make[1]: Leaving directory '/home/cc/src/plexe-sumo/build-release/CMakeFiles/CMakeTmp'
Makefile:121: recipe for target 'cmTC_9f654/fast' failed
make: *** [cmTC_9f654/fast] Error 2
My assumption is that this is really a behavior which only the new cmake shows. You could try to rename all references to libsumo in the java part of the CMakeLists.txt or simply use the CMakeLists of the main line sumo here: https://github.com/eclipse/sumo/blob/master/src/libsumo/CMakeLists.txt

CMake with IBMs mpixlf2008

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.

handmade Makefile to Cmake with static library

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.