CLion not finding Boost headers - boost

Windows build 18362
CLion 2019.1.2
Boost 1.67
Toolchain mingw-64
I'm trying to setup a simple project in Clion using Boost. The problem is when I include a boost header #include <boost/log/trivial.hpp>, CLion cannot find the header file.
My CMakeLists.txt:
cmake_minimum_required(VERSION 3.14)
project(BoostTest)
set(CMAKE_CXX_STANDARD 14)
add_executable(BoostTest main.cpp)
set(BOOST_ROOT "$ENV{HOMEPATH}/.local/share/boost")
set(Boost_ARCHITECTURE "-x64")
find_package(Boost REQUIRED COMPONENTS log)
message(STATUS "Boost_INCLUDE_DIR: ${Boost_INCLUDE_DIR}")
include_directories(${Boost_INCLUDE_DIR})
target_link_libraries(BoostTest ${Boost_LIBRARIES})
The output of CMake seems to indicate that everything is found correctly:
C:\Users\michael\AppData\Local\JetBrains\Toolbox\apps\CLion\ch-0\191.6707.69\bin\cmake\win\bin\cmake.exe -DCMAKE_BUILD_TYPE=Debug -G "CodeBlocks - MinGW Makefiles" C:\Users\michael\projects\sml\BoostTest
-- The C compiler identification is GNU 8.1.0
-- The CXX compiler identification is GNU 8.1.0
-- Check for working C compiler: C:/mingw/mingw64/bin/gcc.exe
-- Check for working C compiler: C:/mingw/mingw64/bin/gcc.exe -- 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: C:/mingw/mingw64/bin/g++.exe
-- Check for working CXX compiler: C:/mingw/mingw64/bin/g++.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - found
-- Found Threads: TRUE
-- Boost version: 1.67.0
-- Found the following Boost libraries:
-- log
-- date_time
-- log_setup
-- system
-- filesystem
-- thread
-- regex
-- chrono
-- atomic
-- Boost_INCLUDE_DIR: /Users/michael/.local/share/boost/include/boost-1_67
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/michael/projects/sml/BoostTest/cmake-build-debug
But still CLion cannot find the header file in the include statement. The header files are indeed present at the location specified in Boost_INCLUDE_DIR. I'm new to Windows and CLion , and I probably missing some really basic, but I cannot see it. Any clues?

After getting this to work from the command line, I've come to the conclusion that is a CLion bug. If the include directory does not include the drive designation (i.e., C:/), CLion is not finding the header files.
Here is a CMakeLists.txt that works for CLion:
cmake_minimum_required(VERSION 3.14)
project(boost-test)
set(CMAKE_CXX_STANDARD 14)
add_executable(boost-test main.cpp)
set(Boost_USE_STATIC_LIBS ON)
find_package(Boost REQUIRED COMPONENTS log)
if (Boost_FOUND)
message(STATUS "Boost_INCLUDE_DIRS: ${Boost_INCLUDE_DIRS}")
include_directories("C:${Boost_INCLUDE_DIRS}")
target_link_libraries(boost-test ${Boost_LIBRARIES})
endif()
This same file works from the command line without the hacky C: added to the include_directories.
Note that even without the C:, CLion will build and run the code just fine. So the issue seems to be solely with finding the header files based on include_directories().

I just tried doing this from Ubuntu, and no need for any hack to get this working.
find_package(Boost 1.40 COMPONENTS system filesystem program_options log REQUIRED)
include_directories(${Boost_INCLUDE_DIRS})
Not sure it may help, but at least it works somewhere.

Related

Impossible to link SDL2 library to my cmake compiler on Windows

I'm actualy trying to compile a project on windows with the CMakeList.txt that I used to compile the project on linux.
Unfortunatly when I try to compile with windows powershell, cmake is saying :
cmake . -G "MinGW Makefiles"
-- The C compiler identification is GNU 12.2.0
-- The CXX compiler identification is GNU 12.2.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/msys64/mingw64/bin/gcc.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:/msys64/mingw64/bin/g++.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at C:/Program Files/CMake/share/cmake-3.26/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
Could NOT find SDL2_image (missing: SDL2_IMAGE_LIBRARIES)
Call Stack (most recent call first):
C:/Program Files/CMake/share/cmake-3.26/Modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE)
cmake/FindSDL2_image.cmake:91 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
CMakeLists.txt:12 (find_package)
-- Configuring incomplete, errors occurred!
At the first time it didn't scared me cause I know that I have to download every library and link them to the cmake.
After I download every library like this : screenshot of the files
I tried to link them into my cmake,
firstly adding them to my Environment Variables :screenshot
but that didn't work, he always says "impossible to find SDL2_image when its perfectly working on linux with the cmakeFound...
W/E if someone knows how to compile or add a library to cmake on windows it could be insane for me.

OpenMP CMake Apple

I am currently trying to compile a project on Mac using cmake, but running into trouble. I have already looked at this article [1], but am still running into some trouble. My CMakeLists.txt looks as follows.
project(tpch_framework)
# enable c++11
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_BUILD_TYPE "Release")
set(CMAKE_C_COMPILER "/usr/local/Cellar/llvm/10.0.0_3/bin/clang")
set(CMAKE_CXX_COMPILER "/usr/local/Cellar/llvm/10.0.0_3/bin/clang++")
set(OPENMP_LIBRARIES "/usr/local/Cellar/llvm/10.0.0_3/lib")
set(OPENMP_INCLUDES "/usr/local/Cellar/llvm/10.0.0_3/include")
OPTION (USE_OpenMP "Use OpenMP to enamble <omp.h>" ON)
# Find OpenMP
if(APPLE AND USE_OpenMP)
if(CMAKE_C_COMPILER_ID MATCHES "Clang")
set(OpenMP_C_FLAGS "-Xpreprocessor -fopenmp")
set(OpenMP_C_LIB_NAMES "omp")
set(OpenMP_omp_LIBRARY omp)
endif()
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(OpenMP_CXX_FLAGS "-Xpreprocessor -fopenmp")
set(OpenMP_CXX_LIB_NAMES "omp")
set(OpenMP_omp_LIBRARY omp)
endif()
endif()
if(USE_OpenMP)
find_package(OpenMP REQUIRED)
endif(USE_OpenMP)
if (OPENMP_FOUND)
include_directories("${OPENMP_INCLUDES}")
link_directories("${OPENMP_LIBRARIES}")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS} -libomp")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS} -libomp")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
endif(OPENMP_FOUND)
# Configure required Boost libraries
set(BOOST_ROOT "" CACHE PATH "Boost build root (useful on Windows)")
option(Boost_USE_STATIC_LIBS
"Search for static boost libs" OFF)
option(Boost_USE_MULTITHREADED
"Search for multithreaded boost libs" ON)
option(Boost_USE_STATIC_RUNTIME
"Search for boost libs linked against static C++ runtime" OFF)
find_package(Boost 1.47.0 REQUIRED filesystem system)
# ensure that dependant libraries not explicitly specified here
# are found by the linker:
link_directories(${Boost_LIBRARY_DIRS})
include_directories(${Boost_INCLUDE_DIRS})
set(LIBS ${LIBS} ${Boost_LIBRARIES})
#Bring the headers into the project
include_directories(include)
FILE(GLOB_RECURSE INC_ALL "include/*.hpp")
#However, the file(GLOB...) allows for wildcard additions:
file(GLOB SOURCES "src/*.cpp")
add_library(tpch_framework ${SOURCES})
add_executable(framework main.cpp ${INC_ALL})
target_link_libraries(framework tpch_framework)
#target_link_libraries(framework stdc++fs)
target_link_libraries(framework ${LIBS})
When I execute this, I get the following output.
-- The C compiler identification is AppleClang 11.0.0.11000033
-- The CXX compiler identification is AppleClang 11.0.0.11000033
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc
-- Check for working C compiler: /Library/Developer/CommandLineTools/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: /Library/Developer/CommandLineTools/usr/bin/c++
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ - works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found OpenMP_C: -Xpreprocessor -fopenmp
-- Found OpenMP_CXX: -Xpreprocessor -fopenmp
-- Found OpenMP: TRUE
-- Found Boost: /usr/local/lib/cmake/Boost-1.72.0/BoostConfig.cmake (found suitable version "1.72.0", minimum required is "1.47.0") found components: filesystem system
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/...
However, when I then use make, I get the following error.
/Users/myname/Desktop/Uni/MHD/tpch_framework_challenge_mhd_2020/src/task4.cpp:48:5: error: use of undeclared identifier 'omp_set_num_threads'
omp_set_num_threads(4);
Which I am guessing comes, as I get this warning: clang-10: warning: -libomp: 'linker' input unused [-Wunused-command-line-argument].
Does anybody have any ideas? I have been stuck with this for way too long and would appreciate any tips.
Kind regards,
Moritz
If you can use a recent version of CMake, this build should work.
# NOTE: Every top-level CMakeLists.txt must start with these two lines
cmake_minimum_required(VERSION 3.16)
project(tpch_framework)
## Enable C++14
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
## Find dependencies
# OpenMP
find_package(OpenMP REQUIRED)
# Boost
set(BOOST_ROOT "" CACHE PATH "Boost build root (useful on Windows)")
option(Boost_USE_STATIC_LIBS
"Search for static boost libs" OFF)
option(Boost_USE_MULTITHREADED
"Search for multithreaded boost libs" ON)
option(Boost_USE_STATIC_RUNTIME
"Search for boost libs linked against static C++ runtime" OFF)
find_package(Boost 1.47.0 REQUIRED COMPONENTS filesystem system)
## Add main project targets
# NOTE: This is completely wrong and will break incremental builds after
# doing a "git pull" or similar. You should never glob for source
# files, but instead list them explicitly.
file(GLOB SOURCES "src/*.cpp")
add_library(tpch_framework ${SOURCES})
target_include_directories(tpch_framework PUBLIC BUILD_INTERFACE:include)
target_link_libraries(tpch_framework
PUBLIC
OpenMP::OpenMP_CXX
Boost::boost
Boost::filesystem
Boost::system)
add_executable(framework main.cpp)
target_link_libraries(framework PRIVATE tpch_framework)
There is so much bad CMake advice here on SO and in tutorials, it's a real shame.

How to set adf_path and build a project for LYRA-T board?

"Warn about uninitialized values.
CMake Warning (dev) at CMakeLists.txt:5 (include):
uninitialized variable 'ADF_PATH'
This warning is for project developers. Use -Wno-dev to suppress it.
CMake Error at CMakeLists.txt:5 (include):
include could not find load file:
/CMakeLists.txt
-- Found Git: C:/Program Files/Git/bin/git.exe (found version "2.25.1.windows.1")
-- Unexpected file in components directory: C:/Users/Embedded/Desktop/esp/esp-idf/components/.gitkeep
-- ccache will be used for faster recompilation
-- The C compiler identification is GNU 8.2.0
-- The CXX compiler identification is GNU 8.2.0
-- The ASM compiler identification is GNU
-- Found assembler: C:/Users/Embedded/.espressif/tools/xtensa-esp32-elf/esp-2019r2-8.2.0/xtensa-esp32-elf/bin/xtensa-esp32-elf-gcc.exe
-- Check for working C compiler: C:/Users/Embedded/.espressif/tools/xtensa-esp32-elf/esp-2019r2-8.2.0/xtensa-esp32-elf/bin/xtensa-esp32-elf-gcc.exe
-- Check for working C compiler: C:/Users/Embedded/.espressif/tools/xtensa-esp32-elf/esp-2019r2-8.2.0/xtensa-esp32-elf/bin/xtensa-esp32-elf-gcc.exe -- 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: C:/Users/Embedded/.espressif/tools/xtensa-esp32-elf/esp-2019r2-8.2.0/xtensa-esp32-elf/bin/xtensa-esp32-elf-g++.exe
-- Check for working CXX compiler: C:/Users/Embedded/.espressif/tools/xtensa-esp32-elf/esp-2019r2-8.2.0/xtensa-esp32-elf/bin/xtensa-esp32-elf-g++.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Building ESP-IDF components for target esp32
warning: the default selection SR_RUN_WM6_CORE1 (undefined) of (defined at C:/Users/Embedded/Desktop/esp/esp-idf/components/esp-sr/Kconfig.projbuild:83) is not contained in the choice
warning: the default selection CONFIG_SR_MN1_MODEL_QUANT (undefined) of (defined at C:/Users/Embedded/Desktop/esp/esp-idf/components/esp-sr/Kconfig.projbuild:100) is not contained in the choice
-- App "play_mp3" version: v2.0-beta2-21-g30403e2-dirty
-- Found PythonInterp: C:/Users/Embedded/.espressif/python_env/idf4.2_py2.7_env/Scripts/python.exe (found version "2.7.12")
-- Could NOT find Perl (missing: PERL_EXECUTABLE)
-- Adding linker script C:/Users/Embedded/Desktop/esp/esp-adf/examples/get-started/play_mp3/build/esp-idf/esp32/esp32_out.ld
-- Adding linker script C:/Users/Embedded/Desktop/esp/esp-idf/components/esp32/ld/esp32.project.ld.in
-- Adding linker script C:/Users/Embedded/Desktop/esp/esp-idf/components/esp32/ld/esp32.peripherals.ld
-- Adding linker script C:/Users/Embedded/Desktop/esp/esp-idf/components/esp_rom/esp32/ld/esp32.rom.newlib-funcs-time.ld
-- Adding linker script C:/Users/Embedded/Desktop/esp/esp-idf/components/esp_rom/esp32/ld/esp32.rom.ld
-- Adding linker script C:/Users/Embedded/Desktop/esp/esp-idf/components/esp_rom/esp32/ld/esp32.rom.libgcc.ld
-- Adding linker script C:/Users/Embedded/Desktop/esp/esp-idf/components/esp_rom/esp32/ld/esp32.rom.newlib-data.ld
-- Adding linker script C:/Users/Embedded/Desktop/esp/esp-idf/components/esp_rom/esp32/ld/esp32.rom.syscalls.ld
-- Adding linker script C:/Users/Embedded/Desktop/esp/esp-idf/components/esp_rom/esp32/ld/esp32.rom.newlib-funcs.ld
-- Current board name is CONFIG_ESP_LYRAT_V4_3_BOARD
-- Components: adf_utils app_trace app_update asio audio_board audio_hal audio_pipeline audio_sal audio_stream bluetooth_service bootloader bootloader_support bt cbor clouds coap console cxx display_service driver dueros_service efuse esp-adf-libs esp-sr esp-tls esp32 esp_actions esp_adc_cal esp_common esp_dispatcher esp_eth esp_event esp_gdbstub esp_http_client esp_http_server esp_https_ota esp_https_server esp_local_ctrl esp_netif esp_peripherals esp_ringbuf esp_rom esp_serial_slave_link esp_timer esp_websocket_client esp_wifi espcoredump esptool_py expat fatfs freemodbus freertos heap idf_test input_key_service jsmn json libsodium log lwip main mbedtls mdns mqtt newlib nghttp nvs_flash openssl partition_table perfmon playlist protobuf-c protocomm pthread sdmmc soc spi_flash spiffs tcp_transport tcpip_adapter ulp unity vfs wear_levelling wifi_provisioning wifi_service wpa_supplicant xtensa
-- Component paths: C:/Users/Embedded/Desktop/esp/esp-idf/components/adf_utils C:/Users/Embedded/Desktop/esp/esp-idf/components/app_trace C:/Users/Embedded/Desktop/esp/esp-idf/components/app_update C:/Users/Embedded/Desktop/esp/esp-idf/components/asio C:/Users/Embedded/Desktop/esp/esp-idf/components/audio_board C:/Users/Embedded/Desktop/esp/esp-idf/components/audio_hal C:/Users/Embedded/Desktop/esp/esp-idf/components/audio_pipeline C:/Users/Embedded/Desktop/esp/esp-idf/components/audio_sal C:/Users/Embedded/Desktop/esp/esp-idf/components/audio_stream C:/Users/Embedded/Desktop/esp/esp-idf/components/bluetooth_service C:/Users/Embedded/Desktop/esp/esp-idf/components/bootloader C:/Users/Embedded/Desktop/esp/esp-idf/components/bootloader_support C:/Users/Embedded/Desktop/esp/esp-idf/components/bt C:/Users/Embedded/Desktop/esp/esp-idf/components/cbor C:/Users/Embedded/Desktop/esp/esp-idf/components/clouds C:/Users/Embedded/Desktop/esp/esp-idf/components/coap C:/Users/Embedded/Desktop/esp/esp-idf/components/console C:/Users/Embedded/Desktop/esp/esp-idf/components/cxx C:/Users/Embedded/Desktop/esp/esp-idf/components/display_service C:/Users/Embedded/Desktop/esp/esp-idf/components/driver C:/Users/Embedded/Desktop/esp/esp-idf/components/dueros_service C:/Users/Embedded/Desktop/esp/esp-idf/components/efuse C:/Users/Embedded/Desktop/esp/esp-idf/components/esp-adf-libs C:/Users/Embedded/Desktop/esp/esp-idf/components/esp-sr C:/Users/Embedded/Desktop/esp/esp-idf/components/esp-tls C:/Users/Embedded/Desktop/esp/esp-idf/components/esp32 C:/Users/Embedded/Desktop/esp/esp-idf/components/esp_actions C:/Users/Embedded/Desktop/esp/esp-idf/components/esp_adc_cal C:/Users/Embedded/Desktop/esp/esp-idf/components/esp_common C:/Users/Embedded/Desktop/esp/esp-idf/components/esp_dispatcher C:/Users/Embedded/Desktop/esp/esp-idf/components/esp_eth C:/Users/Embedded/Desktop/esp/esp-idf/components/esp_event C:/Users/Embedded/Desktop/esp/esp-idf/components/esp_gdbstub C:/Users/Embedded/Desktop/esp/esp-idf/components/esp_http_client C:/Users/Embedded/Desktop/esp/esp-idf/components/esp_http_server C:/Users/Embedded/Desktop/esp/esp-idf/components/esp_https_ota C:/Users/Embedded/Desktop/esp/esp-idf/components/esp_https_server C:/Users/Embedded/Desktop/esp/esp-idf/components/esp_local_ctrl C:/Users/Embedded/Desktop/esp/esp-idf/components/esp_netif C:/Users/Embedded/Desktop/esp/esp-idf/components/esp_peripherals C:/Users/Embedded/Desktop/esp/esp-idf/components/esp_ringbuf C:/Users/Embedded/Desktop/esp/esp-idf/components/esp_rom C:/Users/Embedded/Desktop/esp/esp-idf/components/esp_serial_slave_link C:/Users/Embedded/Desktop/esp/esp-idf/components/esp_timer C:/Users/Embedded/Desktop/esp/esp-idf/components/esp_websocket_client C:/Users/Embedded/Desktop/esp/esp-idf/components/esp_wifi C:/Users/Embedded/Desktop/esp/esp-idf/components/espcoredump C:/Users/Embedded/Desktop/esp/esp-idf/components/esptool_py C:/Users/Embedded/Desktop/esp/esp-idf/components/expat C:/Users/Embedded/Desktop/esp/esp-idf/components/fatfs C:/Users/Embedded/Desktop/esp/esp-idf/components/freemodbus C:/Users/Embedded/Desktop/esp/esp-idf/components/freertos C:/Users/Embedded/Desktop/esp/esp-idf/components/heap C:/Users/Embedded/Desktop/esp/esp-idf/components/idf_test C:/Users/Embedded/Desktop/esp/esp-idf/components/input_key_service C:/Users/Embedded/Desktop/esp/esp-idf/components/jsmn C:/Users/Embedded/Desktop/esp/esp-idf/components/json C:/Users/Embedded/Desktop/esp/esp-idf/components/libsodium C:/Users/Embedded/Desktop/esp/esp-idf/components/log C:/Users/Embedded/Desktop/esp/esp-idf/components/lwip C:/Users/Embedded/Desktop/esp/esp-adf/examples/get-started/play_mp3/main C:/Users/Embedded/Desktop/esp/esp-idf/components/mbedtls C:/Users/Embedded/Desktop/esp/esp-idf/components/mdns C:/Users/Embedded/Desktop/esp/esp-idf/components/mqtt C:/Users/Embedded/Desktop/esp/esp-idf/components/newlib C:/Users/Embedded/Desktop/esp/esp-idf/components/nghttp C:/Users/Embedded/Desktop/esp/esp-idf/components/nvs_flash C:/Users/Embedded/Desktop/esp/esp-idf/components/openssl C:/Users/Embedded/Desktop/esp/esp-idf/components/partition_table C:/Users/Embedded/Desktop/esp/esp-idf/components/perfmon C:/Users/Embedded/Desktop/esp/esp-idf/components/playlist C:/Users/Embedded/Desktop/esp/esp-idf/components/protobuf-c C:/Users/Embedded/Desktop/esp/esp-idf/components/protocomm C:/Users/Embedded/Desktop/esp/esp-idf/components/pthread C:/Users/Embedded/Desktop/esp/esp-idf/components/sdmmc C:/Users/Embedded/Desktop/esp/esp-idf/components/soc C:/Users/Embedded/Desktop/esp/esp-idf/components/spi_flash C:/Users/Embedded/Desktop/esp/esp-idf/components/spiffs C:/Users/Embedded/Desktop/esp/esp-idf/components/tcp_transport C:/Users/Embedded/Desktop/esp/esp-idf/components/tcpip_adapter C:/Users/Embedded/Desktop/esp/esp-idf/components/ulp C:/Users/Embedded/Desktop/esp/esp-idf/components/unity C:/Users/Embedded/Desktop/esp/esp-idf/components/vfs C:/Users/Embedded/Desktop/esp/esp-idf/components/wear_levelling C:/Users/Embedded/Desktop/esp/esp-idf/components/wifi_provisioning C:/Users/Embedded/Desktop/esp/esp-idf/components/wifi_service C:/Users/Embedded/Desktop/esp/esp-idf/components/wpa_supplicant C:/Users/Embedded/Desktop/esp/esp-idf/components/xtensa
-- Configuring incomplete, errors occurred!
See also "C:/Users/Embedded/Desktop/esp/esp-adf/examples/get-started/play_mp3/build/CMakeFiles/CMakeOutput.log".
cmake failed with exit code 1
"
if using Windows :
in IDF command prompt
set ADF_PATH = "C:\Users\username\Desktop\esp-adf"
to ensure your path
echo %ADF_PATH%
Permanent solution :add the following at the end of export.bat (found in IDF folder)
set ADF_PATH = "C:\Users\username\Desktop\esp-adf"

How to recompile opencv_traincascade (OpenCV 2.4)?

I would like to know How to compile ONLY the program opencv_traincascade on macOS Sierra.
I have the source code of the traincascade (in the folder /opencv-2.4.13/apps/traincascade/). However, when I go to this folder and type on terminal:
cmake ..
It returns:
-- The C compiler identification is AppleClang 8.0.0.8000042
-- The CXX compiler identification is AppleClang 8.0.0.8000042
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/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: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at haartraining/CMakeLists.txt:2 (ocv_check_dependencies):
Unknown CMake command "ocv_check_dependencies".
CMake Warning (dev) in CMakeLists.txt:
No cmake_minimum_required command is present. A line of code such as
cmake_minimum_required(VERSION 3.6)
should be added at the top of the file. The version specified may be lower
if you wish to support older CMake versions for this project. For more
information run "cmake --help-policy CMP0000".
This warning is for project developers. Use -Wno-dev to suppress it.
-- Configuring incomplete, errors occurred!
=> It does not understand the "ocv_check_dependencies"
Here is the CMakeLists.txt code:
SET(OPENCV_TRAINCASCADE_DEPS opencv_core opencv_ml opencv_imgproc opencv_objdetect opencv_highgui opencv_calib3d opencv_video opencv_features2d opencv_flann opencv_legacy)
ocv_check_dependencies(${OPENCV_TRAINCASCADE_DEPS})
if(NOT OCV_DEPENDENCIES_FOUND)
return()
endif()
project(traincascade)
ocv_include_directories("${CMAKE_CURRENT_SOURCE_DIR}" "${OpenCV_SOURCE_DIR}/include/opencv")
ocv_include_modules(${OPENCV_TRAINCASCADE_DEPS})
set(traincascade_files traincascade.cpp
cascadeclassifier.cpp cascadeclassifier.h
boost.cpp boost.h features.cpp traincascade_features.h
haarfeatures.cpp haarfeatures.h
lbpfeatures.cpp lbpfeatures.h
HOGfeatures.cpp HOGfeatures.h
imagestorage.cpp imagestorage.h)
set(the_target opencv_traincascade)
add_executable(${the_target} ${traincascade_files})
target_link_libraries(${the_target} ${OPENCV_TRAINCASCADE_DEPS} opencv_haartraining_engine)
set_target_properties(${the_target} PROPERTIES
DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
ARCHIVE_OUTPUT_DIRECTORY ${LIBRARY_OUTPUT_PATH}
RUNTIME_OUTPUT_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}
OUTPUT_NAME "opencv_traincascade")
if(ENABLE_SOLUTION_FOLDERS)
set_target_properties(${the_target} PROPERTIES FOLDER "applications")
endif()
if(INSTALL_CREATE_DISTRIB)
if(BUILD_SHARED_LIBS)
install(TARGETS ${the_target} RUNTIME DESTINATION ${OPENCV_BIN_INSTALL_PATH} CONFIGURATIONS Release COMPONENT dev)
endif()
else()
install(TARGETS ${the_target} RUNTIME DESTINATION ${OPENCV_BIN_INSTALL_PATH} COMPONENT dev)
endif()
In addition, this question raised on my mind because I got stuck in the training process with -featureType LBP . When I train my face detector with LBP feature, it shows:
Andy-Chen:Temp Training macpro$ opencv_traincascade -data data -vec faces_15000-80000.vec -bg neg.txt -numPos 4000 -numNeg 10000 -numStages 10 -w 21 -h 24 -featureType LBP
===== TRAINING 0-stage =====
<BEGIN
POS count : consumed 4000 : 4000
NEG count : acceptanceRatio 10000 : 1
and then it keeps this status for several hours without any progress. However, if I train with HAAR feature, everything works fine.
Thus, I want to add some "cout" commands to the source code of traincascade so that I can see where the program gets stuck and then look for a solution or modify something to make it workable.
I look forward to hearing from your help. Thank you very much for your time.

Setting SDK on cross-compilation to OSX in CMake

I'm cross compiling from Linux to OSX using CMake. To do this I use a toolchain file, so the call is like this:
cmake -G 'Unix Makefiles' -DCMAKE_TOOLCHAIN_FILE=./cmake/toolchains/c.apple.universal.cmake .
The toolchain file looks like this:
SET(CMAKE_SYSTEM_NAME Darwin)
SET(CMAKE_SYSTEM_PROCESSOR universal)
# set compilers...
INCLUDE("${CMAKE_CURRENT_LIST_DIR}/c.apple.common.cmake")
And the other one:
INCLUDE("${CMAKE_CURRENT_LIST_DIR}/../Modules/CMakeMacroSetCCache.cmake")
# specify the cross compiler
SET_CCACHE(CMAKE_C_COMPILER i686-apple-darwin10-gcc)
SET_CCACHE(CMAKE_CXX_COMPILER i686-apple-darwin10-g++)
SET(CMAKE_RANLIB i686-apple-darwin10-ranlib CACHE STRING "" FORCE)
SET(CMAKE_LIPO i686-apple-darwin10-lipo CACHE STRING "" FORCE)
SET(OSX104_SDK "/usr/lib/apple/SDKs/MacOSX10.4.sdk")
SET(OSX105_SDK "/usr/lib/apple/SDKs/MacOSX10.5.sdk")
# set SDK
SET(CMAKE_OSX_DEPLOYMENT_TARGET )
IF(EXISTS ${OSX104_SDK})
SET(CMAKE_OSX_SYSROOT ${OSX104_SDK})
ELSEIF(EXISTS ${OSX105_SDK})
SET(CMAKE_OSX_SYSROOT ${OSX105_SDK})
ELSE()
MESSAGE(FATAL_ERROR "No OSX SDK found!")
ENDIF()
MESSAGE(STATUS "Using OSX SDK at ${CMAKE_OSX_SYSROOT}")
SET(CMAKE_PREFIX_PATH ${CMAKE_OSX_SYSROOT})
SET(CMAKE_FIND_ROOT_PATH ${CMAKE_PREFIX_PATH})
SET(BOOST_ROOT ${CMAKE_PREFIX_PATH})
# search for programs in the build host directories
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
# for libraries and headers in the target directories
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
This works so far, but somehow CMake resets CMAKE_OSX_SYSROOT at some point. The output I get is:
-- Set CMAKE_C_COMPILER to /usr/lib/ccache-lipo/i686-apple-darwin10-gcc
-- Set CMAKE_CXX_COMPILER to /usr/lib/ccache-lipo/i686-apple-darwin10-g++
-- Using OSX SDK at /usr/lib/apple/SDKs/MacOSX10.5.sdk
-- Set CMAKE_C_COMPILER to /usr/lib/ccache-lipo/i686-apple-darwin10-gcc
-- Set CMAKE_CXX_COMPILER to /usr/lib/ccache-lipo/i686-apple-darwin10-g++
-- Using OSX SDK at /usr/lib/apple/SDKs/MacOSX10.5.sdk
-- The C compiler identification is GNU
-- The CXX compiler identification is GNU
-- 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 - yes
-- Check for working C compiler: /usr/lib/ccache-lipo/i686-apple-darwin10-gcc
-- Check for working C compiler: /usr/lib/ccache-lipo/i686-apple-darwin10-gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Checking whether CXX compiler has -isysroot
-- Checking whether CXX compiler has -isysroot - yes
-- Checking whether CXX compiler supports OSX deployment target flag
-- Checking whether CXX compiler supports OSX deployment target flag - yes
-- Check for working CXX compiler: /usr/lib/ccache-lipo/i686-apple-darwin10-g++
-- Check for working CXX compiler: /usr/lib/ccache-lipo/i686-apple-darwin10-g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Used Toolchain definition file '/srv/jenkins/.../cmake/toolchains/c.apple.universal.cmake'
-- Configuring for cross-compiling to Darwin on universal
-- Using platform config cmake/darwin.cmake
-- Checking /Developer/SDKs/MacOSX.sdk/usr/lib/libSystem.B.dylib for possible architectures
The last 3 lines are from the CMakeList.txt. The correct toolchain file was used (it's just a message), SYSTEM_NAME and SYSTEM_PROCESSOR are set correctly but the OSX SDK is wrong. The corresponding CMake code comes from a macro that will set CMAKE_OSX_ARCHITECTURES if it wasn't set before (which is the case here). The line is:
MESSAGE(STATUS "Checking ${CMAKE_OSX_SYSROOT}/usr/lib/libSystem.B.dylib for possible architectures")
Am I using CMake wrongly here? Why is CMake resetting the OSX_SYSROOT? According to http://www.cmake.org/cmake/help/v3.0/variable/CMAKE_OSX_SYSROOT.html it should also affect FIND* commands but I needed to set CMAKE_FIND_ROOT_PATH for it to work.
Strange enough, it worked yesterday. Cleaning the whole build-directory (which I'm sure I did yesterday too) and rerunning CMake resets CMAKE_OSX_SYSROOT now.
If this makes a difference: PROJECT is called before the inclusion end execution of the macro, that shows the wrong sysroot.
The solution I found is to set the variable into the cache. This way it "survives" during CMake processing:
SET(CMAKE_OSX_SYSROOT ${CMAKE_OSX_SYSROOT} CACHE PATH "..." FORCE)

Resources