Building Apache Arrow inside existing C++ Executable project CMAKE - c++

I'm working on a C++ CMake project that uses Apache Arrow as a dependency. My goal is to be able to include and use arrow/api.h. However, I couldn't find any documentation or tutorial that explains what I can do to achieve that so my first thought was to add it as a third library using CMake's FetchContent, hence, I added the following code to my CMakeLists.txt:
include(FetchContent REQUIRED)
# INCLUDING APACHE ARROW ================================ #
message(STATUS "Searching for Apache Arrow")
FetchContent_Declare(
arrow
GIT_REPOSITORY https://github.com/apache/arrow.git
GIT_TAG apache-arrow-0.15.1
)
FetchContent_GetProperties(arrow)
if(NOT arrow_POPULATED)
message(STATUS "Populating Arrow")
FetchContent_Populate(arrow)
add_subdirectory(${arrow_SOURCE_DIR}/cpp ${arrow_BINARY_DIR})
endif()
I can find the code inside my project now - still can't use include arrow/api.h though - but whenever I try to build it I receive errors from the CMakeLists.txt of Apache Arrow cpp src directory! Here's the CMake build log that contains the error:
-- Searching for Apache Arrow
-- Populating Arrow
-- Building using CMake version: 3.15.3
-- Arrow version: 0.15.1 (full: '0.15.1')
-- Arrow SO version: 15 (full: 15.1.0)
-- clang-tidy not found
-- clang-format not found
-- infer not found
-- Could NOT find PythonInterp (missing: PYTHON_EXECUTABLE)
-- Found cpplint executable at CPPLINT_BIN-NOTFOUND
-- Compiler command: C:/MinGW/bin/g++.exe -v
-- Compiler version: Using built-in specs.
COLLECT_GCC=C:/MinGW/bin/g++.exe
COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/8.2.0/lto-wrapper.exe
Target: mingw32
Configured with: ../src/gcc-8.2.0/configure --build=x86_64-pc-linux-gnu --host=mingw32 --target=mingw32 --prefix=/mingw --disable-win32-registry --with-arch=i586 --with-tune=generic --enable-languages=c,c++,objc,obj-c++,fortran,ada --with-pkgversion='MinGW.org GCC-8.2.0-3' --with-gmp=/mingw --with-mpfr=/mingw --with-mpc=/mingw --enable-static --enable-shared --enable-threads --with-dwarf2 --disable-sjlj-exceptions --enable-version-specific-runtime-libs --with-libiconv-prefix=/mingw --with-libintl-prefix=/mingw --enable-libstdcxx-debug --with-isl=/mingw --enable-libgomp --disable-libvtv --enable-nls --disable-build-format-warnings
Thread model: win32
gcc version 8.2.0 (MinGW.org GCC-8.2.0-3)
-- Compiler id: GNU
Selected compiler gcc 8.2.0
-- Arrow build warning level: CHECKIN
Configured for DEBUG build (set with cmake -DCMAKE_BUILD_TYPE={release,debug,...})
-- Build Type: DEBUG
-- Using approach to find dependencies
-- AWSSDK_VERSION: 1.7.160
-- BOOST_VERSION: 1.67.0
-- BROTLI_VERSION: v1.0.7
-- BZIP2_VERSION: 1.0.8
-- CARES_VERSION: 1.15.0
-- DOUBLE_CONVERSION_VERSION: v3.1.5
-- FLATBUFFERS_VERSION: v1.11.0
-- GBENCHMARK_VERSION: v1.5.0
-- GFLAGS_VERSION: v2.2.0
-- GLOG_VERSION: v0.3.5
-- GRPC_VERSION: v1.20.0
-- GTEST_VERSION: 1.8.1
-- JEMALLOC_VERSION: 5.2.1
-- LZ4_VERSION: v1.8.3
-- MIMALLOC_VERSION: 270e765454f98e8bab9d42609b153425f749fff6
-- ORC_VERSION: 1.5.5
-- PROTOBUF_VERSION: v3.7.1
-- RAPIDJSON_VERSION: 2bbd33b33217ff4a73434ebf10cdac41e2ef5e34
-- RE2_VERSION: 2019-08-01
-- SNAPPY_VERSION: 1.1.7
-- THRIFT_VERSION: 0.12.0
-- THRIFT_MD5_CHECKSUM: 3deebbb4d1ca77dd9c9e009a1ea02183
-- URIPARSER_VERSION: 0.9.3
-- ZLIB_VERSION: 1.2.11
-- ZSTD_VERSION: v1.4.3
-- Boost include dir:
-- Boost libraries:
-- Performing Test DOUBLE_CONVERSION_HAS_CASE_INSENSIBILITY
-- Performing Test DOUBLE_CONVERSION_HAS_CASE_INSENSIBILITY - Failed
-- Building without OpenSSL support. Minimum OpenSSL version 1.0.2 required.
-- Found hdfs.h at: D:/School/Research Project/TestApacheArrow/cmake-build-debug/_deps/arrow-src/cpp/thirdparty/hadoop/include/hdfs.h
-- CMAKE_C_FLAGS: -g -O0 -Wall -Wno-conversion -Wno-sign-conversion -Wno-unused-variable -Werror
-- CMAKE_CXX_FLAGS: -Wno-noexcept-type -fdiagnostics-color=always -g -O0 -Wall -Wno-conversion -Wno-sign-conversion -Wno-unused-variable -Werror
CMake Error at cmake-build-debug/_deps/arrow-src/cpp/src/arrow/CMakeLists.txt:362 (add_dependencies):
add_dependencies called with incorrect number of arguments
CMake Error at cmake-build-debug/_deps/arrow-src/cpp/CMakeLists.txt:814 (export):
export Export set "arrow-targets" not found.
-- ---------------------------------------------------------------------
-- Arrow version: 0.15.1
--
-- Build configuration summary:
-- Generator: MinGW Makefiles
-- Build type: DEBUG
-- Source directory: D:/School/Research Project/TestApacheArrow/cmake-build-debug/_deps/arrow-src/cpp
-- Install prefix: C:/Program Files (x86)/TestApacheArrow
-- Configuring incomplete, errors occurred!
See also "/cmake-build-debug/CMakeFiles/CMakeOutput.log".
See also "/cmake-build-debug/CMakeFiles/CMakeError.log".
Am I missing something here? is this the correct way to include Apache Arrow in an existing project? Any idea how can I fix this error?
I'm using Windows 10 but would finally want to run the project on Linux!

We don't currently support including Apache Arrow in another CMake project using add_subdirectory. You can use ExternalProject_Add, though, and it should work. It should also be possible to use CMake's built-in find_package facility to find a pre-built package.
We would like to provide well-documented and straightforward solutions for C++ developers including Apache Arrow in their CMake projects. We'd be glad to discuss further on our developer mailing list dev#arrow.apache.org

Related

Debian, cmake, connot compile c++ program, missing config cmake file

Trying to compile dot11decrypt on debian, installed apt-get install libtins4.0 and apt-get install libtins-dev, but cmake .. can't find package libtins, heres the error:
CMake Error at CMakeLists.txt:4 (FIND_PACKAGE):
By not providing "Findlibtins.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "libtins", but
CMake did not find one.
Could not find a package configuration file provided by "libtins" with any
of the following names:
libtinsConfig.cmake
libtins-config.cmake
Add the installation prefix of "libtins" to CMAKE_PREFIX_PATH or set
"libtins_DIR" to a directory containing one of the above files. If
"libtins" provides a separate development package or SDK, be sure it has
been installed.
-- Configuring incomplete, errors occurred!
See also "/home/user/dot11decrypt/build/CMakeFiles/CMakeOutput.log".
cat:dot11decrypt/CMakeLists.txt
1. CMAKE_MINIMUM_REQUIRED(VERSION 2.8.1)
2. PROJECT(dot11decrypt)
3.
4. FIND_PACKAGE(libtins REQUIRED)
5.
6. SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
7.
8. ADD_EXECUTABLE(dot11decrypt dot11decrypt.cpp)
9. TARGET_LINK_LIBRARIES(dot11decrypt ${LIBTINS_LIBRARIES} pthread)
find / -name Findlibtins.cmake or libtinsConfig.cmake brings no result.
I found those files on internet but still no success, i think i have to install something but don't know what.
I went with Tsyvarev solution.
# installing missing dependencies for libtins
apt-get install libpcap-dev libssl-dev cmake
# installing libtins
git clone https://github.com/mfontanini/libtins.git
cd libtins
mkdir build
cd build
cmake ../
make
checkinstall
Now cmake will reach dot11decrypt missing files.
# installing dot11decrypt
git clone https://github.com/mfontanini/dot11decrypt.git
cd dot11decrypt/
mkdir build
cd build/
cmake ../
make
Now you should have dot11decrypt executable.
If i would have to do it again i would try Alex Reinking solution first.
You don't need to compile from source... find_package is a very flexible configuration point! You'll just need to provide your own find module that is sufficient for the build. Fortunately, this is very simple. Here's what I did:
$ https://github.com/mfontanini/dot11decrypt
$ cd dot11decrypt
$ mkdir _patches
$ vim _patches/Findlibtins.cmake
$ cat _patches/Findlibtins.cmake
find_package(PkgConfig REQUIRED)
pkg_check_modules(LIBTINS REQUIRED libtins)
$ cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_MODULE_PATH=$PWD/_patches
CMake Deprecation Warning at CMakeLists.txt:1 (CMAKE_MINIMUM_REQUIRED):
Compatibility with CMake < 2.8.12 will be removed from a future version of
CMake.
Update the VERSION argument <min> value or use a ...<max> suffix to tell
CMake that the project does not need compatibility with older versions.
-- The C compiler identification is GNU 9.4.0
-- The CXX compiler identification is GNU 9.4.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.1")
-- Checking for module 'libtins'
-- Found libtins, version 4.0
-- Configuring done
-- Generating done
-- Build files have been written to: /home/alex/test/dot11decrypt/build
$ cmake --build build/
[ 50%] Building CXX object CMakeFiles/dot11decrypt.dir/dot11decrypt.cpp.o
/home/alex/test/dot11decrypt/dot11decrypt.cpp: In function ‘void decrypt_traffic(unique_fd, const string&, decrypter_tuple)’:
/home/alex/test/dot11decrypt/dot11decrypt.cpp:333:39: warning: ‘Tins::Sniffer::Sniffer(const string&, unsigned int, bool, const string&, bool)’ is deprecated [-Wdeprecated-declarations]
333 | Sniffer sniffer(iface, 2500, false);
| ^
In file included from /usr/include/tins/dns.h:38,
from /usr/include/tins/tins.h:33,
from /home/alex/test/dot11decrypt/dot11decrypt.cpp:25:
/usr/include/tins/sniffer.h:369:5: note: declared here
369 | TINS_DEPRECATED(Sniffer(const std::string& device, unsigned max_packet_size,
| ^~~~~~~~~~~~~~~
[100%] Linking CXX executable dot11decrypt
[100%] Built target dot11decrypt
The key here is to create a minimal Find module. This is just two lines on my system since it isn't meant to be reusable...
# _patches/Findlibtins.cmake
find_package(PkgConfig REQUIRED)
pkg_check_modules(LIBTINS REQUIRED libtins)
This just delegates the responsibility of setting the LIBTINS_LIBRARIES to pkg-config. To connect this find module to the build, I just set -DCMAKE_MODULE_PATH=$PWD/_patches at the CMake configure command line.
Also, you should definitely open a bug report with the dot11decrypt author about their broken and outdated build. Notice the strongly worded deprecation warning in the logs I posted.

How to get rid of link error in FreeGLUT MS Visual Studio project build with Cmake + Conan?

Im trying build freeGLUT project with cmake and conan for MS Visual Studio, but when I build it return link error LNK1104 "Cant open file "freeglut.lib" for Release and "Cant open file "freeglutd.lib" for Debug.
Visual Studio 16 2019
Cmake 3.20.3
Conan 1.39.0
Project Tree
CMakeLists.txt
cmake_minimum_required(VERSION 3.20)
project(OpenGLConan)
include(${CMAKE_BINARY_DIR}/conan_paths.cmake)
add_subdirectory(src)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
find_package(FreeGLUT)
target_include_directories(${PROJECT_NAME} PUBLIC ${FreeGLUT_INCLUDE_DIRS})
target_link_libraries(${PROJECT_NAME} ${FreeGLUT_LIBRARIES})
conanfile.txt
[requires]
freeglut/3.2.1
[generators]
cmake_find_package
cmake_paths
src/CMakeLists.txt
add_executable(${PROJECT_NAME} main.cpp)
src/main.cpp
#include <iostream>
#include <GL/glut.h>
int main(int argc, char** argv)
{
glutInit(&argc, argv);
/* Create a single window with a keyboard and display callback */
glutCreateWindow("GLUT Test");
/* Run the GLUT event loop */
glutMainLoop();
return EXIT_SUCCESS;
}
Edit
In CMakeLists.txt I added
...
if(${FreeGLUT_FOUND})
message(STATUS "-----LIB FOUND!!!-----")
target_include_directories(${PROJECT_NAME} PUBLIC ${FreeGLUT_INCLUDE_DIRS})
target_link_libraries(${PROJECT_NAME} ${FreeGLUT_LIBRARIES})
endif()
...
Information from the console.
$ conan install ..
Configuration:
[settings]
arch=x86_64
arch_build=x86_64
build_type=Release
compiler=Visual Studio
compiler.runtime=MD
compiler.version=16
os=Windows
os_build=Windows
[options]
[build_requires]
[env]
conanfile.txt: Installing package
Requirements
freeglut/3.2.1 from 'conancenter' - Cache
glu/system from 'conancenter' - Cache
opengl/system from 'conancenter' - Cache
Packages
freeglut/3.2.1:d72ca9d65490ffa06c751d72974c9906d3454d5c - Cache
glu/system:5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9 - Cache
opengl/system:5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9 - Cache
Installing (downloading, building) binaries...
opengl/system: Already installed!
glu/system: Already installed!
freeglut/3.2.1: Already installed!
conanfile.txt: Generator cmake_paths created conan_paths.cmake
conanfile.txt: Generator txt created conanbuildinfo.txt
conanfile.txt: Generator cmake_find_package created FindFreeGLUT.cmake
conanfile.txt: Generator cmake_find_package created Findglu.cmake
conanfile.txt: Generator cmake_find_package created Findopengl_system.cmake
conanfile.txt: Aggregating env generators
conanfile.txt: Generated conaninfo.txt
conanfile.txt: Generated graphinfo
Антон#LAPTOP-4L8RSG2A MINGW64 /d/GitHub/OpenGLConan/build
$ cmake .. -G "Visual Studio 16 2019"
-- Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.19042.
-- The C compiler identification is MSVC 19.29.30038.1
-- The CXX compiler identification is MSVC 19.29.30038.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30037/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30037/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Conan: Using autogenerated FindFreeGLUT.cmake
-- Found FreeGLUT: 3.2.1 (found version "3.2.1")
-- Library glut found C:/Users/Anton/.conan/data/freeglut/3.2.1/_/_/package/d72ca9d65490ffa06c751d72974c9906d3454d5c/lib/glut.lib
-- Found: C:/Users/Anton/.conan/data/freeglut/3.2.1/_/_/package/d72ca9d65490ffa06c751d72974c9906d3454d5c/lib/glut.lib
-- Conan: Using autogenerated Findopengl_system.cmake
-- Found opengl_system: system (found version "system")
-- Conan: Using autogenerated Findglu.cmake
-- Found glu: system (found version "system")
-- Dependency opengl_system already found
-- Library glut found C:/Users/Anton/.conan/data/freeglut/3.2.1/_/_/package/d72ca9d65490ffa06c751d72974c9906d3454d5c/lib/glut.lib
-- Found: C:/Users/Anton/.conan/data/freeglut/3.2.1/_/_/package/d72ca9d65490ffa06c751d72974c9906d3454d5c/lib/glut.lib
-- -----LIB FOUND!!!-----
-- Configuring done
-- Generating done
-- Build files have been written to: D:/GitHub/OpenGLConan/build
Антон#LAPTOP-4L8RSG2A MINGW64 /d/GitHub/OpenGLConan/build
$ cmake --build .
Microsoft (R) Build Engine версии 16.10.2+857e5a733 для .NET Framework
(C) Корпорация Майкрософт (Microsoft Corporation). Все права защищены.
Checking Build System
Building Custom Rule D:/GitHub/OpenGLConan/src/CMakeLists.txt
main.cpp
LINK : fatal error LNK1104: не удается открыть файл "freeglutd.lib" [D:\GitHub\OpenGLConan\build\src\OpenGLConan.vcxproj]
I think the problem here is in the conanfile of freeglut. Conan file be default says in packaging:
self.cpp_info.components["freeglut_"].names["pkg_config"] = "freeglut" if self.settings.os == "Windows" else "glut"
So it tries to find freeglut.
At the same time be default conanfile sets "replace_glut": True. From Cmake this option sets:
option to build either as "glut" (ON) or "freeglut" (OFF)
So your library is built as glut, but conanfile still tries to find freeglut.
I would suggest you try to build conan package with option replace_glut=False
If that fixes the issue, pls open a bug here: https://github.com/conan-io/conan-center-index/issues

How to compile Boost-1.76.0 with Emscripten-1.38.31 (??)

I've searched high and low for this answer and I think it should be answered in a modern setting. Most things I see are from 2013 or at the latest 2015 with comments from 2019.
to start off I am using macOS 11.2 with the most recent version of xcode 12.4.
I cloned and installed from git the most recent (as of today) repositories for boost and emscripten.
for some reason on my project when trying to integrate enscripten flags into my CMakeLists.txt file I get an error running
$ cmake .. then $ make.
the CMakeLists.txt file:
cmake_minimum_required(VERSION 3.17)
project(FernQuest) #emscripten version
if (${CMAKE_SYSTEM_NAME} MATCHES "Emscripten")
message(STATUS "using emscripten")
endif ()
if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Emscripten")
message(STATUS "using cmake")
endif ()
#options
option(JS_ONLY "Compiles to native JS (No WASM)" OFF)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/out)
include_directories(.)
include_directories(/usr/local/include) #where boost in located
message(STATUS "finding boost!")
find_package(Boost 1.74.0 REQUIRED serialization system filesystem COMPONENTS serialization system filesystem)
if(Boost_FOUND)
message(STATUS "found boost!")
endif()
include_directories(${Boost_INCLUDE_DIR})
link_directories(${Boost_LIBRARY_DIR})
if(NOT Boost_FOUND)
message(FATAL_ERROR "Could not find boost!")
endif()
message(STATUS "setting sources")
SET(FQ_SRCS
../src/FernQuest.cpp
../src/Item.cpp
../src/Item.h
../src/Player.cpp
../src/Player.h
../src/Game.cpp
../src/Game.h
../src/QuestLog.cpp
../src/QuestLog.h)
SET(CMAKE_C_COMPILER emcc)
SET(CMAKE_CPP_COMPILER em++)
add_executable(FernQuest ${FQ_SRCS})
if(Boost_FOUND)
if(JS_ONLY)
message(STATUS "Setting compilation target to native JavaScript")
set(CMAKE_EXECUTABLE_SUFFIX ".js")
set_target_properties(FernQuest PROPERTIES COMPILE_FLAGS "-s USE_BOOST_HEADERS=1" LINK_FLAGS "-s USE_BOOST_HEADERS=1 -s WASM=0 -s EXPORTED_FUNCTIONS='[_main]'")
else(JS_ONLY)
message(STATUS "Setting compilation target to WASM")
set(CMAKE_EXECUTABLE_SUFFIX ".wasm.js")
set_target_properties(FernQuest PROPERTIES COMPILE_FLAGS "-s USE_BOOST_HEADERS=1" LINK_FLAGS " -s USE_BOOST_HEADERS=1 -s WASM=1 -s EXPORTED_FUNCTIONS='[_main]'")
endif(JS_ONLY)
endif()
the error:
-- The C compiler identification is AppleClang 12.0.0.12000032
-- The CXX compiler identification is AppleClang 12.0.0.12000032
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- using cmake
-- finding boost!
-- Found Boost: /usr/local/lib/cmake/Boost-1.76.0/BoostConfig.cmake (found suitable version "1.76.0", minimum required is "1.74.0") found components: serialization system filesystem serialization system filesystem
-- found boost!
-- setting sources
-- Setting compilation target to WASM
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/codiecottrell/Documents/FernQuest/emscripten/build
Scanning dependencies of target FernQuest
[ 16%] Building CXX object CMakeFiles/FernQuest.dir/Users/codiecottrell/Documents/FernQuest/src/FernQuest.cpp.o
clang: error: no such file or directory: 'USE_BOOST_HEADERS=1'
make[2]: *** [CMakeFiles/FernQuest.dir/Users/codiecottrell/Documents/FernQuest/src/FernQuest.cpp.o] Error 1
make[1]: *** [CMakeFiles/FernQuest.dir/all] Error 2
make: *** [all] Error 2
so I read up and they say that to fix this you use this below as to actually run it using the -DCMAKE_TOOLCHAIN_FILE:
$ emcmake cmake .. then $ emmake make
this error occurs:
configure: cmake .. -DCMAKE_TOOLCHAIN_FILE=/Users/codiecottrell/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake -DCMAKE_CROSSCOMPILING_EMULATOR="/Users/codiecottrell/emsdk/node/14.15.5_64bit/bin/node"
-- using emscripten
-- finding boost!
CMake Error at /usr/local/Cellar/cmake/3.19.4/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:218 (message):
Could NOT find Boost (missing: Boost_INCLUDE_DIR serialization system
filesystem serialization system filesystem) (Required is at least version
"1.74.0")
Call Stack (most recent call first):
/usr/local/Cellar/cmake/3.19.4/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:582 (_FPHSA_FAILURE_MESSAGE)
/usr/local/Cellar/cmake/3.19.4/share/cmake/Modules/FindBoost.cmake:2193 (find_package_handle_standard_args)
CMakeLists.txt:21 (find_package)
-- Configuring incomplete, errors occurred!
See also "/Users/codiecottrell/Documents/FernQuest/emscripten/build/CMakeFiles/CMakeOutput.log".
make: make
-- using emscripten
-- finding boost!
CMake Error at /usr/local/Cellar/cmake/3.19.4/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:218 (message):
Could NOT find Boost (missing: Boost_INCLUDE_DIR serialization system
filesystem serialization system filesystem) (Required is at least version
"1.74.0")
Call Stack (most recent call first):
/usr/local/Cellar/cmake/3.19.4/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:582 (_FPHSA_FAILURE_MESSAGE)
/usr/local/Cellar/cmake/3.19.4/share/cmake/Modules/FindBoost.cmake:2193 (find_package_handle_standard_args)
CMakeLists.txt:21 (find_package)
-- Configuring incomplete, errors occurred!
See also "/Users/codiecottrell/Documents/FernQuest/emscripten/build/CMakeFiles/CMakeOutput.log".
make: *** [cmake_check_build_system] Error 1
My Question:
it seems that enscripten cannot find boost when running it through its own means, however cmake can clearly find it. There is also support for running boost through emscripten as I've read in both documentations however there is no clear way. What is this way and where am I going wrong? I'm going to continue to troubleshoot
EDIT
just tried $ emconfigure ./b2 toolset=gcc --prefix=/usr/local/B2
and it didn't change anything
If you're building with emscripten then the libraries on your mac (where cmake is searching) won't work; you will need to compile them statically.
I recommend trying to build your project without CMake.
If you're project only uses the boost headers (not libraries), then something like this might work:
$ em++ ../src/*.cpp -o index.html -s USE_BOOST_HEADERS=1
Otherwise you'll need to compile Boost also. Once you've done that and you have a libboost.a file, you'd compile your program like this:
$ em++ ../src/*.cpp -c -s USE_BOOST_HEADERS=1
Then link it:
$ em++ *.o /path/to/libboost.a -o index.html
Of course, depending on what other libraries you use you'll need to tweak those commands. But the general idea is to compile all the dependencies into static archive (.a) files, then compile those together to get the resulting .html (or .js or .wasm) file.
Read more about compiling with emcc.

CMake cannot find 32 bit Open SSL on 64 bit Ubuntu 14.04

I have a 64 bit Ubuntu 14.04 VM and I am trying to compile a 32 bit application that depends on openssl and I keep getting the following error:
-- The C compiler identification is GNU 4.8.4
-- The CXX compiler identification is GNU 4.8.4
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/g++
-- Check for working CXX compiler: /usr/bin/g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
CMake Error at /usr/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:108 (message):
Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the
system variable OPENSSL_ROOT_DIR (missing: OPENSSL_LIBRARIES) (found
version "1.0.1f")
I have created the following test case to reproduce the error.
DockerFile
FROM ubuntu:trusty
LABEL maintainer="Diarra_Bakary#test.com"
LABEL version="1.0"
RUN dpkg --add-architecture i386 && \
apt-get update && \
apt-get install -y \
git\
cmake\
curl:i386\
libcurl4-openssl-dev:i386\
libssl-dev:i386\
uuid-dev:i386
RUN apt-get install -y \
gcc-multilib\
g++-multilib
CMakeLists.txt
cmake_minimum_required(VERSION 2.8)
find_package(OpenSSL REQUIRED)
x86_32.cmake
SET(CMAKE_SYSTEM_NAME Linux)
# which compilers to use for C and C++
set(CMAKE_C_COMPILER gcc)
set(CMAKE_C_FLAGS -m32)
set(CMAKE_CXX_COMPILER g++)
set(CMAKE_CXX_FLAGS -m32)
Run the following commands
mkdir cmake
cd cmake
cmake -DCMAKE_TOOLCHAIN_FILE=x86_32.cmake ..
Thanks in advance
I was able to fix my issue by adding the following lines to my toolchain:
# Specify Openssl Path
SET(CMAKE_LIBRARY_PATH "/usr/lib/i386-linux-gnu")
include_directories(BEFORE /usr/include/i386-linux-gnu)
Thank you #Tsyvarev for your recommendation !
CMake suggests to try to set the path to OpenSSL root folder in the system variable OPENSSL_ROOT_DIR.
Indeed, FindOpenSSL.cmake features an option OPENSSL_ROOT_DIR which can be provided to specify the location of the install directory of OpenSSL.
Could you try something like that in your CMakeList.txt:
cmake_minimum_required(VERSION 2.8)
set(OPENSSL_ROOT_DIR /usr/local/ssl)
message("OPENSSL_ROOT_DIR is " ${OPENSSL_ROOT_DIR})
find_package(OpenSSL REQUIRED)
message("OPENSSL_FOUND is " ${OPENSSL_FOUND})
message("OPENSSL_INCLUDE_DIR is " ${OPENSSL_INCLUDE_DIR})
message("OPENSSL_CRYPTO_LIBRARY is " ${OPENSSL_CRYPTO_LIBRARY})
message("OPENSSL_SSL_LIBRARY is " ${OPENSSL_SSL_LIBRARY})
message("OPENSSL_LIBRARIES is " ${OPENSSL_LIBRARIES})
message("OPENSSL_VERSION is " ${OPENSSL_VERSION})
Of course, the folder /usr/local/ssl must be tuned to specify the installation directory, where you will find folder lib and include. In folder lib, you will find the libraries libcrypto.a and libssl.a and you will find a lot of header (.h) files in include/openssl.
Edit: if the intallation is not standard, then the environment variables must be set to the correct values without calling find_package(). For example, mine are:
OPENSSL_ROOT_DIR is /usr/local/ssl
OPENSSL_FOUND is TRUE
OPENSSL_INCLUDE_DIR is /usr/local/ssl/include
OPENSSL_CRYPTO_LIBRARY is /usr/local/ssl/lib/libcrypto.a
OPENSSL_SSL_LIBRARY is /usr/local/ssl/lib/libssl.a
OPENSSL_LIBRARIES is /usr/local/ssl/lib/libssl.a/usr/local/ssl/lib/libcrypto.a
OPENSSL_VERSION is 1.0.2d
Then, target_include_directories(), link_directories() and target_link_libraries() can be used.

The CXX compiler identification is unknown: xcode

I am trying to install an external library into my C++ project using Cmake. I want the Xcode project to be produced with that library. In my terminal i run the following from the build directory:
cmake -G Xcode ..
and that gives me the following errors:
-- The CXX compiler identification is unknown
-- The C compiler identification is unknown
CMake Error at CMakeLists.txt:6 (project):
No CMAKE_CXX_COMPILER could be found.
CMake Error at CMakeLists.txt:6 (project):
No CMAKE_C_COMPILER could be found.
I am using g++ compiler:
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 7.0.0 (clang-700.1.76)
Target: x86_64-apple-darwin14.5.0
Thread model: posix
Edit: CMakeLists.txt file
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/VERSION" PROJECT_VERSION_FULL)
string(REGEX REPLACE "[\n\r]" "" PROJECT_VERSION_FULL "${PROJECT_VERSION_FULL}")
string(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.[0-9]+$" "\\1" PROJECT_VERSION_MAJOR "${PROJECT_VERSION_FULL}")
string(REGEX REPLACE "^[0-9]+\\.([0-9]+)\\.[0-9]+$" "\\1" PROJECT_VERSION_MINOR "${PROJECT_VERSION_FULL}")
string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+)$" "\\1" PROJECT_VERSION_PATCH "${PROJECT_VERSION_FULL}")
set(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}")
math(EXPR LIBRARY_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}")
set(LIBRARY_VERSION_MINOR "${PROJECT_VERSION_MINOR}")
set(LIBRARY_VERSION_PATCH "${PROJECT_VERSION_PATCH}")
set(LIBRARY_VERSION "${LIBRARY_VERSION_MAJOR}.${LIBRARY_VERSION_MINOR}")
set(LIBRARY_VERSION_FULL "${LIBRARY_VERSION}.${LIBRARY_VERSION_PATCH}")
option(CODE_COVERAGE "Set ON to add code coverage compile options" OFF)
option(GENERATE_DOC "Set ON to genrate doxygen API reference in build/doc directory" OFF)
# C++11 compiler Check
if(NOT CMAKE_CXX_COMPILER_VERSION) # work around for cmake versions smaller than 2.8.10
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE CMAKE_CXX_COMPILER_VERSION)
endif()
if(CMAKE_CXX_COMPILER MATCHES ".*clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(CMAKE_COMPILER_IS_CLANGXX 1)
endif()
if( (CMAKE_COMPILER_IS_GNUCXX AND ${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 4.7) OR
(CMAKE_COMPILER_IS_CLANGXX AND ${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 3.2))
message(FATAL_ERROR "Your C++ compiler does not support C++11. Please install g++ 4.7 (or greater) or clang 3.2 (or greater)")
else()
message(STATUS "Compiler is recent enough to support C++11.")
endif()
if( CMAKE_COMPILER_IS_GNUCXX )
append_cxx_compiler_flags("-std=c++11 -Wall -Wextra -DNDEBUG" "GCC" CMAKE_CXX_FLAGS)
append_cxx_compiler_flags("-O3 -ffast-math -funroll-loops" "GCC" CMAKE_CXX_OPT_FLAGS)
if ( CODE_COVERAGE )
append_cxx_compiler_flags("-g -fprofile-arcs -ftest-coverage -lgcov" "GCC" CMAKE_CXX_FLAGS)
endif()
else()
if(MSVC)
append_cxx_compiler_flags("/EHsc" "MSVC" CMAKE_CXX_FLAGS)
append_cxx_compiler_flags("/Od" "MSVC" CMAKE_CXX_FLAGS_DEBUG)
append_cxx_compiler_flags("/Ox" "MSVC" CMAKE_CXX_FLAGS_RELEASE)
set(vars CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
foreach(var ${vars})
string(REPLACE "/MD" "-MT" ${var} "${${var}}")
endforeach(var)
add_definitions("/DMSVC_COMPILER")
else()
append_cxx_compiler_flags("-std=c++11 -DNDEBUG" "CLANG" CMAKE_CXX_FLAGS)
append_cxx_compiler_flags("-stdlib=libc++" "CLANG" CMAKE_CXX_FLAGS)
append_cxx_compiler_flags("-O3 -ffast-math -funroll-loops" "CLANG" CMAKE_CXX_OPT_FLAGS)
endif()
endif()
Also CMakeEdit.log:
Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed.
Compiler:
Build flags:
Id flags:
The output was:
1
xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance
Compiling the C compiler identification source file "CMakeCCompilerId.c" failed.
Compiler:
Build flags:
Id flags:
The output was:
1
xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance
EDIT:
This problem happens when xcode-select developer directory was pointing to /Library/Developer/CommandLineTools, when a full regular XCode was required (happens when CLT are installed after XCode).
I have found the solution to be this:
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
After this being done, when I run cmake -G Xcode .. I get other errors:
-- The CXX compiler identification is AppleClang 7.0.0.7000176
-- The C compiler identification is AppleClang 7.0.0.7000176
CMake Error at /usr/local/Cellar/cmake/3.4.0/share/cmake/Modules/Platform/Darwin.cmake:76 (message):
CMAKE_OSX_DEPLOYMENT_TARGET is '10.10' but CMAKE_OSX_SYSROOT:
""
is not set to a MacOSX SDK with a recognized version. Either set
CMAKE_OSX_SYSROOT to a valid SDK or set CMAKE_OSX_DEPLOYMENT_TARGET to
empty.
Call Stack (most recent call first):
/usr/local/Cellar/cmake/3.4.0/share/cmake/Modules/CMakeSystemSpecificInformation.cmake:36 (include)
CMakeLists.txt:6 (project)
EDIT 2
Looks like the SDK specified by the OS is wrong.
CMAKE_OSX_DEPLOYMENT_TARGET is '10.10' but the matching SDK does not exist
at:
"/Applications/DEV/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk"
Instead using SDK:
"/Applications/DEV/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk".
Call Stack (most recent call first):
/usr/local/Cellar/cmake/3.4.0/share/cmake/Modules/CMakeSystemSpecificInitialize.cmake:18 (include)
CMakeLists.txt:6 (project)
-- The CXX compiler identification is AppleClang 7.0.0.7000176
-- The C compiler identification is AppleClang 7.0.0.7000176
CMake Error at /usr/local/Cellar/cmake/3.4.0/share/cmake/Modules/Platform/Darwin.cmake:76 (message):
CMAKE_OSX_DEPLOYMENT_TARGET is '10.10' but CMAKE_OSX_SYSROOT:
""
is not set to a MacOSX SDK with a recognized version. Either set
CMAKE_OSX_SYSROOT to a valid SDK or set CMAKE_OSX_DEPLOYMENT_TARGET to
empty.
Call Stack (most recent call first):
/usr/local/Cellar/cmake/3.4.0/share/cmake/Modules/CMakeSystemSpecificInformation.cmake:36 (include)
CMakeLists.txt:6 (project)
I had the same problem, but I solved it with:
sudo xcode-select --reset
Before doing the above, xcode-select -p reported the path was /Library/Developer/CommandLineTools.
After the reset, the path was /Applications/Xcode.app/Contents/Developer.
I had the same output and could solve it by agreeing to the apple license.
sudo xcodebuild -license accept
The error you have with the SDK can usually be solved by clearing the CMake build cache and adding the following to your CMakeLists.txt before project():
SET(MACOSX_DEPLOYMENT_TARGET ${DARWIN_MAJOR_SDK_VERSION}.${DARWIN_MINOR_SDK_VERSION})
SET(CMAKE_CXX_FLAGS "--sysroot ${CMAKE_OSX_SYSROOT} ${CMAKE_CXX_FLAGS}")
MESSAGE("Setting MACOSX_DEPLOYMENT_TARGET to '${MACOSX_DEPLOYMENT_TARGET}'.")
If you find that doesn't solve the issue then you should check the version of Xcode is current and has the SDK installed you are specifying. Generally Homebrew and Macports CMake both should have the latest stable build of Xcode installed.
↳ https://github.com/Homebrew/homebrew/issues/23074
I had the same issue and as mentioned in one of the comments it appears to be due to the fact that I installed the command-line tools first.
I solved it by opening the Xcode app, going to Preferences -> Locations, and selecting the Xcode installation from the dropdown for Command Line Tools. It was initially blank.
I solved a similar problem by
sudo xcodebuild -license
After agreeing the license, C compiler and CXX compiler can be identified.
================================
As a reference, my error message is:
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- broken
CMake Error at /usr/local/Cellar/cmake/3.13.3/share/cmake/Modules/CMakeTestCCompiler.cmake:52 (message):
The C compiler "/usr/bin/cc" is not able to compile a simple test program.
It fails with the following output:
Change Dir: /Users/MyName/pyscf/pyscf/lib/build/CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/make" "cmTC_114dd/fast"
Agreeing to the Xcode/iOS license requires admin privileges, please run “sudo xcodebuild -license” and then retry this command.
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:16 (project)
-- Configuring incomplete, errors occurred!
After upgrading to the latest version of CMake, it worked again.
cmake 3.25.0
AppleClang 14.0.0.14000029