when i try "make", i get error: identifier “nullptr” is undefined - c++

When I try OpenPose Building, I get error: identifier “nullptr” is undefined.
I follow the instructions on the site to install OpenPose and I have error in "OpenPose Building".
https://github.com/CMU-Perceptual-Computing-Lab/openpose/blob/master/doc/installation.md#clone-openpose
my#PC:~/openpose/build$ make -j`nproc`
Scanning dependencies of target openpose_caffe
[ 12%] Creating directories for 'openpose_caffe'
[ 25%] No download step for 'openpose_caffe'
[ 37%] [ 50%] No patch step for 'openpose_caffe'
No update step for 'openpose_caffe'
[ 62%] Performing configure step for 'openpose_caffe'
-- The C compiler identification is GNU 4.9.4
-- The CXX compiler identification is GNU 4.9.4
-- 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
-- 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
-- Boost version: 1.54.0
-- Found the following Boost libraries:
-- system
-- thread
-- filesystem
-- Looking for include file pthread.h
-- Looking for include file 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 GFlags: /usr/include
-- Found gflags (include: /usr/include, library: /usr/lib/x86_64-linux-gnu/libgflags.so)
-- Found Glog: /usr/include
-- Found glog (include: /usr/include, library: /usr/lib/x86_64-linux-gnu/libglog.so)
-- Found PROTOBUF: /usr/lib/x86_64-linux-gnu/libprotobuf.so
-- Found PROTOBUF Compiler: /usr/bin/protoc
-- Found HDF5: /usr/lib/x86_64-linux-gnu/libhdf5_hl.so;/usr/lib/x86_64-linux-gnu/libhdf5.so
-- CUDA detected: 8.0
-- Found cuDNN: ver. 5.1.10 found (include: /usr/include, library: /usr/lib/x86_64-linux-gnu/libcudnn.so)
-- Automatic GPU detection failed. Building for all known architectures.
-- Added CUDA NVCC flags for: sm_30 sm_35 sm_50 sm_52 sm_60 sm_61
-- Found Atlas: /usr/include
-- Found Atlas (include: /usr/include library: /usr/lib/libatlas.so lapack: /usr/lib/liblapack.so
-- Python interface is disabled or not all required dependencies found. Building without it...
-- Found Git: /usr/bin/git (found version "1.9.1")
--
-- ******************* Caffe Configuration Summary *******************
-- General:
-- Version : 1.0.0
-- Git : 1.0-141-g974172c
-- System : Linux
-- C++ compiler : /usr/bin/c++
-- Release CXX flags : -O3 -DNDEBUG -fPIC -Wall -std=c++11 -Wno-sign-compare -Wno-uninitialized
-- Debug CXX flags : -g -fPIC -Wall -std=c++11 -Wno-sign-compare -Wno-uninitialized
-- Build type : Release
--
-- BUILD_SHARED_LIBS : ON
-- BUILD_python : OFF
-- BUILD_matlab : OFF
-- BUILD_docs : OFF
-- CPU_ONLY : OFF
-- USE_OPENCV : OFF
-- USE_LEVELDB : OFF
-- USE_LMDB : OFF
-- USE_NCCL : OFF
-- ALLOW_LMDB_NOLOCK : OFF
-- USE_HDF5 : ON
--
-- Dependencies:
-- BLAS : Yes (Atlas)
-- Boost : Yes (ver. 1.54)
-- glog : Yes
-- gflags : Yes
-- protobuf : Yes (ver. 2.5.0)
-- CUDA : Yes (ver. 8.0)
--
-- NVIDIA CUDA:
-- Target GPU(s) : Auto
-- GPU arch(s) : sm_30 sm_35 sm_50 sm_52 sm_60 sm_61
-- cuDNN : Yes (ver. 5.1.10)
--
-- Install:
-- Install path : /home/miyo/openpose/build/caffe
--
CMake Warning (dev) in src/caffe/CMakeLists.txt:
Policy CMP0022 is not set: INTERFACE_LINK_LIBRARIES defines the link
interface. Run "cmake --help-policy CMP0022" for policy details. Use the
cmake_policy command to set the policy and suppress this warning.
Target "caffe" has an INTERFACE_LINK_LIBRARIES property which differs from
its LINK_INTERFACE_LIBRARIES properties.
INTERFACE_LINK_LIBRARIES:
caffeproto;/usr/lib/x86_64-linux-gnu/libboost_system.so;/usr/lib/x86_64-linux-gnu/libboost_thread.so;/usr/lib/x86_64-linux-gnu/libboost_filesystem.so;/usr/lib/x86_64-linux-gnu/libpthread.so;/usr/lib/x86_64-linux-gnu/libglog.so;/usr/lib/x86_64-linux-gnu/libgflags.so;$<$<NOT:$<CONFIG:DEBUG>>:/usr/lib/x86_64-linux-gnu/libprotobuf.so>;$<$<CONFIG:DEBUG>:/usr/lib/x86_64-linux-gnu/libprotobuf.so>;-lpthread;/usr/lib/x86_64-linux-gnu/libhdf5_hl.so;/usr/lib/x86_64-linux-gnu/libhdf5.so;/usr/lib/x86_64-linux-gnu/libhdf5_hl.so;/usr/lib/x86_64-linux-gnu/libhdf5.so;/usr/lib/x86_64-linux-gnu/libhdf5_hl.so;/usr/lib/x86_64-linux-gnu/libhdf5.so;/usr/lib/x86_64-linux-gnu/libhdf5_hl.so;/usr/lib/x86_64-linux-gnu/libhdf5.so;/usr/local/cuda-8.0/lib64/libcudart.so;/usr/local/cuda-8.0/lib64/libcurand.so;/usr/local/cuda-8.0/lib64/libcublas.so;/usr/lib/x86_64-linux-gnu/libcudnn.so;/usr/lib/liblapack.so;/usr/lib/libcblas.so;/usr/lib/libatlas.so
LINK_INTERFACE_LIBRARIES:
caffeproto;/usr/lib/x86_64-linux-gnu/libboost_system.so;/usr/lib/x86_64-linux-gnu/libboost_thread.so;/usr/lib/x86_64-linux-gnu/libboost_filesystem.so;/usr/lib/x86_64-linux-gnu/libpthread.so;/usr/lib/x86_64-linux-gnu/libglog.so;/usr/lib/x86_64-linux-gnu/libgflags.so;/usr/lib/x86_64-linux-gnu/libprotobuf.so;-lpthread;/usr/lib/x86_64-linux-gnu/libhdf5_hl.so;/usr/lib/x86_64-linux-gnu/libhdf5.so;/usr/lib/x86_64-linux-gnu/libhdf5_hl.so;/usr/lib/x86_64-linux-gnu/libhdf5.so;/usr/lib/x86_64-linux-gnu/libhdf5_hl.so;/usr/lib/x86_64-linux-gnu/libhdf5.so;/usr/lib/x86_64-linux-gnu/libhdf5_hl.so;/usr/lib/x86_64-linux-gnu/libhdf5.so;/usr/local/cuda-8.0/lib64/libcudart.so;/usr/local/cuda-8.0/lib64/libcurand.so;/usr/local/cuda-8.0/lib64/libcublas.so;/usr/lib/x86_64-linux-gnu/libcudnn.so;/usr/lib/liblapack.so;/usr/lib/libcblas.so;/usr/lib/libatlas.so
This warning is for project developers. Use -Wno-dev to suppress it.
-- Configuring done
-- Generating done
-- Build files have been written to: /home/miyo/openpose/build/caffe/src/openpose_caffe-build
[ 75%] Performing build step for 'openpose_caffe'
[ 1%] Running C++/Python protocol buffer compiler on /home/miyo/openpose/3rdparty/caffe/src/caffe/proto/caffe.proto
Scanning dependencies of target caffeproto
[ 1%] Building CXX object src/caffe/CMakeFiles/caffeproto.dir/__/__/include/caffe/proto/caffe.pb.cc.o
Linking CXX static library ../../lib/libcaffeproto.a
[ 1%] Built target caffeproto
[ 1%] [ 1%] [ 2%] [ 2%] [ 4%] [ 5%] [ 6%] [ 6%] [ 6%] Building NVCC (Device) object src/caffe/CMakeFiles/cuda_compile.dir/solvers/./cuda_compile_generated_sgd_solver.cu.o
Building NVCC (Device) object src/caffe/CMakeFiles/cuda_compile.dir/util/./cuda_compile_generated_math_functions.cu.o
[ 6%] Building NVCC (Device) object src/caffe/CMakeFiles/cuda_compile.dir/solvers/./cuda_compile_generated_adam_solver.cu.o
Building NVCC (Device) object src/caffe/CMakeFiles/cuda_compile.dir/layers/./cuda_compile_generated_deconv_layer.cu.o
Building NVCC (Device) object src/caffe/CMakeFiles/cuda_compile.dir/util/./cuda_compile_generated_im2col.cu.o
Building NVCC (Device) object src/caffe/CMakeFiles/cuda_compile.dir/solvers/./cuda_compile_generated_adagrad_solver.cu.o
Building NVCC (Device) object src/caffe/CMakeFiles/cuda_compile.dir/solvers/./cuda_compile_generated_rmsprop_solver.cu.o
Building NVCC (Device) object src/caffe/CMakeFiles/cuda_compile.dir/solvers/./cuda_compile_generated_nesterov_solver.cu.o
Building NVCC (Device) object src/caffe/CMakeFiles/cuda_compile.dir/solvers/./cuda_compile_generated_adadelta_solver.cu.o
[ 8%] [ 8%] Building NVCC (Device) object src/caffe/CMakeFiles/cuda_compile.dir/layers/./cuda_compile_generated_lrn_layer.cu.o
Building NVCC (Device) object src/caffe/CMakeFiles/cuda_compile.dir/layers/./cuda_compile_generated_hdf5_data_layer.cu.o
Building NVCC (Device) object src/caffe/CMakeFiles/cuda_compile.dir/layers/./cuda_compile_generated_cudnn_sigmoid_layer.cu.o
/usr/lib/gcc/x86_64-linux-gnu/4.9/include/stddef.h(432): error: identifier "nullptr" is undefined
/usr/lib/gcc/x86_64-linux-gnu/4.9/include/stddef.h(432): error: expected a ";"
/usr/lib/gcc/x86_64-linux-gnu/4.9/include/stddef.h(432): error: identifier "nullptr" is undefined
/usr/lib/gcc/x86_64-linux-gnu/4.9/include/stddef.h(432): error: expected a ";"
...
/usr/include/c++/4.9/cmath(202): error: variable "std::constexpr" has already been defined
/usr/include/c++/4.9/cmath(202): error: expected a ";"
/usr/include/c++/4.9/cmath(221): error: inline specifier allowed on function declarations only
/usr/include/c++/4.9/cmath(221): error: variable "std::constexpr" has already been defined
/usr/include/c++/4.9/cmath(221): error: expected a ";"
/usr/include/c++/4.9/cmath(240): error: inline specifier allowed on function declarations only
/usr/include/c++/4.9/cmath(240): error: variable "std::constexpr" has already been defined
/usr/include/c++/4.9/cmath(240): error: expected a ";"
Error limit reached.
100 errors detected in the compilation of "/tmp/tmpxft_00001d71_00000000-17_math_functions.compute_61.cpp1.ii".
Compilation terminated.
CMake Error at cuda_compile_generated_math_functions.cu.o.cmake:264 (message):
Error generating file
/home/miyo/openpose/build/caffe/src/openpose_caffe-build/src/caffe/CMakeFiles/cuda_compile.dir/util/./cuda_compile_generated_math_functions.cu.o
make[5]: *** [src/caffe/CMakeFiles/cuda_compile.dir/util/./cuda_compile_generated_math_functions.cu.o] Error 1
make[4]: *** [src/caffe/CMakeFiles/caffe.dir/all] Error 2
make[3]: *** [all] Error 2
make[2]: *** [caffe/src/openpose_caffe-stamp/openpose_caffe-build] Error 2
make[1]: *** [CMakeFiles/openpose_caffe.dir/all] Error 2
make: *** [all] Error 2
Please tell me how to solve this problem.
Ubuntu 14.04,
Cuda 8.0,
cudnn 5.1,
gcc 4.9,
g++ 4.9
Additional notes -
I am multiposting here.
https://github.com/CMU-Perceptual-Computing-Lab/openpose/issues/981
https://ja.stackoverflow.com/questions/51408/openpose%e3%81%ae%e3%83%93%e3%83%ab%e3%83%89%e6%99%82%e3%81%aberror-identifier-nullptr-is-undefined%e3%81%ae%e3%82%a8%e3%83%a9%e3%83%bc%e3%81%8c%e7%99%ba%e7%94%9f%e3%81%99%e3%82%8b
I ran the following code but I could not improve this problem.
sudo apt-get update && sudo apt-get upgrade && sudo apt-get dist-upgrade && sudo apt-get autoremove
Additional notes2 -
my#PC:~$ cc --version
cc (Ubuntu 4.9.4-2ubuntu1~14.04.1) 4.9.4
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
my#PC:~$ c++ --version
c++ (Ubuntu 4.9.4-2ubuntu1~14.04.1) 4.9.4
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

I believe that GCC 4.9 should be sufficient. The caveat is that it does not use C++11 by default, so you have to add --std=c++11 somewhere in the Makefile where the CXXFLAGS are defined. The developers of the software package might use a newer version of GCC which uses C++14 by default, like GCC 8.2.
As this is a CMake project, you can either add
add_definitions('--std=c++11')
to the CMakeLists.txt or add
set(CMAKE_CXX_STANDARD 11)
if your version of CMake supports it.

Related

c++17 parallel algorithms and CMake on ubuntu 20.04

I had installed gcc-11/g++-11 and tbb
$ dpkg -l | grep tbb
ii libtbb-dev:amd64 2020.1-2 amd64 parallelism library for C++ - development files
ii libtbb2:amd64 2020.1-2 amd64 parallelism library for C++ - runtime files
$ dpkg -l | grep gcc-11
ii gcc-11 11.1.0-1ubuntu1~20.04 amd64 GNU C compiler
ii gcc-11-base:amd64 11.1.0-1ubuntu1~20.04 amd64 GCC, the GNU Compiler Collection (base package)
ii libgcc-11-dev:amd64 11.1.0-1ubuntu1~20.04 amd64 GCC support library (development files)
$ dpkg -l | grep g++-11
ii g++-11 11.1.0-1ubuntu1~20.04 amd64 GNU C++ compiler
then, I wrote cmake like below
https://github.com/yumetodo/SigContrastFastAviUtl/blob/master/test/CMakeLists.txt
...
find_package(TBB REQUIRED tbb)
...
target_link_libraries(SigContrastFastAviUtl_test ${TBB_IMPORTED_TARGETS})
...
However, it's seemed me that find_package doesn't work and link error was occurred.
$ cmake -B build -DCMAKE_CXX_COMPILER=g++-11 -DCMAKE_C_COMPILER=gcc-11
-- Configuring done
You have changed variables that require your cache to be deleted.
Configure will be re-run and you may have to reset some variables.
The following variables have changed:
CMAKE_CXX_COMPILER= g++-11
CMAKE_C_COMPILER= gcc-11
CMAKE_CXX_COMPILER= g++-11
-- The CXX compiler identification is GNU 11.1.0
-- Check for working CXX compiler: /usr/bin/g++-11
-- Check for working CXX compiler: /usr/bin/g++-11 -- 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
-- 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
-- The C compiler identification is GNU 11.1.0
-- Check for working C compiler: /usr/bin/gcc-11
-- Check for working C compiler: /usr/bin/gcc-11 -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/yumetodo/SigContrastFastAviUtl/test/build
$ cmake --build build/
Scanning dependencies of target SigContrastFastAviUtl_test
[ 16%] Building CXX object CMakeFiles/SigContrastFastAviUtl_test.dir/LUT.cpp.o
[ 33%] Building CXX object CMakeFiles/SigContrastFastAviUtl_test.dir/random.cpp.o
[ 50%] Building CXX object CMakeFiles/SigContrastFastAviUtl_test.dir/RSigmoidTable.cpp.o
[ 66%] Building CXX object CMakeFiles/SigContrastFastAviUtl_test.dir/SigmoidTable.cpp.o
[ 83%] Building CXX object CMakeFiles/SigContrastFastAviUtl_test.dir/test.cpp.o
/home/yumetodo/SigContrastFastAviUtl/test/test.cpp: In member function ‘virtual void iu_Analyzer_x_iutest_x_calcAverage_Test::Body()’:
/home/yumetodo/SigContrastFastAviUtl/test/test.cpp:114:19: warning: unused variable ‘_’ [-Wunused-variable]
114 | for (auto _ : std::views::iota(0, 1000)) input.emplace_back(d(engine));
| ^
/home/yumetodo/SigContrastFastAviUtl/test/test.cpp: In member function ‘virtual void iu_Analyzer_x_iutest_x_calcStdev_Test::Body()’:
/home/yumetodo/SigContrastFastAviUtl/test/test.cpp:124:19: warning: unused variable ‘_’ [-Wunused-variable]
124 | for (auto _ : std::views::iota(0, 1000)) input.emplace_back(d(engine));
| ^
[100%] Linking CXX executable SigContrastFastAviUtl_test
/usr/bin/ld: CMakeFiles/SigContrastFastAviUtl_test.dir/test.cpp.o: in function `tbb::task_group_context::task_group_context(tbb::internal::string_index)':
test.cpp:(.text._ZN3tbb18task_group_contextC2ENS_8internal12string_indexE[_ZN3tbb18task_group_contextC5ENS_8internal12string_indexE]+0x41): undefined reference to `tbb::task_group_context::init()'
/usr/bin/ld: CMakeFiles/SigContrastFastAviUtl_test.dir/test.cpp.o: in function `tbb::task::task()':
test.cpp:(.text._ZN3tbb4taskC2Ev[_ZN3tbb4taskC5Ev]+0x13): undefined reference to `vtable for tbb::task'
/usr/bin/ld: CMakeFiles/SigContrastFastAviUtl_test.dir/test.cpp.o: in function `tbb::task::~task()':
.
.
.
(full log is here)
I watched below but not resolved.
c++17 parallel algorithms and CMake
https://github.com/oneapi-src/oneTBB/blob/tbb_2020/cmake/README.rst#binary-package-integration
How should I do?
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 46dcc93..8b662dc 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
## -60,6 +60,7 ## if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUC)
if(WIN32)
target_link_libraries(SigContrastFastAviUtl_test wsock32 ws2_32)
endif()
- target_link_libraries(SigContrastFastAviUtl_test ${TBB_IMPORTED_TARGETS})
+ #target_link_libraries(SigContrastFastAviUtl_test ${TBB_IMPORTED_TARGETS})
+ target_link_libraries(SigContrastFastAviUtl_test TBB::tbb)
endif()
target_link_libraries(SigContrastFastAviUtl_test Threads::Threads)
-- Configuring done
CMake Error at CMakeLists.txt:58 (add_executable):
Target "SigContrastFastAviUtl_test" links to target "TBB::tbb" 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.
make: *** [Makefile:296: cmake_check_build_system] Error 1

CMake with clang shows undefined symbol, and with cl links correctly

TLDR
Im building a static library and linking it to an executable. Im generating makefiles with cmake. When I generate the makefile for cl (The compiler from visual studio) I have no problems, but when I generate the makefile for clang I get an undefined symbol.
Versions:
cmake version 3.18.1
clang version 11.0.0
Target: x86_64-pc-windows-msvc
Thread model: posix
cl version 19.26.28806 for x64
Minimal Example
I have the following structure for the proyect:
Proyect Root
│ CMakeLists.txt
│ foo.cpp
│ foo.hpp
│ main.cpp
│
└───bin
And this are the contents of the files:
foo.hpp
namespace foo {
void do_stuff(void);
}
foo.cpp
#include <foo.hpp>
namespace foo {
void do_stuff(void) {}
}
main.cpp
#include <foo.hpp>
int main(void) {
foo::do_stuff();
return 0;
}
And CMakeLists.txt
cmake_minimum_required(VERSION 3.0.0)
project(CompileAndLinkLib)
include_directories(".")
file(GLOB FOO_SRC "foo.cpp")
add_library(foo STATIC ${FOO_SRC})
add_executable(main "main.cpp")
target_link_libraries(main foo)
Correct linking
First I call vcvarsall.bat. I generate a nmake file with the following command:
cmake .. -G "NMake Makefiles"
And compile with:
nmake
The project compiles and links correctly
The undefined symbol
I generate the make file with the following command:
cmake .. -G "Unix Makefiles" -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
And when I compile with make I get the following output:
Scanning dependencies of target foo
[ 25%] Building CXX object CMakeFiles/foo.dir/foo.cpp.obj
[ 50%] Linking CXX static library foo.lib
[ 50%] Built target foo
Scanning dependencies of target main
[ 75%] Building CXX object CMakeFiles/main.dir/main.cpp.obj
[100%] Linking CXX executable main.exe
lld-link: error: undefined symbol: void __cdecl foo::do_stuff(void)
>>> referenced by C:\Users\pabsa\temp\main.cpp:4
>>> CMakeFiles/main.dir/main.cpp.obj:(main)
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [main.exe] Error 1
make[1]: *** [CMakeFiles/main.dir/all] Error 2
make: *** [all] Error 2
Im not sure if im doing something wrong, like if im missing something, or if this is an error with the makefile generated by cmake.
I just had the same problem, but with Clang 13. It could be solved with specifying clang as compiler in the CMakeLists, instead of letting CMake determine it automatically.
set(CMAKE_CXX_COMPILER "clang++")
(And yes, I read your original question correct, using this:
-DCMAKE_CXX_COMPILER=clang++
as an additional argument for cmake did not work for me as well, even if it looks like it should behave the same as setting it in CMakeLists.txt)
I tested again with:
clang version 12.0.0
Target: x86_64-pc-windows-msvc
Thread model: posix
And it worked corretly. Seems like it was a problem with clang 11
You're overcomplicating things imo. What about just "cmake .. -T ClangCL && cmake --build ."? Builds fine for me:
C:\Users\vital\test\_build>cmake .. -T ClangCL
-- Building for: Visual Studio 17 2022
-- Selecting Windows SDK version 10.0.20348.0 to target Windows 10.0.22000.
-- The C compiler identification is Clang 14.0.5 with MSVC-like command-line
-- The CXX compiler identification is Clang 14.0.5 with MSVC-like command-line
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/Llvm/x64/bin/clang-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/Microsoft Visual Studio/2022/Community/VC/Tools/Llvm/x64/bin/clang-cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/vital/test/_build
C:\Users\vital\test\_build>cmake --build .
MSBuild version 17.3.1+2badb37d1 for .NET Framework
Checking Build System
Building Custom Rule C:/Users/vital/test/CMakeLists.txt
foo.vcxproj -> C:\Users\vital\test\_build\Debug\foo.lib
Building Custom Rule C:/Users/vital/test/CMakeLists.txt
main.vcxproj -> C:\Users\vital\test\_build\Debug\main.exe
Building Custom Rule C:/Users/vital/test/CMakeLists.txt
C:\Users\vital\test\_build>

make openmp g++-6.2.0 no such file [duplicate]

This question already has an answer here:
CMake - set_property could not find CACHE variable
(1 answer)
Closed 6 years ago.
cmakelist.txt
cmake_minimum_required(VERSION 3.7)
project(multithreading)
# Find ITK.
find_package(ITK REQUIRED)
include(${ITK_USE_FILE})
FIND_PACKAGE( OpenMP REQUIRED)
if(OPENMP_FOUND)
message("OPENMP FOUND")
set(CMAKE_C_FLAGS “${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}”)
set(CMAKE_CXX_FLAGS “${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}“)
set(CMAKE_EXE_LINKER_FLAGS “${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}”)
endif()
add_executable(multithreading multithreading.cpp )
target_link_libraries(multithreading ${ITK_LIBRARIES})
TARGET_LINK_LIBRARIES(multithreading ${OpenMP_CXX_LIBRARIES})
And then I change default compiler which is AppleClang to gcc-6.2.0, and then cmake
,all openmp flags find, and configure is fine.
cmake -DCMAKE_C_COMPILER=/usr/local/gcc-6.2.0/bin/gcc-6.2.0 -DCMAKE_CXX_COMPILER=/usr/local/gcc-6.2.0/bin/g++-6.2.0 ./
-- The C compiler identification is GNU 6.2.0
-- The CXX compiler identification is GNU 6.2.0
-- 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/local/gcc-6.2.0/bin/gcc-6.2.0
-- Check for working C compiler: /usr/local/gcc-6.2.0/bin/gcc-6.2.0 -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - 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/local/gcc-6.2.0/bin/g++-6.2.0
-- Check for working CXX compiler: /usr/local/gcc-6.2.0/bin/g++-6.2.0 -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Try OpenMP C flag = [-fopenmp]
-- Performing Test OpenMP_FLAG_DETECTED
-- Performing Test OpenMP_FLAG_DETECTED - Success
-- Try OpenMP CXX flag = [-fopenmp]
-- Performing Test OpenMP_FLAG_DETECTED
-- Performing Test OpenMP_FLAG_DETECTED - Success
-- Found OpenMP: -fopenmp
OPENMP FOUND
-- Configuring done
-- Generating done
then next when I do ‘make’ it shows me
canning dependencies of target multithreading
[ 50%] Building CXX object CMakeFiles/multithreading.dir/multithreading.cpp.o
g++-6.2.0: error: “: No such file or directory
g++-6.2.0: fatal error: no input files
compilation terminated.
/bin/sh: -fopenmp“: command not found
make[2]: *** [CMakeFiles/multithreading.dir/multithreading.cpp.o] Error 127
make[1]: *** [CMakeFiles/multithreading.dir/all] Error 2
make: *** [all] Error 2
If I do g++ -fopenmp myproject.cpp it will not link ITK Library
g++ -fopenmp multithreading.cpp
multithreading.cpp:4:44: fatal error: itkRescaleIntensityImageFilter.h: No such file or directory
#include "itkRescaleIntensityImageFilter.h"
^
compilation terminated.
So I am wondering how can I fix that issue, so use itk and openmp as library at the same time.
You're using language/locale-specific double quotes. Most programming languages don't support these, including CMake. Use the "normal" double quotes: "

How can I make a library find Eigen with CMake in macOS?

I am trying to compile my project with CMake which includes the Ceres Solver library. I'm using macOS Sierra with Xcode 8.1 dev tools.
I installed the library with Homebrew (brew install ceres-solver). I downloaded and tested the binary manually (http://ceres-solver.org/building.html#mac-os-x), and that works just fine. But I can't include it in my own project because it can't seem to find Eigen. Here is a complete example:
ceres-test/CMakeLists.txt:
cmake_minimum_required(VERSION 2.8)
project(CeresTest)
find_package(ceres REQUIRED)
add_executable(
TestCeres
src/test_ceres.cpp
)
target_link_libraries(
TestCeres
ceres
)
ceres-test/src/test_ceres.cpp
#include <iostream>
#include "ceres/ceres.h"
int main(int argc, char** argv) {
std::cout << "Works." << std::endl;
return 0;
}
How I compile it:
mkdir build
cd build
cmake ..
make
Full output:
me: ceres-test $ mkdir build
me: ceres-test $ cd build/
cmake
me: build $ cmake ..
-- 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
-- Found required Ceres dependency: Eigen version 3.2.10 in /usr/local/include/eigen3
-- Found required Ceres dependency: Glog in /usr/local/include
-- Found Ceres version: 1.11.0 installed in: /usr/local
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/me/Tests/ceres-test/build
make
me: build $ make
Scanning dependencies of target TestCeres
[ 50%] Building CXX object CMakeFiles/TestCeres.dir/src/test_ceres.cpp.o
In file included from /Users/me/Tests/ceres-test/src/test_ceres.cpp:3:
In file included from /usr/local/include/ceres/ceres.h:37:
In file included from /usr/local/include/ceres/autodiff_cost_function.h:132:
In file included from /usr/local/include/ceres/internal/autodiff.h:145:
/usr/local/include/ceres/jet.h:165:10: fatal error: 'Eigen/Core' file not found
#include "Eigen/Core"
^
1 error generated.
make[2]: *** [CMakeFiles/TestCeres.dir/src/test_ceres.cpp.o] Error 1
make[1]: *** [CMakeFiles/TestCeres.dir/all] Error 2
make: *** [all] Error 2
I have no idea how to resolve this. None of the solutions I found online helped. CMake seems to be finding the Eigen library just fine, so I'm not sure how to add it in.
On a side note I cannot include "Eigen/Core" directly either, but the tests that I was able to compile do include it and those are fine. I'm not familiar how to deal with these kinds of problems with CMake.
Edit: I can get it to compile if I include it as "eigen3/Eigen/Core" but I can't change the source code for Ceres.
Fixed with
include_directories(${EIGEN_INCLUDE_DIR})
in the CMakeLists....
For my mac mini m1.
I found the eigen library through
brew link --overwrite eigen.
It's located on
/opt/homebrew/Cellar/eigen/3.4.0_1/include/eigen3

Coin3D library using cmake on Fedora 20 - fatal error: Inventor/Qt/SoQt.h: No such file or directory

I have create a project that uses Cmake and Coin3D libraries: https://github.com/tuxdna/phyloviz
I am getting a fatal error: Inventor/Qt/SoQt.h: No such file or directory. This is what I am doing:
$ sudo yum install cmake SoQt-devel
$ cd path/to/phyloviz
[phyloviz] $ mkdir build
[phyloviz] $ cd build/
[phyloviz/build] $ cmake ../ -DCOIN3D_INCLUDE_DIRS=/usr/include/Coin2/
-- The C compiler identification is GNU 4.8.2
-- The CXX compiler identification is GNU 4.8.2
-- Check for working C compiler: /bin/cc
-- Check for working C compiler: /bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /bin/c++
-- Check for working CXX compiler: /bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Found PkgConfig: /bin/pkg-config (found version "0.28")
-- Looking for Q_WS_X11
-- Looking for Q_WS_X11 - found
-- Looking for Q_WS_WIN
-- Looking for Q_WS_WIN - not found
-- Looking for Q_WS_QWS
-- Looking for Q_WS_QWS - not found
-- Looking for Q_WS_MAC
-- Looking for Q_WS_MAC - not found
-- Found Qt4: /bin/qmake-qt4 (found version "4.8.5")
-- Found Coin3D: /usr/lib64/libCoin.so
-- Configuring done
-- Generating done
-- Build files have been written to: .../phyloviz/build
Now lets compile the code
[phyloviz/build] $ make
Scanning dependencies of target ev-iv
[ 50%] Building CXX object CMakeFiles/ev-iv.dir/src/ev-iv/ev-iv.cc.o
.../phyloviz/src/ev-iv/ev-iv.cc:1:30: fatal error: Inventor/Qt/SoQt.h: No such file or directory
#include <Inventor/Qt/SoQt.h>
^
compilation terminated.
make[2]: *** [CMakeFiles/ev-iv.dir/src/ev-iv/ev-iv.cc.o] Error 1
make[1]: *** [CMakeFiles/ev-iv.dir/all] Error 2
make: *** [all] Error 2
[phyloviz/build]$
Even though I have specified the include directory using cmake ../ -DCOIN3D_INCLUDE_DIRS=/usr/include/Coin2/, I am getting the fatal error above.
This works fine on Ubuntu 14.04. How can I resolve this?