Cross compiling CGAL with Mingw-w64 - archlinux

I am having some compilation errors while using mingw-w64 to cross compile the CGAL library. I have read in some comments on some forums that CGAL has not been tested with mingw-w64, although in CGAL documentation there is no mention about this.
Here are the errors I am getting. I am using mingw-w64 on ArchLinux
Run Build Command:"/usr/bin/make" "cmTC_f335f/fast"
/usr/bin/make -f CMakeFiles/cmTC_f335f.dir/build.make CMakeFiles/cmTC_f335f.dir/build
make[1]: Entering directory '/home/calegria/Software/aur/mingw/mingw-w64-cgal/src/CGAL-4.10/build-i686-w64-mingw32/CMakeFiles/CMakeTmp'
Building CXX object CMakeFiles/cmTC_f335f.dir/print_GCC_version.cpp.obj
/usr/bin/i686-w64-mingw32-g++ -o CMakeFiles/cmTC_f335f.dir/print_GCC_version.cpp.obj -c /home/calegria/Software/aur/mingw/mingw-w64-cgal/src/CGAL-4.10/config/support/print_GCC_version.cpp
Linking CXX executable cmTC_f335f.exe
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_f335f.dir/link.txt --verbose=1
/usr/bin/cmake -E remove -f CMakeFiles/cmTC_f335f.dir/objects.a
/usr/bin/i686-w64-mingw32-ar cr CMakeFiles/cmTC_f335f.dir/objects.a #CMakeFiles/cmTC_f335f.dir/objects1.rsp
/usr/bin/i686-w64-mingw32-g++ -Wl,--whole-archive CMakeFiles/cmTC_f335f.dir/objects.a -Wl,--no-whole-archive -o cmTC_f335f.exe -Wl,--out-implib,libcmTC_f335f.dll.a -Wl,--major-image-version,0,--minor-image-version,0 #CMakeFiles/cmTC_f335f.dir/linklibs.rsp
make[1]: Leaving directory '/home/calegria/Software/aur/mingw/mingw-w64-cgal/src/CGAL-4.10/build-i686-w64-mingw32/CMakeFiles/CMakeTmp'
/usr/bin/i686-w64-mingw32-wine: line 20: wine: command not found
-- USING GCC_VERSION = 'unknown'
== Generate version files (DONE) ==
== Set up flags ==
-- Build type: Release
-- USING CXXFLAGS = ' -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions --param=ssp-buffer-size=4'
-- USING LDFLAGS = ' '
== Set up flags (DONE) ==
== Detect external libraries ==
-- External libraries supported: GMP;MPFR;ZLIB;OpenGL;LEDA;MPFI;RS;RS3;OpenNL;Eigen3;BLAS;LAPACK;QGLViewer;ESBTL;Coin3D;NTL;IPE
-- Preconfiguring library: GMP ...
-- Found GMP: /usr/i686-w64-mingw32/lib/libgmp.dll.a
-- GMP has been preconfigured:
-- UseGMP-file:
-- GMP include: /usr/i686-w64-mingw32/include
-- GMP libraries: /usr/i686-w64-mingw32/lib/libgmp.dll.a
-- GMP definitions:
-- WARNING: GMP found but print_GMP_version.cpp exited with error condition: 127
-- GMP_INCLUDE_DIR=/usr/i686-w64-mingw32/include
-- GMP_LIBRARIES=/usr/i686-w64-mingw32/lib/libgmp.dll.a
-- GMP_LIBRARIES_DIR=/usr/i686-w64-mingw32/lib
-- Change Dir: /home/calegria/Software/aur/mingw/mingw-w64-cgal/src/CGAL-4.10/build-i686-w64-mingw32/CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/make" "cmTC_f3997/fast"
/usr/bin/make -f CMakeFiles/cmTC_f3997.dir/build.make CMakeFiles/cmTC_f3997.dir/build
make[1]: Entering directory '/home/calegria/Software/aur/mingw/mingw-w64-cgal/src/CGAL-4.10/build-i686-w64-mingw32/CMakeFiles/CMakeTmp'
Building CXX object CMakeFiles/cmTC_f3997.dir/print_GMP_version.cpp.obj
/usr/bin/i686-w64-mingw32-g++ #CMakeFiles/cmTC_f3997.dir/includes_CXX.rsp -o CMakeFiles/cmTC_f3997.dir/print_GMP_version.cpp.obj -c /home/calegria/Software/aur/mingw/mingw-w64-cgal/src/CGAL-4.10/config/support/print_GMP_version.cpp
Linking CXX executable cmTC_f3997.exe
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_f3997.dir/link.txt --verbose=1
/usr/bin/cmake -E remove -f CMakeFiles/cmTC_f3997.dir/objects.a
/usr/bin/i686-w64-mingw32-ar cr CMakeFiles/cmTC_f3997.dir/objects.a #CMakeFiles/cmTC_f3997.dir/objects1.rsp
/usr/bin/i686-w64-mingw32-g++ -Wl,--whole-archive CMakeFiles/cmTC_f3997.dir/objects.a -Wl,--no-whole-archive -o cmTC_f3997.exe -Wl,--out-implib,libcmTC_f3997.dll.a -Wl,--major-image-version,0,--minor-image-version,0 #CMakeFiles/cmTC_f3997.dir/linklibs.rsp
make[1]: Leaving directory '/home/calegria/Software/aur/mingw/mingw-w64-cgal/src/CGAL-4.10/build-i686-w64-mingw32/CMakeFiles/CMakeTmp'
/usr/bin/i686-w64-mingw32-wine: line 20: wine: command not found
-- USING GMP_VERSION = 'unknown'
-- Preconfiguring library: MPFR ...
-- Found MPFR: /usr/i686-w64-mingw32/lib/libmpfr.dll.a
-- MPFR has been preconfigured:
-- UseMPFR-file:
-- MPFR include: /usr/i686-w64-mingw32/include
-- MPFR libraries: /usr/i686-w64-mingw32/lib/libmpfr.dll.a
-- MPFR definitions:
-- WARNING: MPFR found but print_MPFR_version.cpp exited with error condition: 127
-- MPFR_INCLUDE_DIR=/usr/i686-w64-mingw32/include
-- MPFR_LIBRARIES=/usr/i686-w64-mingw32/lib/libmpfr.dll.a
-- MPFR_LIBRARIES_DIR=/usr/i686-w64-mingw32/lib
-- Change Dir: /home/calegria/Software/aur/mingw/mingw-w64-cgal/src/CGAL-4.10/build-i686-w64-mingw32/CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/make" "cmTC_0a17b/fast"
/usr/bin/make -f CMakeFiles/cmTC_0a17b.dir/build.make CMakeFiles/cmTC_0a17b.dir/build
make[1]: Entering directory '/home/calegria/Software/aur/mingw/mingw-w64-cgal/src/CGAL-4.10/build-i686-w64-mingw32/CMakeFiles/CMakeTmp'
Building CXX object CMakeFiles/cmTC_0a17b.dir/print_MPFR_version.cpp.obj
/usr/bin/i686-w64-mingw32-g++ #CMakeFiles/cmTC_0a17b.dir/includes_CXX.rsp -o CMakeFiles/cmTC_0a17b.dir/print_MPFR_version.cpp.obj -c /home/calegria/Software/aur/mingw/mingw-w64-cgal/src/CGAL-4.10/config/support/print_MPFR_version.cpp
Linking CXX executable cmTC_0a17b.exe
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_0a17b.dir/link.txt --verbose=1
/usr/bin/cmake -E remove -f CMakeFiles/cmTC_0a17b.dir/objects.a
/usr/bin/i686-w64-mingw32-ar cr CMakeFiles/cmTC_0a17b.dir/objects.a #CMakeFiles/cmTC_0a17b.dir/objects1.rsp
/usr/bin/i686-w64-mingw32-g++ -Wl,--whole-archive CMakeFiles/cmTC_0a17b.dir/objects.a -Wl,--no-whole-archive -o cmTC_0a17b.exe -Wl,--out-implib,libcmTC_0a17b.dll.a -Wl,--major-image-version,0,--minor-image-version,0 #CMakeFiles/cmTC_0a17b.dir/linklibs.rsp
make[1]: Leaving directory '/home/calegria/Software/aur/mingw/mingw-w64-cgal/src/CGAL-4.10/build-i686-w64-mingw32/CMakeFiles/CMakeTmp'
/usr/bin/i686-w64-mingw32-wine: line 20: wine: command not found
-- USING MPFR_VERSION = 'unknown'
-- __cplusplus is /usr/bin/i686-w64-mingw32-wine: line 20: wine: command not found
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - found
-- Found Threads: TRUE
-- Boost version: 1.64.0
-- Found the following Boost libraries:
-- thread
-- system
-- chrono
-- date_time
-- atomic
-- Boost include: /usr/i686-w64-mingw32/include
-- Boost libraries: /usr/i686-w64-mingw32/lib/libboost_thread-mt.dll.a;/usr/i686-w64-mingw32/lib/libboost_system-mt.dll.a;/usr/i686-w64-mingw32/lib/libboost_chrono-mt.dll.a;/usr/i686-w64-mingw32/lib/libboost_date_time-mt.dll.a;/usr/i686-w64-mingw32/lib/libboost_atomic-mt.dll.a
-- Boost definitions:
-- USING BOOST_VERSION = '1.64.0'
== Detect external libraries (DONE) ==
== Write compiler_config.h ==
-- Performing Test CGAL_CFG_DENORMALS_COMPILE_BUG - Failed
-- Performing Test CGAL_CFG_FPU_ROUNDING_MODE_UNWINDING_VC_BUG - Failed
-- Performing Test CGAL_CFG_IEEE_754_BUG - Failed
-- Performing Test CGAL_CFG_ISTREAM_INT_BUG - Failed
-- Performing Test CGAL_CFG_MATCHING_BUG_5 - Failed
-- Performing Test CGAL_CFG_MATCHING_BUG_6 - Failed
-- Performing Test CGAL_CFG_MATCHING_BUG_7 - Failed
-- Performing Test CGAL_CFG_MATCHING_BUG_8 - Failed
-- Performing Test CGAL_CFG_NESTED_CLASS_FRIEND_DECLARATION_BUG - Failed
-- Performing Test CGAL_CFG_NO_LIMITS - Failed
-- Performing Test CGAL_CFG_NO_NEXTAFTER - Failed
-- Performing Test CGAL_CFG_NO_STL - Failed
-- Performing Test CGAL_CFG_NUMERIC_LIMITS_BUG - Failed
-- Performing Test CGAL_CFG_OUTOFLINE_MEMBER_DEFINITION_BUG - Failed
-- Performing Test CGAL_CFG_TEMPLATE_IN_DEFAULT_PARAMETER_BUG - Failed
-- Performing Test CGAL_CFG_TYPENAME_BEFORE_DEFAULT_ARGUMENT_BUG - Failed
-- Performing Test CGAL_CFG_USING_BASE_MEMBER_BUG_2 - Failed
== Write compiler_config.h (DONE) ==
== Generating build files ==
Configuring libCGAL
-- Requested component: MPFR
-- Requested component: GMP
libCGAL is configured
-- Sources for CGAL component library 'CGAL_Core' detected
Configuring libCGAL_Core
-- Requested component: MPFR
-- Requested component: GMP
-- Boost version: 1.64.0
-- Found the following Boost libraries:
-- thread
-- system
-- chrono
-- date_time
-- atomic
libCGAL_Core is configured
-- Sources for CGAL component library 'CGAL_ImageIO' detected
Configuring libCGAL_ImageIO
-- Found ZLIB: /usr/i686-w64-mingw32/lib/libz.dll.a (found version "1.2.11")
-- WARNING: ZLIB found but print_ZLIB_version.cpp exited with error condition: 127
-- ZLIB_INCLUDE_DIR=/usr/i686-w64-mingw32/include
-- ZLIB_LIBRARIES=/usr/i686-w64-mingw32/lib/libz.dll.a
-- ZLIB_LIBRARIES_DIR=
-- Change Dir: /home/calegria/Software/aur/mingw/mingw-w64-cgal/src/CGAL-4.10/build-i686-w64-mingw32/CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/make" "cmTC_e29f4/fast"
/usr/bin/make -f CMakeFiles/cmTC_e29f4.dir/build.make CMakeFiles/cmTC_e29f4.dir/build
make[1]: Entering directory '/home/calegria/Software/aur/mingw/mingw-w64-cgal/src/CGAL-4.10/build-i686-w64-mingw32/CMakeFiles/CMakeTmp'
Building CXX object CMakeFiles/cmTC_e29f4.dir/print_ZLIB_version.cpp.obj
/usr/bin/i686-w64-mingw32-g++ #CMakeFiles/cmTC_e29f4.dir/includes_CXX.rsp -o CMakeFiles/cmTC_e29f4.dir/print_ZLIB_version.cpp.obj -c /home/calegria/Software/aur/mingw/mingw-w64-cgal/src/CGAL-4.10/config/support/print_ZLIB_version.cpp
Linking CXX executable cmTC_e29f4.exe
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_e29f4.dir/link.txt --verbose=1
/usr/bin/cmake -E remove -f CMakeFiles/cmTC_e29f4.dir/objects.a
/usr/bin/i686-w64-mingw32-ar cr CMakeFiles/cmTC_e29f4.dir/objects.a #CMakeFiles/cmTC_e29f4.dir/objects1.rsp
/usr/bin/i686-w64-mingw32-g++ -Wl,--whole-archive CMakeFiles/cmTC_e29f4.dir/objects.a -Wl,--no-whole-archive -o cmTC_e29f4.exe -Wl,--out-implib,libcmTC_e29f4.dll.a -Wl,--major-image-version,0,--minor-image-version,0 #CMakeFiles/cmTC_e29f4.dir/linklibs.rsp
make[1]: Leaving directory '/home/calegria/Software/aur/mingw/mingw-w64-cgal/src/CGAL-4.10/build-i686-w64-mingw32/CMakeFiles/CMakeTmp'
/usr/bin/i686-w64-mingw32-wine: line 20: wine: command not found
-- USING ZLIB_VERSION = 'unknown'
-- Requested component: MPFR
-- Requested component: GMP
libCGAL_ImageIO is configured
-- Sources for CGAL component library 'CGAL_Qt5' detected
-- Sources for CGAL component libraries 'CGAL_Core;CGAL_ImageIO;CGAL_Qt5' detected
== Generating build files (DONE) ==
-- Configuring done
-- Generating done
CMake Warning:
Manually-specified variables were not used by the project:
CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES
INCLUDE_INSTALL_DIR
LIB_INSTALL_DIR
SHARE_INSTALL_DIR
SYSCONF_INSTALL_DIR
-- Build files have been written to: /home/calegria/Software/aur/mingw/mingw-w64-cgal/src/CGAL-4.10/build-i686-w64-mingw32
Scanning dependencies of target CGAL
[ 11%] Building CXX object src/CGAL/CMakeFiles/CGAL.dir/all_files.cpp.obj
In file included from /home/calegria/Software/aur/mingw/mingw-w64-cgal/src/CGAL-4.10/include/CGAL/Bbox_2.h:27:0,
from /home/calegria/Software/aur/mingw/mingw-w64-cgal/src/CGAL-4.10/include/CGAL/Bbox_2_Line_2_intersection.h:29,
from /home/calegria/Software/aur/mingw/mingw-w64-cgal/src/CGAL-4.10/src/CGAL/Bbox_2_intersections.cpp:27,
from /home/calegria/Software/aur/mingw/mingw-w64-cgal/src/CGAL-4.10/build-i686-w64-mingw32/src/CGAL/all_files.cpp:1:
/home/calegria/Software/aur/mingw/mingw-w64-cgal/src/CGAL-4.10/include/CGAL/config.h:257:4: error: #error "This compiler does not have a working STL"
# error "This compiler does not have a working STL"
^~~~~
In file included from /home/calegria/Software/aur/mingw/mingw-w64-cgal/src/CGAL-4.10/include/CGAL/number_type_basic.h:57:0,
from /home/calegria/Software/aur/mingw/mingw-w64-cgal/src/CGAL-4.10/include/CGAL/basic.h:44,
from /home/calegria/Software/aur/mingw/mingw-w64-cgal/src/CGAL-4.10/include/CGAL/Cartesian/Cartesian_base.h:28,
from /home/calegria/Software/aur/mingw/mingw-w64-cgal/src/CGAL-4.10/include/CGAL/Simple_cartesian.h:28,
from /home/calegria/Software/aur/mingw/mingw-w64-cgal/src/CGAL-4.10/include/CGAL/Bbox_2_Line_2_intersection_impl.h:31,
from /home/calegria/Software/aur/mingw/mingw-w64-cgal/src/CGAL-4.10/src/CGAL/Bbox_2_intersections.cpp:28,
from /home/calegria/Software/aur/mingw/mingw-w64-cgal/src/CGAL-4.10/build-i686-w64-mingw32/src/CGAL/all_files.cpp:1:
/home/calegria/Software/aur/mingw/mingw-w64-cgal/src/CGAL-4.10/include/CGAL/Interval_nt.h: In static member function ‘static CGAL::Interval_nt<Protected>::IA CGAL::Interval_nt<Protected>::smallest()’:
/home/calegria/Software/aur/mingw/mingw-w64-cgal/src/CGAL-4.10/include/CGAL/FPU.h:70:49: error: ‘get_static_minimin’ is not a member of ‘CGAL::internal’
# define CGAL_IA_MIN_DOUBLE (CGAL::internal::get_static_minimin())
^
/home/calegria/Software/aur/mingw/mingw-w64-cgal/src/CGAL-4.10/include/CGAL/Interval_nt.h:185:16: note: in expansion of macro ‘CGAL_IA_MIN_DOUBLE’
return IA(-CGAL_IA_MIN_DOUBLE, CGAL_IA_MIN_DOUBLE);
^~~~~~~~~~~~~~~~~~
/home/calegria/Software/aur/mingw/mingw-w64-cgal/src/CGAL-4.10/include/CGAL/FPU.h:70:49: note: suggested alternative:
# define CGAL_IA_MIN_DOUBLE (CGAL::internal::get_static_minimin())
^
/home/calegria/Software/aur/mingw/mingw-w64-cgal/src/CGAL-4.10/include/CGAL/Interval_nt.h:185:16: note: in expansion of macro ‘CGAL_IA_MIN_DOUBLE’
return IA(-CGAL_IA_MIN_DOUBLE, CGAL_IA_MIN_DOUBLE);
^~~~~~~~~~~~~~~~~~
/home/calegria/Software/aur/mingw/mingw-w64-cgal/src/CGAL-4.10/include/CGAL/FPU.h:120:9: note: ‘get_static_minimin’
double& get_static_minimin(); // Defined in Interval_arithmetic_impl.h
^~~~~~~~~~~~~~~~~~
/home/calegria/Software/aur/mingw/mingw-w64-cgal/src/CGAL-4.10/include/CGAL/FPU.h:70:49: error: ‘get_static_minimin’ is not a member of ‘CGAL::internal’
# define CGAL_IA_MIN_DOUBLE (CGAL::internal::get_static_minimin())
^
/home/calegria/Software/aur/mingw/mingw-w64-cgal/src/CGAL-4.10/include/CGAL/Interval_nt.h:185:36: note: in expansion of macro ‘CGAL_IA_MIN_DOUBLE’
return IA(-CGAL_IA_MIN_DOUBLE, CGAL_IA_MIN_DOUBLE);
^~~~~~~~~~~~~~~~~~
/home/calegria/Software/aur/mingw/mingw-w64-cgal/src/CGAL-4.10/include/CGAL/FPU.h:70:49: note: suggested alternative:
# define CGAL_IA_MIN_DOUBLE (CGAL::internal::get_static_minimin())
^
/home/calegria/Software/aur/mingw/mingw-w64-cgal/src/CGAL-4.10/include/CGAL/Interval_nt.h:185:36: note: in expansion of macro ‘CGAL_IA_MIN_DOUBLE’
return IA(-CGAL_IA_MIN_DOUBLE, CGAL_IA_MIN_DOUBLE);
^~~~~~~~~~~~~~~~~~
/home/calegria/Software/aur/mingw/mingw-w64-cgal/src/CGAL-4.10/include/CGAL/FPU.h:120:9: note: ‘get_static_minimin’
double& get_static_minimin(); // Defined in Interval_arithmetic_impl.h
^~~~~~~~~~~~~~~~~~
/home/calegria/Software/aur/mingw/mingw-w64-cgal/src/CGAL-4.10/include/CGAL/Interval_nt.h: In function ‘CGAL::Interval_nt<Protected> CGAL::ldexp(const CGAL::Interval_nt<Protected>&, int)’:
/home/calegria/Software/aur/mingw/mingw-w64-cgal/src/CGAL-4.10/include/CGAL/FPU.h:70:49: error: ‘get_static_minimin’ is not a member of ‘CGAL::internal’
# define CGAL_IA_MIN_DOUBLE (CGAL::internal::get_static_minimin())
^
/home/calegria/Software/aur/mingw/mingw-w64-cgal/src/CGAL-4.10/include/CGAL/Interval_nt.h:737:36: note: in expansion of macro ‘CGAL_IA_MIN_DOUBLE’
scale == 0 ? CGAL_IA_MIN_DOUBLE : scale);
^~~~~~~~~~~~~~~~~~
/home/calegria/Software/aur/mingw/mingw-w64-cgal/src/CGAL-4.10/include/CGAL/FPU.h:70:49: note: suggested alternative:
# define CGAL_IA_MIN_DOUBLE (CGAL::internal::get_static_minimin())
^
/home/calegria/Software/aur/mingw/mingw-w64-cgal/src/CGAL-4.10/include/CGAL/Interval_nt.h:737:36: note: in expansion of macro ‘CGAL_IA_MIN_DOUBLE’
scale == 0 ? CGAL_IA_MIN_DOUBLE : scale);
^~~~~~~~~~~~~~~~~~
/home/calegria/Software/aur/mingw/mingw-w64-cgal/src/CGAL-4.10/include/CGAL/FPU.h:120:9: note: ‘get_static_minimin’
double& get_static_minimin(); // Defined in Interval_arithmetic_impl.h
^~~~~~~~~~~~~~~~~~
In file included from /home/calegria/Software/aur/mingw/mingw-w64-cgal/src/CGAL-4.10/src/CGAL/Geomview_stream.cpp:28:0,
from /home/calegria/Software/aur/mingw/mingw-w64-cgal/src/CGAL-4.10/build-i686-w64-mingw32/src/CGAL/all_files.cpp:10:
/home/calegria/Software/aur/mingw/mingw-w64-cgal/src/CGAL-4.10/include/CGAL/IO/Geomview_stream_impl.h: At global scope:
/home/calegria/Software/aur/mingw/mingw-w64-cgal/src/CGAL-4.10/include/CGAL/IO/Geomview_stream_impl.h:607:5: warning: ‘CGAL::{anonymous}::dummy’ defined but not used [-Wunused-variable]
int dummy;
^~~~~
make[2]: *** [src/CGAL/CMakeFiles/CGAL.dir/build.make:64: src/CGAL/CMakeFiles/CGAL.dir/all_files.cpp.obj] Error 1
make[1]: *** [CMakeFiles/Makefile2:206: src/CGAL/CMakeFiles/CGAL.dir/all] Error 2
make: *** [Makefile:130: all] Error 2
==> ERROR: A failure occurred in build().
Aborting...
¿Has someone successfully compiled CGAL with mingw-w64?

I was able to solve the issue. I just needed to install wine so CMake was able to use it as an emulator via the CMAKE_CROSSCOMPILING_EMULATOR variable.
If you are using Arch Linux the paclage mingw-w64-cgal will work.

Related

Conan and Raspberry Pico, how to use together?

Good morning!
I'm rewriting this question because, after a lot of reading and try-fails, I go further on that but I get staked again.
What I'm trying to accomplice here is: Use Conan as a Package manager for the embedded device "Raspberry PICO" from my Mac (with CLion)
The change from the previous question is that now I'm creating a package and I do not use only the "standalone" packages manager.
This "package" is on github.com. To install and try to compile it, you will need also the Pico SDK.
Some facts:
The new c++ project without Conan but with SDK is compiling and working on an embedded device.
The Conan project without Pico SDK is compiling correctly.
I really tried every possible configuration on the profile file and there are two mainly configuration profiles that brings to two different errors during build:
The first one is without any environments. This is because on CLion I'm not adding any environment and the project itself (without conan, but oblivious with SDK for pico) is builder correctly.
[settings]
os_build=Macos
arch_build=x86_64
os=Linux
arch=armv7
# os=Macos
# arch=x86_64
# compiler=apple-clang
compiler=gcc
# compiler.version=12.0
compiler.version=9.2
# compiler.libcxx=libc++
compiler.libcxx=libstdc++
build_type=Release
[options]
[build_requires]
[env]
ps. The commented lines are additional tests that resolve on the same result after conan build ..
The error is this:
jure.prah#MacBook-Pro-di-Jure conan-blink-mosfet % conan build .
Using lockfile: '/Users/jure.prah/CLionProjects/rpi-pico/conan-blink-mosfet/conan.lock'
Using cached profile from lockfile
conanfile.py (blink/0.1): Calling build()
conanfile.py (blink/0.1): CMake command: cmake -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE="/Users/jure.prah/CLionProjects/rpi-pico/conan-blink-mosfet/build/generators/conan_toolchain.cmake" -DCMAKE_INSTALL_PREFIX="/Users/jure.prah/CLionProjects/rpi-pico/conan-blink-mosfet/package" "/Users/jure.prah/CLionProjects/rpi-pico/conan-blink-mosfet/src"
Using PICO_SDK_PATH from environment ('/Users/jure.prah/CLionProjects/pico-sdk')
PICO_SDK_PATH is /Users/jure.prah/CLionProjects/pico-sdk
Defaulting PICO_PLATFORM to rp2040 since not specified.
-- Defaulting build type to 'Release' since not specified.
Using Conan toolchain through /Users/jure.prah/CLionProjects/rpi-pico/conan-blink-mosfet/build/generators/conan_toolchain.cmake.
-- Conan toolchain: Setting CMAKE_POSITION_INDEPENDENT_CODE=ON (options.fPIC)
-- Conan toolchain: Setting BUILD_SHARED_LIBS= OFF
-- The C compiler identification is AppleClang 12.0.5.12050022
-- The CXX compiler identification is AppleClang 12.0.5.12050022
-- The ASM compiler identification is Clang
-- Found assembler: /Library/Developer/CommandLineTools/usr/bin/cc
-- Detecting C compiler ABI info
Using Conan toolchain through .
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
Using Conan toolchain through .
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
Defaulting PICO target board to pico since not specified.
Using board configuration from /Users/jure.prah/CLionProjects/pico-sdk/src/boards/include/boards/pico.h
-- Found Python3: /usr/local/Frameworks/Python.framework/Versions/3.9/bin/python3.9 (found version "3.9.6") found components: Interpreter
TinyUSB available at /Users/jure.prah/CLionProjects/pico-sdk/lib/tinyusb/src/portable/raspberrypi/rp2040; adding USB support.
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/jure.prah/CLionProjects/rpi-pico/conan-blink-mosfet/build/Release
conanfile.py (blink/0.1): CMake command: cmake --build '/Users/jure.prah/CLionProjects/rpi-pico/conan-blink-mosfet/build/Release'
[ 25%] Building CXX object CMakeFiles/blink.dir/blink.cpp.o
[ 50%] Linking CXX static library libblink.a
[ 50%] Built target blink
Scanning dependencies of target bs2_default
[ 75%] Building ASM object pico-sdk/src/rp2_common/boot_stage2/CMakeFiles/bs2_default.dir/compile_time_choice.S.o
/Users/jure.prah/CLionProjects/pico-sdk/src/rp2_common/boot_stage2/boot2_w25q080.S:89:1: error: unknown directive
.syntax unified
^
/Users/jure.prah/CLionProjects/pico-sdk/src/rp2_common/boot_stage2/boot2_w25q080.S:90:1: error: unknown directive
.cpu cortex-m0plus
^
/Users/jure.prah/CLionProjects/pico-sdk/src/rp2_common/boot_stage2/boot2_w25q080.S:91:1: error: unknown directive
.thumb
^
/Users/jure.prah/CLionProjects/pico-sdk/src/rp2_common/boot_stage2/boot2_w25q080.S:93:15: error: unexpected token in '.section' directive
.section .text
^
/Users/jure.prah/CLionProjects/pico-sdk/src/rp2_common/boot_stage2/boot2_w25q080.S:101:1: error: unknown directive
.type _stage2_boot,%function
^
/Users/jure.prah/CLionProjects/pico-sdk/src/rp2_common/boot_stage2/boot2_w25q080.S:102:1: error: unknown directive
.thumb_func
^
/Users/jure.prah/CLionProjects/pico-sdk/src/rp2_common/boot_stage2/boot2_w25q080.S:104:11: error: unknown token in expression
push {lr}
^
[...]
^
/Users/jure.prah/CLionProjects/pico-sdk/src/rp2_common/boot_stage2/boot2_w25q080.S:285:1: error: unknown directive
.ltorg
^
make[2]: *** [pico-sdk/src/rp2_common/boot_stage2/CMakeFiles/bs2_default.dir/compile_time_choice.S.o] Error 1
make[1]: *** [pico-sdk/src/rp2_common/boot_stage2/CMakeFiles/bs2_default.dir/all] Error 2
make: *** [all] Error 2
ERROR: conanfile.py (blink/0.1): Error in build() method, line 40
cmake.build()
ConanException: Error 2 while executing cmake --build '/Users/jure.prah/CLionProjects/rpi-pico/conan-blink-mosfet/build/Release'
The second profile configuration is based on the example from conan.com (thanks to #uilianres) and sets the environments.:
toolchain_path=/usr/local/bin
toolchain=arm-none-eabi
[settings]
os_build=Macos
arch_build=x86_64
#os=Macos
#arch=x86_64
os=Linux
arch=armv7
compiler=apple-clang
# compiler=gcc
compiler.version=12.0
# compiler.version=9.2
compiler.libcxx=libc++
# compiler.libcxx=libstdc++
build_type=Release
[options]
[build_requires]
[env]
CONAN_CMAKE_FIND_ROOT_PATH=$toolchain_path/
AR=$toolchain-ar
AS=$toolchain-as
CC=$toolchain-gcc
CXX=$toolchain-g++
STRIP=$toolchain-strip
Using command conan build . resolve on different error:
jure.prah#MacBook-Pro-di-Jure conan-blink-mosfet % conan build .
Using lockfile: '/Users/jure.prah/CLionProjects/rpi-pico/conan-blink-mosfet/conan.lock'
Using cached profile from lockfile
conanfile.py (blink/0.1): Calling build()
conanfile.py (blink/0.1): CMake command: cmake -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE="/Users/jure.prah/CLionProjects/rpi-pico/conan-blink-mosfet/build/generators/conan_toolchain.cmake" -DCMAKE_INSTALL_PREFIX="/Users/jure.prah/CLionProjects/rpi-pico/conan-blink-mosfet/package" "/Users/jure.prah/CLionProjects/rpi-pico/conan-blink-mosfet/src"
Using PICO_SDK_PATH from environment ('/Users/jure.prah/CLionProjects/pico-sdk')
PICO_SDK_PATH is /Users/jure.prah/CLionProjects/pico-sdk
Defaulting PICO_PLATFORM to rp2040 since not specified.
-- Defaulting build type to 'Release' since not specified.
Using Conan toolchain through /Users/jure.prah/CLionProjects/rpi-pico/conan-blink-mosfet/build/generators/conan_toolchain.cmake.
-- Conan toolchain: Setting CMAKE_POSITION_INDEPENDENT_CODE=ON (options.fPIC)
-- Conan toolchain: Setting BUILD_SHARED_LIBS= OFF
-- The C compiler identification is GNU 9.2.1
-- The CXX compiler identification is GNU 9.2.1
-- The ASM compiler identification is GNU
-- Found assembler: /usr/local/bin/arm-none-eabi-gcc
-- Checking whether C compiler has -isysroot
-- Checking whether C compiler has -isysroot - yes
-- Checking whether C compiler supports OSX deployment target flag
-- Checking whether C compiler supports OSX deployment target flag - no
-- Detecting C compiler ABI info
Using Conan toolchain through .
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: /usr/local/bin/arm-none-eabi-gcc
Using Conan toolchain through .
-- Check for working C compiler: /usr/local/bin/arm-none-eabi-gcc - broken
CMake Error at /usr/local/Cellar/cmake/3.21.0/share/cmake/Modules/CMakeTestCCompiler.cmake:66 (message):
The C compiler
"/usr/local/bin/arm-none-eabi-gcc"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: /Users/jure.prah/CLionProjects/rpi-pico/conan-blink-mosfet/build/Release/CMakeFiles/CMakeTmp
Run Build Command(s):/usr/bin/make -f Makefile cmTC_69910/fast && /Library/Developer/CommandLineTools/usr/bin/make -f CMakeFiles/cmTC_69910.dir/build.make CMakeFiles/cmTC_69910.dir/build
Building C object CMakeFiles/cmTC_69910.dir/testCCompiler.c.o
/usr/local/bin/arm-none-eabi-gcc -D_GLIBCXX_USE_CXX11_ABI=0 -O3 -DNDEBUG -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk -fPIE -o CMakeFiles/cmTC_69910.dir/testCCompiler.c.o -c /Users/jure.prah/CLionProjects/rpi-pico/conan-blink-mosfet/build/Release/CMakeFiles/CMakeTmp/testCCompiler.c
Linking C executable cmTC_69910
/usr/local/Cellar/cmake/3.21.0/bin/cmake -E cmake_link_script CMakeFiles/cmTC_69910.dir/link.txt --verbose=1
/usr/local/bin/arm-none-eabi-gcc -O3 -DNDEBUG -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk -Wl,-search_paths_first -Wl,-headerpad_max_install_names CMakeFiles/cmTC_69910.dir/testCCompiler.c.o -o cmTC_69910
/usr/local/Cellar/arm-none-eabi-gcc/9-2019-q4-major/gcc/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: warning: cannot find entry symbol arch_paths_first; defaulting to 0000000000008018
/usr/local/Cellar/arm-none-eabi-gcc/9-2019-q4-major/gcc/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: /usr/local/Cellar/arm-none-eabi-gcc/9-2019-q4-major/gcc/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/lib/libc.a(lib_a-exit.o): in function `exit':
exit.c:(.text.exit+0x2c): undefined reference to `_exit'
collect2: error: ld returned 1 exit status
make[1]: *** [cmTC_69910] Error 1
make: *** [cmTC_69910/fast] Error 2
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:5 (project)
-- Configuring incomplete, errors occurred!
See also "/Users/jure.prah/CLionProjects/rpi-pico/conan-blink-mosfet/build/Release/CMakeFiles/CMakeOutput.log".
See also "/Users/jure.prah/CLionProjects/rpi-pico/conan-blink-mosfet/build/Release/CMakeFiles/CMakeError.log".
ERROR: conanfile.py (blink/0.1): Error in build() method, line 39
cmake.configure()
ConanException: Error 1 while executing cmake -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE="/Users/jure.prah/CLionProjects/rpi-pico/conan-blink-mosfet/build/generators/conan_toolchain.cmake" -DCMAKE_INSTALL_PREFIX="/Users/jure.prah/CLionProjects/rpi-pico/conan-blink-mosfet/package" "/Users/jure.prah/CLionProjects/rpi-pico/conan-blink-mosfet/src"
Also here I did all the variants and tests, but everything leads to this error. Besides, I checked the toolchain paths and there are correct.
I'm completely lost now. :(

why 'target_link_libraries' command is not working? (cplex)

I tried to compile an project with cmake command(all implementation is written by other people. my job is just compile and run.)
error messages after cmake
-- The C compiler identification is GNU 9.3.0
-- The CXX compiler identification is GNU 9.3.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
fatal: bad revision 'HEAD'
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Found LibXml2: /usr/lib/x86_64-linux-gnu/libxml2.so (found version "2.9.10")
-- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.2.11")
-- CPLEX Library: /opt/ibm/ILOG/CPLEX_Studio1210/cplex/lib/x86-64_linux/static_pic/libcplex.a
-- ILOCPLEX Library: /opt/ibm/ILOG/CPLEX_Studio1210/cplex/lib/x86-64_linux/static_pic/libilocplex.a
-- CONCERT Library: /opt/ibm/ILOG/CPLEX_Studio1210/concert/lib/x86-64_linux/static_pic/libconcert.a
-- CPLEX Bin Dir: /opt/ibm/ILOG/CPLEX_Studio1210/cplex/bin/x86-64_linux
-- Found CPLEX: /opt/ibm/ILOG/CPLEX_Studio1210/cplex/lib/x86-64_linux/static_pic/libcplex.a
-- Configuring done
CMake Error at cpxutils/CMakeLists.txt:25 (add_executable):
Target "cpx_solver" links to target "Cplex::Cplex" but the target was not
found. Perhaps a find_package() call is missing for an IMPORTED target, or
an ALIAS target is missing?
CMake Error at cpxutils/CMakeLists.txt:13 (add_library):
Target "cpxutils" links to target "Cplex::Cplex" but the target was not
found. Perhaps a find_package() call is missing for an IMPORTED target, or
an ALIAS target is missing?
CMake Error at feaspump/CMakeLists.txt:17 (add_executable):
Target "fp2" links to target "Cplex::Cplex" but the target was not found.
Perhaps a find_package() call is missing for an IMPORTED target, or an
ALIAS target is missing?
CMake Error at feaspump/CMakeLists.txt:5 (add_library):
Target "fp" links to target "Cplex::Cplex" but the target was not found.
Perhaps a find_package() call is missing for an IMPORTED target, or an
ALIAS target is missing?
-- Generating done
CMake Generate step failed. Build files cannot be regenerated correctly.
and this is cpxutils/CMakeLists.txt file.
cmake_minimum_required(VERSION 3.6)
# Find CPLEX library
find_package(CPLEX)
# Export CPLEX_FOUND for CMakeLists.txt files in other subdirectories
set(CPLEX_FOUND ${CPLEX_FOUND} PARENT_SCOPE)
if (CPLEX_FOUND)
# Define libcpxutils
add_library(cpxutils STATIC cpxutils.cpp cpxmacro.cpp model.cpp gomory.cpp cpxapp.cpp)
target_include_directories(cpxutils PUBLIC
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}>
$<INSTALL_INTERFACE:include>
)
target_link_libraries(cpxutils PUBLIC utils Cplex::Cplex)
add_library(Cpxutils::Lib ALIAS cpxutils)
# Define cpx_solver executable
add_executable(cpx_solver EXCLUDE_FROM_ALL cpx_solver.cpp)
target_include_directories(cpx_solver PUBLIC
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}>
$<INSTALL_INTERFACE:include>
)
target_link_libraries(cpx_solver PUBLIC utils Cpxutils::Lib)
else()
message(WARNING "Disabling CPXUTILS subproject")
endif()
i don't know why cannot find target despite CPLEX package is found.
i'm using WSL1 (Ubuntu) environment.
↑ problem solved. thanks for #Tsyvarev.
=== additional problem ===
Even though cmake commad works without any error, I cant find execution file. So I checked 'CMakeError.log' file then, there are some error.
This is CMakeError.log file.
Performing C SOURCE FILE Test CMAKE_HAVE_LIBC_PTHREAD failed with the following output:
Change Dir: /mnt/c/Users/aero5010/Desktop/CBC+FP/CBC+FP/fp2/build/CMakeFiles/CMakeTmp
Run Build Command(s):/usr/bin/make cmTC_92254/fast && /usr/bin/make -f CMakeFiles/cmTC_92254.dir/build.make CMakeFiles/cmTC_92254.dir/build
make[1]: Entering directory '/mnt/c/Users/aero5010/Desktop/CBC+FP/CBC+FP/fp2/build/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_92254.dir/src.c.o
/usr/bin/cc -DCMAKE_HAVE_LIBC_PTHREAD -o CMakeFiles/cmTC_92254.dir/src.c.o -c /mnt/c/Users/aero5010/Desktop/CBC+FP/CBC+FP/fp2/build/CMakeFiles/CMakeTmp/src.c
Linking C executable cmTC_92254
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_92254.dir/link.txt --verbose=1
/usr/bin/cc -DCMAKE_HAVE_LIBC_PTHREAD CMakeFiles/cmTC_92254.dir/src.c.o -o cmTC_92254
/usr/bin/ld: CMakeFiles/cmTC_92254.dir/src.c.o: in function `main':
src.c:(.text+0x46): undefined reference to `pthread_create'
/usr/bin/ld: src.c:(.text+0x52): undefined reference to `pthread_detach'
/usr/bin/ld: src.c:(.text+0x63): undefined reference to `pthread_join'
collect2: error: ld returned 1 exit status
make[1]: *** [CMakeFiles/cmTC_92254.dir/build.make:87: cmTC_92254] Error 1
make[1]: Leaving directory '/mnt/c/Users/aero5010/Desktop/CBC+FP/CBC+FP/fp2/build/CMakeFiles/CMakeTmp'
make: *** [Makefile:121: cmTC_92254/fast] Error 2
Source file was:
#include <pthread.h>
void* test_func(void* data)
{
return data;
}
int main(void)
{
pthread_t thread;
pthread_create(&thread, NULL, test_func, NULL);
pthread_detach(thread);
pthread_join(thread, NULL);
pthread_atfork(NULL, NULL, NULL);
pthread_exit(NULL);
return 0;
}
Determining if the function pthread_create exists in the pthreads failed with the following output:
Change Dir: /mnt/c/Users/aero5010/Desktop/CBC+FP/CBC+FP/fp2/build/CMakeFiles/CMakeTmp
Run Build Command(s):/usr/bin/make cmTC_8ae2b/fast && /usr/bin/make -f CMakeFiles/cmTC_8ae2b.dir/build.make CMakeFiles/cmTC_8ae2b.dir/build
make[1]: Entering directory '/mnt/c/Users/aero5010/Desktop/CBC+FP/CBC+FP/fp2/build/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_8ae2b.dir/CheckFunctionExists.c.o
/usr/bin/cc -DCHECK_FUNCTION_EXISTS=pthread_create -o CMakeFiles/cmTC_8ae2b.dir/CheckFunctionExists.c.o -c /usr/share/cmake-3.16/Modules/CheckFunctionExists.c
Linking C executable cmTC_8ae2b
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_8ae2b.dir/link.txt --verbose=1
/usr/bin/cc -DCHECK_FUNCTION_EXISTS=pthread_create CMakeFiles/cmTC_8ae2b.dir/CheckFunctionExists.c.o -o cmTC_8ae2b -lpthreads
/usr/bin/ld: cannot find -lpthreads
collect2: error: ld returned 1 exit status
make[1]: *** [CMakeFiles/cmTC_8ae2b.dir/build.make:87: cmTC_8ae2b] Error 1
make[1]: Leaving directory '/mnt/c/Users/aero5010/Desktop/CBC+FP/CBC+FP/fp2/build/CMakeFiles/CMakeTmp'
make: *** [Makefile:121: cmTC_8ae2b/fast] Error 2
I think this is why i cant find execution file. But I dont know why this error occured despite pthread library is installed well...
** thank you for every advice about Stackoverflow Manners.

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 3.0+Fortran+CUDA requires -fPIC even when building executables

This is a CMake question. I cannot compile Fortran executables with CUDA support when using the Intel Fortran compiler, unless I include the -fPIC flag. The problem is that -fPIC shouldn't be necessary unless I'm building a library.
The following is minimal example:
# CMakeLists.txt
cmake_minimum_required(VERSION 3.0)
project(cuda LANGUAGES Fortran CXX)
find_package(CUDA)
cuda_add_executable(main main.f90)
and
# main.f90
end
When I try to build and run,
cmake -D CMAKE_Fortran_COMPILER=ifort .. && make VERBOSE=1
I get the following:
-- The Fortran compiler identification is Intel 18.0.0.20170811
-- The CXX compiler identification is GNU 7.3.0
-- Check for working Fortran compiler: /opt/intel/compilers_and_libraries_2018.0.128/linux/bin/intel64/ifort
-- Check for working Fortran compiler: /opt/intel/compilers_and_libraries_2018.0.128/linux/bin/intel64/ifort -- works
-- Detecting Fortran compiler ABI info
-- Detecting Fortran compiler ABI info - done
-- Checking whether /opt/intel/compilers_and_libraries_2018.0.128/linux/bin/intel64/ifort supports Fortran 90
-- Checking whether /opt/intel/compilers_and_libraries_2018.0.128/linux/bin/intel64/ifort supports Fortran 90 -- yes
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for C++ include pthread.h
-- Looking for C++ include pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Found CUDA: /opt/cuda (found version "9.1")
-- Configuring done
-- Generating done
-- Build files have been written to: /home/raul/tmp/cuda/build
/usr/bin/cmake -H/home/raul/tmp/cuda -B/home/raul/tmp/cuda/build --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start /home/raul/tmp/cuda/build/CMakeFiles /home/raul/tmp/cuda/build/CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory '/home/raul/tmp/cuda/build'
make -f CMakeFiles/main.dir/build.make CMakeFiles/main.dir/depend
make[2]: Entering directory '/home/raul/tmp/cuda/build'
cd /home/raul/tmp/cuda/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/raul/tmp/cuda /home/raul/tmp/cuda /home/raul/tmp/cuda/build /home/raul/tmp/cuda/build /home/raul/tmp/cuda/build/CMakeFiles/main.dir/DependInfo.cmake --color=
Dependee "/home/raul/tmp/cuda/build/CMakeFiles/main.dir/DependInfo.cmake" is newer than depender "/home/raul/tmp/cuda/build/CMakeFiles/main.dir/depend.internal".
Dependee "/home/raul/tmp/cuda/build/CMakeFiles/CMakeDirectoryInformation.cmake" is newer than depender "/home/raul/tmp/cuda/build/CMakeFiles/main.dir/depend.internal".
Scanning dependencies of target main
make[2]: Leaving directory '/home/raul/tmp/cuda/build'
make -f CMakeFiles/main.dir/build.make CMakeFiles/main.dir/requires
make[2]: Entering directory '/home/raul/tmp/cuda/build'
make[2]: Nothing to be done for 'CMakeFiles/main.dir/requires'.
make[2]: Leaving directory '/home/raul/tmp/cuda/build'
make -f CMakeFiles/main.dir/build.make CMakeFiles/main.dir/build
make[2]: Entering directory '/home/raul/tmp/cuda/build'
[ 50%] Building Fortran object CMakeFiles/main.dir/main.f90.o
/opt/intel/compilers_and_libraries_2018.0.128/linux/bin/intel64/ifort -I/opt/cuda/include -c /home/raul/tmp/cuda/main.f90 -o CMakeFiles/main.dir/main.f90.o
[100%] Linking CXX executable main
/usr/bin/cmake -E cmake_link_script CMakeFiles/main.dir/link.txt --verbose=1
/usr/bin/c++ -rdynamic CMakeFiles/main.dir/main.f90.o -o main /opt/cuda/lib64/libcudart_static.a -lpthread -ldl -lrt -lifport -lifcoremt -limf -lsvml -lipgo -lirc -lpthread -lsvml -lirc_s -ldl
/usr/bin/ld: CMakeFiles/main.dir/main.f90.o: relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/../../../../lib/Scrt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
/usr/bin/ld: final link failed: Invalid operation
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/main.dir/build.make:97: main] Error 1
make[2]: Leaving directory '/home/raul/tmp/cuda/build'
make[1]: *** [CMakeFiles/Makefile2:69: CMakeFiles/main.dir/all] Error 2
make[1]: Leaving directory '/home/raul/tmp/cuda/build'
make: *** [Makefile:84: all] Error 2
I do not get the build error if I use the newer CUDA features of CMake, e.g.
# CMakeLists.txt
cmake_minimum_required(VERSION 3.10)
project(cuda LANGUAGES Fortran CUDA)
add_executable(main main.f90)
However, our current policy is to support CMake 3.0 and thus I cannot the simpler version. Also, I do not get any error if instead of ifort I use gfortran. I'm currently looking into FindCUDA.cmake that ships with CMake, but I haven't found a solution yet. Any thoughts?
I found a solution that works for now, but it's not trivial at all. First, one should use icpc with ifort (not a requirement for CMake >=3.8). It turns out that out of the many libraries that icpc links against under the hood (you won't see them without running make VERBOSE=1), one of them (but not others) should be linked against statically. Thus, by specifying
target_link_libraries(main ifcoremt.a)
in CMakeLists.txt seems to fix the problem, at least for me.

Error cross-compiling cpp-netlib for Raspbian

I've successfully compiled boost using the cross compiler (used the instructions from Installing Raspberry Pi Cross-Compiler) and it worked just fine.
I moved the lib and the include into the rootfs so that cmake finds it... and when I run cmake, I get
gervasio#ubuntu:~/cpp-netlib-0.10.1$ cmake -DCMAKE_TOOLCHAIN_FILE=$HOME/raspberrypi/pi.cmake .
-- The C compiler identification is GNU
-- The CXX compiler identification is GNU
-- Check for working C compiler: /home/gervasio/raspberrypi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-gcc
-- Check for working C compiler: /home/gervasio/raspberrypi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /home/gervasio/raspberrypi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-g++
-- Check for working CXX compiler: /home/gervasio/raspberrypi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Boost version: 1.55.0
-- Found the following Boost libraries:
-- unit_test_framework
-- system
-- regex
-- date_time
-- thread
-- filesystem
-- program_options
-- chrono
-- Found OpenSSL: /home/gervasio/raspberrypi/rootfs/usr/lib/arm-linux-gnueabihf/libssl.so;/home/gervasio/raspberrypi/rootfs/usr/lib/arm-linux-gnueabihf/libcrypto.so (found version "1..1")
-- Looking for include files CMAKE_HAVE_PTHREAD_H
-- Looking for include files CMAKE_HAVE_PTHREAD_H - found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Configuring done
-- Generating done
-- Build files have been written to: /home/gervasio/cpp-netlib-0.10.1
which is awesome... now, when I run make, it ends with
gervasio#ubuntu:~/cpp-netlib-0.10.1$ make
...
[ 15%] Building CXX object libs/network/test/CMakeFiles/cpp-netlib-message_test.dir/message_test.cpp.o
cd /home/gervasio/cpp-netlib-0.10.1/libs/network/test && /home/gervasio/raspberrypi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-g++ -DBOOST_NETWORK_ENABLE_HTTPS -Wall -I/home/gervasio/raspberrypi/rootfs/usr/include -I/home/gervasio/cpp-netlib-0.10.1 -Wall -o CMakeFiles/cpp-netlib-message_test.dir/message_test.cpp.o -c /home/gervasio/cpp-netlib-0.10.1/libs/network/test/message_test.cpp
Linking CXX executable ../../../tests/cpp-netlib-message_test
cd /home/gervasio/cpp-netlib-0.10.1/libs/network/test && /usr/bin/cmake -E cmake_link_script CMakeFiles/cpp-netlib-message_test.dir/link.txt --verbose=1
/home/gervasio/raspberrypi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-g++ -Wall CMakeFiles/cpp-netlib-message_test.dir/message_test.cpp.o -o ../../../tests/cpp-netlib-message_test -rdynamic /home/gervasio/raspberrypi/rootfs/usr/lib/libboost_unit_test_framework.a /home/gervasio/raspberrypi/rootfs/usr/lib/libboost_system.a /home/gervasio/raspberrypi/rootfs/usr/lib/libboost_regex.a /home/gervasio/raspberrypi/rootfs/usr/lib/libboost_date_time.a /home/gervasio/raspberrypi/rootfs/usr/lib/libboost_thread.a -lpthread /home/gervasio/raspberrypi/rootfs/usr/lib/libboost_filesystem.a /home/gervasio/raspberrypi/rootfs/usr/lib/libboost_program_options.a /home/gervasio/raspberrypi/rootfs/usr/lib/libboost_chrono.a -lpthread ../src/libcppnetlib-uri.a /home/gervasio/raspberrypi/rootfs/usr/lib/arm-linux-gnueabihf/libssl.so /home/gervasio/raspberrypi/rootfs/usr/lib/arm-linux-gnueabihf/libcrypto.so -lrt -Wl,-rpath,/home/gervasio/raspberrypi/rootfs/usr/lib/arm-linux-gnueabihf
/home/gervasio/raspberrypi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/../lib/gcc/arm-linux-gnueabihf/4.7.2/../../../../arm-linux-gnueabihf/bin/ld: warning: libz.so.1, needed by /home/gervasio/raspberrypi/rootfs/usr/lib/arm-linux-gnueabihf/libssl.so, not found (try using -rpath or -rpath-link)
/home/gervasio/raspberrypi/rootfs/usr/lib/arm-linux-gnueabihf/libcrypto.so: undefined reference to `deflateInit_'
/home/gervasio/raspberrypi/rootfs/usr/lib/arm-linux-gnueabihf/libcrypto.so: undefined reference to `deflate'
/home/gervasio/raspberrypi/rootfs/usr/lib/arm-linux-gnueabihf/libcrypto.so: undefined reference to `deflateEnd'
/home/gervasio/raspberrypi/rootfs/usr/lib/arm-linux-gnueabihf/libcrypto.so: undefined reference to `inflate'
/home/gervasio/raspberrypi/rootfs/usr/lib/arm-linux-gnueabihf/libcrypto.so: undefined reference to `inflateInit_'
/home/gervasio/raspberrypi/rootfs/usr/lib/arm-linux-gnueabihf/libcrypto.so: undefined reference to `inflateEnd'
/home/gervasio/raspberrypi/rootfs/usr/lib/arm-linux-gnueabihf/libcrypto.so: undefined reference to `zError'
collect2: error: ld returned 1 exit status
make[2]: *** [tests/cpp-netlib-message_test] Error 1
make[2]: Leaving directory `/home/gervasio/cpp-netlib-0.10.1'
make[1]: *** [libs/network/test/CMakeFiles/cpp-netlib-message_test.dir/all] Error 2
make[1]: Leaving directory `/home/gervasio/cpp-netlib-0.10.1'
make: *** [all] Error 2
but... inside ~/raspberrypi/rootfs/lib/arm-linux-gnueabihf there's a libz.so.1
gervasio#ubuntu:~/raspberrypi/rootfs/lib/arm-linux-gnueabihf$ ls -lah libz.so*
lrwxrwxrwx 1 gervasio gervasio 13 Jun 24 2012 libz.so.1 -> libz.so.1.2.7
-rw-r--r-- 1 gervasio gervasio 86K Jun 24 2012 libz.so.1.2.7
I know it's failing just on the test, and that I can use the libraries... but I'd really like to have a good environment to cross compile whatever I need.
Thanks for your help :)
edit: just ran ldd libssl.so on the raspberry and got
/usr/lib/arm-linux-gnueabihf/libcofi_rpi.so (0xb6ec6000)
libcrypto.so.1.0.0 => /usr/lib/arm-linux-gnueabihf/libcrypto.so.1.0.0 (0xb6d57000)
libdl.so.2 => /lib/arm-linux-gnueabihf/libdl.so.2 (0xb6d4c000)
libz.so.1 => /lib/arm-linux-gnueabihf/libz.so.1 (0xb6d2e000)
libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0xb6bff000)
/lib/ld-linux-armhf.so.3 (0xb6f24000)
libgcc_s.so.1 => /lib/arm-linux-gnueabihf/libgcc_s.so.1 (0xb6bd7000)
edit 2: If I run cmake with -DCMAKE_SKIP_BUILD_RPATH=FALSE -DCMAKE_BUILD_WITH_INSTALL_RPATH=FALSE -DCMAKE_INSTALL_RPATH=/home/gervasio/raspberrypi/rootfs/lib/arm-linux-gnueabihf -DCMAKE_INSTALL_RPATH_USE_LINK_PATH=TRUE I get this output
/home/gervasio/raspberrypi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-g++ -Wall CMakeFiles/cpp-netlib-message_test.dir/message_test.cpp.o -o ../../../tests/cpp-netlib-message_test -rdynamic /home/gervasio/raspberrypi/rootfs/usr/lib/libboost_unit_test_framework.a /home/gervasio/raspberrypi/rootfs/usr/lib/libboost_system.a /home/gervasio/raspberrypi/rootfs/usr/lib/libboost_regex.a /home/gervasio/raspberrypi/rootfs/usr/lib/libboost_date_time.a /home/gervasio/raspberrypi/rootfs/usr/lib/libboost_thread.a -lpthread /home/gervasio/raspberrypi/rootfs/usr/lib/libboost_filesystem.a /home/gervasio/raspberrypi/rootfs/usr/lib/libboost_program_options.a /home/gervasio/raspberrypi/rootfs/usr/lib/libboost_chrono.a -lpthread ../src/libcppnetlib-uri.a /home/gervasio/raspberrypi/rootfs/usr/lib/arm-linux-gnueabihf/libssl.so /home/gervasio/raspberrypi/rootfs/usr/lib/arm-linux-gnueabihf/libcrypto.so -lrt -Wl,-rpath,/home/gervasio/raspberrypi/rootfs/usr/lib/arm-linux-gnueabihf
/home/gervasio/raspberrypi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/../lib/gcc/arm-linux-gnueabihf/4.7.2/../../../../arm-linux-gnueabihf/bin/ld: warning: libz.so.1, needed by /home/gervasio/raspberrypi/rootfs/usr/lib/arm-linux-gnueabihf/libssl.so, not found (try using -rpath or -rpath-link)
where it says -rpath,/home/gervasio/raspberrypi/rootfs/usr/lib/arm-linux-gnueabihf that doesn't seem ok, right?
Thanks to #ruslo and that link he posted, I figured it out... this is the way to tell cmake to use rpath
cmake -DCMAKE_TOOLCHAIN_FILE=$HOME/raspberrypi/pi.cmake -DCMAKE_SKIP_BUILD_RPATH=FALSE -DCMAKE_BUILD_WITH_INSTALL_RPATH=TRUE -DCMAKE_INSTALL_RPATH=/home/gervasio/raspberrypi/rootfs/lib/arm-linux-gnueabihf -DCMAKE_INSTALL_RPATH_USE_LINK_PATH=TRUE .