OpenCV with xcode error: Undefined symbols for architecture x86_64: - c++

I'm trying to install opencv and use it with xCode for making application in C++.
I installed it using macports and follow many tutorials to do it. I have done the linking too in xcode but there is problems that some function dosen't work. it give an error like Undefined symbols for architecture x86_64:
cv::resize(cv::_InputArray const&, cv::_OutputArray const&, cv::Size_<int>, double, double, int)",
"cv::floodFill(cv::_OutputArray const&, cv::Point_<int>, cv::Scalar_<double>, cv::Rect_<int>*, cv::Scalar_<double>, cv::Scalar_<double>, int)
If I switch the build arch to 32 bits, it gives the same error with more functions.
any idea ? I try to delete macports with opencv and install it using homebrew in 32 bits build but homebrew cannot install it for unknown error. so is the library not 64 bits compatible ?

I got OpenCV 2.3.0 installed on my Mac through my favorite way, which is download the source code and compile it:
tar -xzvf OpenCV-2.3.0.tar.bz2
cd OpenCV-2.3.0
mkdir build
cd build
cmake ../
-- Extracting svn version, please wait...
-- SVNVERSION:
-- Detected version of GNU GCC: 42 (402)
-- checking for module 'libdc1394-2'
-- package 'libdc1394-2' not found
-- checking for module 'libdc1394'
-- package 'libdc1394' not found
-- Found ZLIB: /usr/lib/libz.dylib (found version "1.2.3")
-- Found PythonInterp: /usr/bin/python2.6 (found version "2.6.1")
-- Use NumPy headers from: /System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/numpy/core/include
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named sphinx
-- CUDA detected: 4.0
-- CUDA NVCC target flags: -gencode;arch=compute_11,code=sm_11;-gencode;arch=compute_12,code=sm_12;-gencode;arch=compute_13,code=sm_13;-gencode;arch=compute_20,code=sm_20;-gencode;arch=compute_20,code=sm_21;-gencode;arch=compute_20,code=compute_20
-- Parsing 'cvconfig.h.cmake'
--
-- General configuration for opencv 2.3.0 =====================================
--
-- Built as dynamic libs?: ON
-- Compiler:
-- C++ flags (Release): -m32 -Wall -pthread -march=i386 -O3 -DNDEBUG -fomit-frame-pointer -ffast-math -msse -msse2 -DNDEBUG
-- C++ flags (Debug): -m32 -Wall -pthread -march=i386 -g -O0 -DDEBUG -D_DEBUG -ggdb3
-- Linker flags (Release):
-- Linker flags (Debug):
--
-- GUI:
-- Cocoa: YES
--
-- Media I/O:
-- ZLib: TRUE
-- JPEG: TRUE
-- PNG: TRUE
-- TIFF: TRUE
-- JPEG 2000: TRUE
-- OpenEXR: NO
-- OpenNI: FALSE
--
-- Video I/O: QTKit
--
-- Interfaces:
-- Python: ON
-- Python interpreter: /usr/bin/python2.6
-- Python numpy: YES
-- Use IPP: NO
-- Use TBB: NO
-- Use ThreadingFramework: NO
-- Use Cuda: YES
-- Use Eigen: NO
--
-- Documentation:
-- Build Documentation: NO
--
-- Install path: /usr/local
--
-- cvconfig.h is in: /Users/karlphillip/installers/OpenCV-2.3.0/build
-- -----------------------------------------------------------------
--
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/karlphillip/installers/OpenCV-2.3.0/build
Then:
make
sudo make install
And there it is:
$ pkg-config --cflags --libs opencv
-I/usr/local/include/opencv -I/usr/local/include -L/usr/local/lib -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_ml -lopencv_video -lopencv_features2d -lopencv_calib3d -lopencv_objdetect -lopencv_contrib -lopencv_legacy -lopencv_flann
Note: if you need to install any dependencies, use brew!
And all OpenCV libs are x86_64:
$ file /usr/local/lib/libopencv_highgui.dylib
/usr/local/lib/libopencv_highgui.dylib: Mach-O 64-bit dynamically linked shared library x86_64
$ file /usr/local/lib/libopencv_imgproc.dylib
/usr/local/lib/libopencv_imgproc.dylib: Mach-O 64-bit dynamically linked shared library x86_64
I suggest you remove the current OpenCV installation and make sure there is nothing left in your system before downloading and compiling it from scratch.

Related

How to use lld with CMake on Windows?

I'm trying to compile SDL2 (https://www.libsdl.org/download-2.0.php) using CMake with clang + lld (http://releases.llvm.org/) + mingw (https://sourceforge.net/projects/mingw-w64/) headers on Windows 10. Despite my many efforts, I seem unable to get CMake to use the lld linker over the mingw ld linker.
I currently build sdl2 with a batch file:
#ECHO OFF
IF NOT EXIST build MKDIR build
PUSHD build
cmake.exe -DCMAKE_BUILD_TYPE=Debug -G "MinGW Makefiles"^
-DCMAKE_C_FLAGS="-target x86_64-windows-gnu"^
-DCMAKE_C_COMPILER_ID="Clang" -DCMAKE_C_COMPILER="clang.exe"^
-DCMAKE_CXX_FLAGS="-target x86_64-windows-gnu"^
-DCMAKE_CXX_COMPILER_ID="Clang++" -DCMAKE_CXX_COMPILER="clang++.exe"^
-DDIRECTX=OFF -DSDL_TEST=OFF -DSDL_SHARED=OFF -DSDL_STATIC=ON ..
cmake.exe --build . -- -j %NUMBER_OF_PROCESSORS%
POPD
I have tried to no avail:
setting -fuse-ld=lld.exe
setting LDFLAGS=lld.exe
setting -DCMAKE_LINKER=lld.exe
the solution from: CMake: use a custom linker
Any help would be greatly appreciated.
To replicate your environment, I followed these steps:
I installed LLVM+Clang 12 to C:\Program Files\LLVM from the GitHub releases page: https://github.com/llvm/llvm-project/releases/download/llvmorg-12.0.0/LLVM-12.0.0-win64.exe
I downloaded mingw-w64 via MSYS2. I have it installed to C:\msys64. See: https://www.msys2.org/
I then downloaded SDL2 2.0.14 from https://www.libsdl.org/release/SDL2-2.0.14.zip and unzipped it to D:\SDL2-2.0.14
I have CMake 3.20 and Ninja 1.10.2 installed system-wide and in the PATH.
Then, I created D:\clang-mingw.cmake with the following contents:
set(CMAKE_C_COMPILER "C:/Program Files/LLVM/bin/clang.exe")
set(CMAKE_CXX_COMPILER "C:/Program Files/LLVM/bin/clang++.exe")
set(CMAKE_C_COMPILER_TARGET x86_64-windows-gnu)
set(CMAKE_CXX_COMPILER_TARGET x86_64-windows-gnu)
set(CMAKE_SYSROOT "C:/msys64/mingw64")
set(CMAKE_EXE_LINKER_FLAGS_INIT "-fuse-ld=lld")
set(CMAKE_MODULE_LINKER_FLAGS_INIT "-fuse-ld=lld")
set(CMAKE_SHARED_LINKER_FLAGS_INIT "-fuse-ld=lld")
This is called a toolchain file. These are used to inform CMake about non-standard compiler and library setups like this one.
Setting the CMAKE_<LANG>_COMPILER variables (naturally) points CMake to the compilers you want to use. In this case, that's Clang.
Setting CMAKE_<LANG>_COMPILER_TARGET configures Clang to use the x86_64-windows-gnu target when compiling. This is important for CMake's compiler detection and sanity checking steps.
Setting CMAKE_SYSROOT informs Clang where to find all of the standard libraries and headers (ie. those from mingw-w64).
Finally, we ensure LLD is used by adding -fuse-ld=lld to the linker flags used when linking executables, loadable modules, and shared libraries (but not static libraries, since no linker is needed, just the archiver). The CMAKE_{EXE,MODULE,SHARED}_LINKER_FLAGS_INIT variables are meant to be set from the toolchain for this purpose.
Then from a normal command prompt (i.e. not a Visual Studio command prompt or MSYS2 bash), I ran:
D:\SDL2-2.0.14>cmake -G Ninja -S . -B build -DCMAKE_TOOLCHAIN_FILE=D:/clang-mingw.cmake -DCMAKE_BUILD_TYPE=Debug -DDIRECTX=OFF -DSDL_TEST=OFF -DSDL_SHARED=OFF -DSDL_STATIC=ON
-- The C compiler identification is Clang 12.0.0
-- The CXX compiler identification is Clang 12.0.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files/LLVM/bin/clang.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/LLVM/bin/clang++.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE)
-- Performing Test HAVE_GCC_WALL
-- Performing Test HAVE_GCC_WALL - Success
[... output clipped ...]
The configure command I used does little more than replicate the SDL-specific settings you used in your question. It just selects Ninja as the build system generator (you could of course replace this with a different one if you so desired) and sets the toolchain file to the one above.
It then builds without errors.
D:\SDL2-2.0.14>cmake --build build
[... output clipped ...]
[163/164] C:\PROGRA~1\LLVM\bin\clang.exe --target=x86_64-windows-gnu --sysroot=C:/msys64/mingw64 -DUSING_GENERATED_CONFIG_H -Iinclude -I../include -idirafter "D:/SDL2-2.0.14/src/video/khronos" "-ID:/SDL2-2.0.14/src/hidapi/hidapi" -msse3 -msse2 -msse -m3dnow -mmmx -Wshadow -fvisibility=hidden -Wdeclaration-after-statement -Werror=declaration-after-statement -fno-strict-aliasing -Wall -g -MD -MT CMakeFiles/SDL2-static.dir/src/video/yuv2rgb/yuv_rgb.c.obj -MF CMakeFiles\SDL2-static.dir\src\video\yuv2rgb\yuv_rgb.c.obj.d -o CMakeFiles/SDL2-static.dir/src/video/yuv2rgb/yuv_rgb.c.obj -c ../src/video/yuv2rgb/yuv_rgb.c
[164/164] cmd.exe /C "cd . && "C:\Program Files\CMake\bin\cmake.exe" -E rm -f libSDL2d.a && C:\PROGRA~1\LLVM\bin\llvm-ar.exe qc libSDL2d.a #CMakeFiles\SDL2-static.rsp && cd ."

Cross-compiling enet from Linux to Windows, linking errors

Introduction
I'm trying to cross compile to Windows from Linux using MinGW-W64.
I had it working before I added enet to my project, however I'm now receiving issues with linking to enet
CMake finds enet correctly. ENET_LIBRARY and ENET_INCLUDE_DIR are set to the right locations.
ENet contains the symbols, as verified using /usr/x86_64-w64-mingw32/bin/objdump /usr/local/mingw64/lib/libenet.a -t
Build fails with "undefined reference to `enet_address_set_host'"
I'm able to compile the same code base natively using Visual Studio and VCPkg
Edit: Checking the contents of libenet.a verifies that it's a problem with cross-compiling enet, not my program in particular
None of my other dependencies use GNU autoconf, so I expect there's a problem there.
The Error
-- The C compiler identification is GNU 8.2.0
-- The CXX compiler identification is GNU 8.2.0
-- Check for working C compiler: /usr/bin/x86_64-w64-mingw32-gcc
-- Check for working C compiler: /usr/bin/x86_64-w64-mingw32-gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/x86_64-w64-mingw32-g++
-- Check for working CXX compiler: /usr/bin/x86_64-w64-mingw32-g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found SFML 2.5 in /usr/local/mingw64/include
-- Found SFGUI in /usr/local/mingw64/include
-- Found Thor in /usr/local/mingw64/include
-- Found Lua in /usr/local/mingw64/include/lua5.1/
-- Found Lua: /usr/local/mingw64/lib/liblua5.1.a
-- Found ENet: /usr/local/mingw64/lib/libenet.a
-- Found ENet in /usr/local/mingw64/include
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - found
-- Found Threads: TRUE
/usr/local/mingw64/lib/liblua5.1.a/usr/local/mingw64/lib/libenet.awsock32ws2_32winmm
-- Adding executable: client (with server)
-- Configuring done
-- Generating done
-- Build files have been written to: /home/ruben/dev/rvwp
Scanning dependencies of target rvwp
[SNIP]
[ 98%] Building CXX object CMakeFiles/rvwp.dir/source/tests/t_chunk.cpp.obj
[100%] Linking CXX executable bin/rvwp.exe
/usr/lib/gcc/x86_64-w64-mingw32/8.2.0/../../../../x86_64-w64-mingw32/bin/ld: CMakeFiles/rvwp.dir/objects.a(address.cpp.obj):address.cpp:(.text+0xc6): undefined reference to `enet_address_set_host'
/usr/lib/gcc/x86_64-w64-mingw32/8.2.0/../../../../x86_64-w64-mingw32/bin/ld: CMakeFiles/rvwp.dir/objects.a(net.cpp.obj):net.cpp:(.text+0x105): undefined reference to `enet_initialize'
/usr/lib/gcc/x86_64-w64-mingw32/8.2.0/../../../../x86_64-w64-mingw32/bin/ld: CMakeFiles/rvwp.dir/objects.a(net.cpp.obj):net.cpp:(.text+0x204): undefined reference to `enet_packet_create'
/usr/lib/gcc/x86_64-w64-mingw32/8.2.0/../../../../x86_64-w64-mingw32/bin/ld: CMakeFiles/rvwp.dir/objects.a(net.cpp.obj):net.cpp:(.text+0x217): undefined reference to `enet_peer_send'
/usr/lib/gcc/x86_64-w64-mingw32/8.2.0/../../../../x86_64-w64-mingw32/bin/ld: CMakeFiles/rvwp.dir/objects.a(net.cpp.obj):net.cpp:(.text+0x29f): undefined reference to `enet_packet_create'
/usr/lib/gcc/x86_64-w64-mingw32/8.2.0/../../../../x86_64-w64-mingw32/bin/ld: CMakeFiles/rvwp.dir/objects.a(net.cpp.obj):net.cpp:(.text+0x2b3): undefined reference to `enet_peer_send'
/usr/lib/gcc/x86_64-w64-mingw32/8.2.0/../../../../x86_64-w64-mingw32/bin/ld: CMakeFiles/rvwp.dir/objects.a(net.cpp.obj):net.cpp:(.text+0x5af): undefined reference to `enet_host_destroy'
/usr/lib/gcc/x86_64-w64-mingw32/8.2.0/../../../../x86_64-w64-mingw32/bin/ld: CMakeFiles/rvwp.dir/objects.a(net.cpp.obj):net.cpp:(.text+0x65b): undefined reference to `enet_host_create'
/usr/lib/gcc/x86_64-w64-mingw32/8.2.0/../../../../x86_64-w64-mingw32/bin/ld: CMakeFiles/rvwp.dir/objects.a(net.cpp.obj):net.cpp:(.text+0x91f): undefined reference to `enet_host_create'
/usr/lib/gcc/x86_64-w64-mingw32/8.2.0/../../../../x86_64-w64-mingw32/bin/ld: CMakeFiles/rvwp.dir/objects.a(net.cpp.obj):net.cpp:(.text+0x950): undefined reference to `enet_host_connect'
/usr/lib/gcc/x86_64-w64-mingw32/8.2.0/../../../../x86_64-w64-mingw32/bin/ld: CMakeFiles/rvwp.dir/objects.a(net.cpp.obj):net.cpp:(.text+0x96c): undefined reference to `enet_host_service'
/usr/lib/gcc/x86_64-w64-mingw32/8.2.0/../../../../x86_64-w64-mingw32/bin/ld: CMakeFiles/rvwp.dir/objects.a(net.cpp.obj):net.cpp:(.text+0x1023): undefined reference to `enet_host_service'
/usr/lib/gcc/x86_64-w64-mingw32/8.2.0/../../../../x86_64-w64-mingw32/bin/ld: CMakeFiles/rvwp.dir/objects.a(net.cpp.obj):net.cpp:(.text+0x1437): undefined reference to `enet_packet_destroy'
/usr/lib/gcc/x86_64-w64-mingw32/8.2.0/../../../../x86_64-w64-mingw32/bin/ld: CMakeFiles/rvwp.dir/objects.a(net.cpp.obj):net.cpp:(.text+0x121): undefined reference to `enet_deinitialize'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/rvwp.dir/build.make:991: bin/rvwp.exe] Error 1
make[1]: *** [CMakeFiles/Makefile2:73: CMakeFiles/rvwp.dir/all] Error 2
make: *** [Makefile:130: all] Error 2
Cross-compiling Enet
To cross compile enet, I use the following script
#!/bin/bash
TOOLSET="x86_64-w64-mingw32"
wget http://enet.bespin.org/download/enet-1.3.13.tar.gz
tar -xzf enet-1.3.13.tar.gz
cd enet-1.3.13
./configure \
--build=${TOOLSET} \
--host=x86_64-windows \
--target=${TOOLSET} \
--prefix=/usr/local/mingw64 \
--enable-shared
make -j3
sudo make install
My Program
I'm using cmake to generate the makefiles, and a toolchain to allow cross-compilation. The program compiles with SFML, thor, std::thread, and Lua fine. None of these libraries use GNU autoconf
My CMakeLists.txt looks like this:
find_package(ENet REQUIRED)
include_directories(${ENET_INCLUDE_DIR})
set(BASE_LIBRARIES ${CMAKE_THREAD_LIBS_INIT} ${LUA_LIBRARY} ${CMAKE_DL_LIBS} ${ENET_LIBRARY})
set(BASE_LIBRARIES ${BASE_LIBRARIES} wsock32 ws2_32 winmm)
message(${BASE_LIBRARIES})
set(EXECUTABLE_NAME "rvwp")
add_executable(${EXECUTABLE_NAME} WIN32 ${CLIENT_SRC})
set_target_properties(${EXECUTABLE_NAME} PROPERTIES BUILD_WITH_INSTALL_RPATH true)
install(TARGETS ${EXECUTABLE_NAME} DESTINATION bin)
target_link_libraries(${EXECUTABLE_NAME} ${BASE_LIBRARIES} ${SFML_LIBRARIES} ${SFGUI_LIBRARY} ${THOR_LIBRARY})
The findENet file looks like this:
FIND_PATH(ENET_INCLUDE_DIR enet/enet.h
PATHS
$ENV{ENETDIR}
/usr/local
/usr
PATH_SUFFIXES include)
FIND_LIBRARY(ENET_LIBRARY
NAMES enet
PATHS
$ENV{ENETDIR}
/usr/local
/usr
PATH_SUFFIXES lib)
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(ENet DEFAULT_MSG ENET_LIBRARY ENET_INCLUDE_DIR)
IF (ENet_FOUND)
MESSAGE(STATUS "Found ENet in ${ENET_INCLUDE_DIR}")
IF(WIN32)
SET(WINDOWS_ENET_DEPENDENCIES "ws2_32;winmm")
SET(ENET_LIBRARIES ${ENET_LIBRARY} ${WINDOWS_ENET_DEPENDENCIES})
ELSE(WIN32)
SET(ENET_LIBRARIES ${ENET_LIBRARY})
ENDIF(WIN32)
ENDIF (ENet_FOUND)
MARK_AS_ADVANCED(ENET_LIBRARY ENET_LIBRARIES ENET_INCLUDE_DIR)
The tool chain looks like this:
# Sample toolchain file for building for Windows from an Ubuntu Linux system.
#
# Typical usage:
# *) install cross compiler: `sudo apt-get install mingw-w64 g++-mingw-w64`
# *) cd build
# *) cmake -DCMAKE_TOOLCHAIN_FILE=~/Toolchain-Ubuntu-mingw64.cmake ..
set(CMAKE_SYSTEM_NAME Windows)
set(TOOLCHAIN_PREFIX x86_64-w64-mingw32)
# cross compilers to use for C and C++
set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc)
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++)
set(CMAKE_RC_COMPILER ${TOOLCHAIN_PREFIX}-windres)
SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc -static-libstdc++" )
# target environment on the build host system
# set 1st to dir with the cross compiler's C/C++ headers/libs
set(CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX} /usr/local/mingw64 ./extlibs)
set(LUA_INCLUDE_DIR /usr/local/mingw64/include/lua5.1/)
set(LUA_LIBRARY /usr/local/mingw64/lib/liblua5.1.a)
set(OPENAL_LIBRARY /usr/local/mingw64/lib/libopenal32.a)
# modify default behavior of FIND_XXX() commands to
# search for headers/libs in the target environment and
# search for programs in the build host environment
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
The linklibs.rsp file is used to pass linking commands to the linker, here is its value:
/usr/local/mingw64/lib/liblua5.1.a /usr/local/mingw64/lib/libenet.a -lwsock32 -lws2_32 -lwinmm /usr/local/mingw64/lib/libsfml-system.a /usr/local/mingw64/lib/libsfml-window.a /usr/local/mingw64/lib/libsfml-graphics.a /usr/local/mingw64/lib/libsfml-network.a /usr/local/mingw64/lib/libsfml-audio.a /usr/local/mingw64/bin/sfgui.dll /usr/local/mingw64/bin/libthor.dll -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32
(EDIT) AR Formats
Extracting the not-working libenet.a and using file results in this:
callbacks.o: ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), with debug_info, not stripped
Extracting the working libsfml-graphics.a results in this:
d000508.o: Intel amd64 COFF object file, no line number info, not stripped, 5 sections, symbol offset=0x144, 8 symbols
So it appears that the problem is in compiling enet

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

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.

C++ headers not found on OSX Sierra

I'm trying to compile a program using CMake and I'm getting the following output:
make VERBOSE=1
Re-run cmake no build system arguments
-- Found ccache /usr/local/osquery/bin/ccache
-- Using ccache to speed up compilation
-- The C compiler identification is Clang 3.8.0
-- The CXX compiler identification is Clang 3.8.0
-- Check for working C compiler: /usr/local/bin/clang
-- Check for working C compiler: /usr/local/bin/clang -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/local/bin/clang++
-- Check for working CXX compiler: /usr/local/bin/clang++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Welcome to osquery's build-- thank you for your patience! :)
-- For a brief tutorial see: http://osquery.readthedocs.io/en/stable/development/building/
-- If at first you dont succeed, perhaps: make distclean; make depsclean
-- Building for platform OS X (darwin, 10.12)
-- Building osquery version 1.6.2-801-gd402a6a sdk 1.6.2
-- Looking for C++ include tr1/tuple
-- Looking for C++ include tr1/tuple - not found
-- Found PythonInterp: /usr/local/osquery/bin/python (found version "2.7.12")
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - found
-- Found Threads: TRUE
-- Found library /usr/lib/libpthread.dylib
-- Found library /usr/lib/libz.dylib
-- Found library /usr/local/osquery/lib/libboost_system-mt.a
-- Found library /usr/local/osquery/lib/libboost_filesystem-mt.a
-- Found library /usr/local/osquery/lib/libgflags.a
-- Found library /usr/local/osquery/lib/libthrift.a
-- Found library /usr/local/osquery/lib/liblz4.a
-- Found library /usr/local/osquery/lib/libglog.a
-- Found library /usr/lib/libdl.dylib
-- Found library /usr/local/osquery/lib/libcppnetlib-uri.a
-- Found library /usr/local/osquery/lib/libcppnetlib-client-connections.a
-- Found library /usr/local/osquery/lib/libboost_regex-mt.a
-- Found library /usr/local/osquery/lib/librocksdb_lite.a
-- Found library /usr/local/osquery/lib/libsnappy.a
-- Found library /usr/local/osquery/lib/libssl.a
-- Found library /usr/local/osquery/lib/libyara.a
-- Found library /usr/local/osquery/lib/libcrypto.a
-- Found library /usr/local/osquery/lib/liblinenoise.a
-- Found library /usr/lib/liblzma.dylib
-- Found library /usr/lib/libbz2.dylib
-- Found library /usr/local/osquery/lib/libaws-cpp-sdk-kinesis.a
-- Found library /usr/local/osquery/lib/libaws-cpp-sdk-firehose.a
-- Found library /usr/local/osquery/lib/libaws-cpp-sdk-sts.a
-- Found library /usr/local/osquery/lib/libaws-cpp-sdk-core.a
-- Found library /usr/lib/libresolv.dylib
-- Found library /usr/lib/libxar.dylib
-- Found library /usr/local/osquery/lib/libmagic.a
-- Found library /usr/local/osquery/lib/libtsk.a
-- Found library /usr/local/osquery/lib/libaugeas.a
-- Found library /usr/local/osquery/lib/libfa.a
-- Found library /usr/local/osquery/lib/libxml2.a
-- Found library /usr/lib/libiconv.dylib
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/omer.katz/Documents/osquery/build/darwin10.12
/usr/local/osquery/Cellar/cmake/3.6.1_1/bin/cmake -H/Users/omer.katz/Documents/osquery -B/Users/omer.katz/Documents/osquery/build/darwin10.12 --check-build-system CMakeFiles/Makefile.cmake 0
/usr/local/osquery/Cellar/cmake/3.6.1_1/bin/cmake -E cmake_progress_start /Users/omer.katz/Documents/osquery/build/darwin10.12/CMakeFiles /Users/omer.katz/Documents/osquery/build/darwin10.12/CMakeFiles/progress.marks
/Library/Developer/CommandLineTools/usr/bin/make -f CMakeFiles/Makefile2 all
/Library/Developer/CommandLineTools/usr/bin/make -f third-party/sqlite3/CMakeFiles/osquery_sqlite.dir/build.make third-party/sqlite3/CMakeFiles/osquery_sqlite.dir/depend
cd /Users/omer.katz/Documents/osquery/build/darwin10.12 && /usr/local/osquery/Cellar/cmake/3.6.1_1/bin/cmake -E cmake_depends "Unix Makefiles" /Users/omer.katz/Documents/osquery /Users/omer.katz/Documents/osquery/third-party/sqlite3 /Users/omer.katz/Documents/osquery/build/darwin10.12 /Users/omer.katz/Documents/osquery/build/darwin10.12/third-party/sqlite3 /Users/omer.katz/Documents/osquery/build/darwin10.12/third-party/sqlite3/CMakeFiles/osquery_sqlite.dir/DependInfo.cmake --color=
Dependee "/Users/omer.katz/Documents/osquery/build/darwin10.12/third-party/sqlite3/CMakeFiles/osquery_sqlite.dir/DependInfo.cmake" is newer than depender "/Users/omer.katz/Documents/osquery/build/darwin10.12/third-party/sqlite3/CMakeFiles/osquery_sqlite.dir/depend.internal".
Dependee "/Users/omer.katz/Documents/osquery/build/darwin10.12/third-party/sqlite3/CMakeFiles/CMakeDirectoryInformation.cmake" is newer than depender "/Users/omer.katz/Documents/osquery/build/darwin10.12/third-party/sqlite3/CMakeFiles/osquery_sqlite.dir/depend.internal".
Scanning dependencies of target osquery_sqlite
/Library/Developer/CommandLineTools/usr/bin/make -f third-party/sqlite3/CMakeFiles/osquery_sqlite.dir/build.make third-party/sqlite3/CMakeFiles/osquery_sqlite.dir/build
[ 0%] Building C object third-party/sqlite3/CMakeFiles/osquery_sqlite.dir/sqlite3.c.o
cd /Users/omer.katz/Documents/osquery/build/darwin10.12/third-party/sqlite3 && /usr/local/osquery/bin/ccache /usr/local/bin/clang -DBOOST_NETWORK_ENABLE_HTTPS -DBOOST_NO_CXX11_VARIADIC_TEMPLATES -DDARWIN -DDARWIN_10_12 -DNDEBUG -DOSQUERY_BUILD_DISTRO=10.12 -DOSQUERY_BUILD_PLATFORM=darwin -DOSQUERY_BUILD_SDK_VERSION=1.6.2 -DOSQUERY_THRIFT="" -DOSQUERY_THRIFT_LIB=thrift -DOSQUERY_THRIFT_POINTER=boost -DOSQUERY_THRIFT_SERVER_LIB=thrift/server -DSQLITE_DISABLE_DIRSYNC -DSQLITE_DISABLE_FTS3_UNICODE -DSQLITE_DISABLE_FTS4_DEFERRED -DSQLITE_DISABLE_LFS -DSQLITE_ENABLE_API_ARMOR -DSQLITE_ENABLE_COLUMN_METADATA -DSQLITE_ENABLE_DBSTAT_VTAB -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_MEMORY_MANAGEMENT -DSQLITE_OMIT_AUTHORIZATION -DSQLITE_OMIT_DEPRECATED -DSQLITE_OMIT_LOOKASIDE -DSQLITE_OMIT_SHARED_CACHE -DSTRIP_FLAG_HELP=1 -isystem /Users/omer.katz/Documents/osquery/third-party/sysroots/darwin -isystem /usr/local/osquery/legacy/include -isystem /usr/local/osquery/include -I/usr/local/osquery/include/openssl -I/Users/omer.katz/Documents/osquery/third-party/sqlite3 -I/Users/omer.katz/Documents/osquery/include -I/Users/omer.katz/Documents/osquery -I/Users/omer.katz/Documents/osquery/build/darwin10.12/generated/gen-cpp -Qunused-arguments -Wstrict-aliasing -Wno-missing-field-initializers -Wno-unused-local-typedef -Wno-deprecated-register -Wno-unknown-warning-option -Wnon-virtual-dtor -Wchar-subscripts -Wpointer-arith -Woverloaded-virtual -Wformat -Wformat-security -Werror=format-security -Wabi-tag -fpermissive -fstack-protector-all -pipe -fdata-sections -ffunction-sections -mmacosx-version-min=10.12 -Os -fPIE -fpie -fPIC -fpic -march=x86-64 -mno-avx -Wno-parentheses-equality -Wno-unused-value -o CMakeFiles/osquery_sqlite.dir/sqlite3.c.o -c /Users/omer.katz/Documents/osquery/third-party/sqlite3/sqlite3.c
/Users/omer.katz/Documents/osquery/third-party/sqlite3/sqlite3.c:20330:17: warning: 'OSAtomicCompareAndSwapPtrBarrier' is deprecated: first deprecated in OS X 10.12 - Use atomic_compare_exchange_strong() from <stdatomic.h> instead [-Wdeprecated-declarations]
success = OSAtomicCompareAndSwapPtrBarrier(NULL, newzone,
^
/usr/include/libkern/OSAtomicDeprecated.h:547:6: note: 'OSAtomicCompareAndSwapPtrBarrier' has been explicitly marked deprecated here
bool OSAtomicCompareAndSwapPtrBarrier( void *__oldValue, void *__newValue, void * volatile *__theValue );
^
1 warning generated.
[ 0%] Built target osquery_sqlite
/Library/Developer/CommandLineTools/usr/bin/make -f third-party/gmock-1.7.0/CMakeFiles/gmock_main.dir/build.make third-party/gmock-1.7.0/CMakeFiles/gmock_main.dir/depend
cd /Users/omer.katz/Documents/osquery/build/darwin10.12 && /usr/local/osquery/Cellar/cmake/3.6.1_1/bin/cmake -E cmake_depends "Unix Makefiles" /Users/omer.katz/Documents/osquery /Users/omer.katz/Documents/osquery/third-party/gmock-1.7.0 /Users/omer.katz/Documents/osquery/build/darwin10.12 /Users/omer.katz/Documents/osquery/build/darwin10.12/third-party/gmock-1.7.0 /Users/omer.katz/Documents/osquery/build/darwin10.12/third-party/gmock-1.7.0/CMakeFiles/gmock_main.dir/DependInfo.cmake --color=
Dependee "/Users/omer.katz/Documents/osquery/build/darwin10.12/third-party/gmock-1.7.0/CMakeFiles/gmock_main.dir/DependInfo.cmake" is newer than depender "/Users/omer.katz/Documents/osquery/build/darwin10.12/third-party/gmock-1.7.0/CMakeFiles/gmock_main.dir/depend.internal".
Dependee "/Users/omer.katz/Documents/osquery/build/darwin10.12/third-party/gmock-1.7.0/CMakeFiles/CMakeDirectoryInformation.cmake" is newer than depender "/Users/omer.katz/Documents/osquery/build/darwin10.12/third-party/gmock-1.7.0/CMakeFiles/gmock_main.dir/depend.internal".
Scanning dependencies of target gmock_main
/Library/Developer/CommandLineTools/usr/bin/make -f third-party/gmock-1.7.0/CMakeFiles/gmock_main.dir/build.make third-party/gmock-1.7.0/CMakeFiles/gmock_main.dir/build
[ 0%] Building CXX object third-party/gmock-1.7.0/CMakeFiles/gmock_main.dir/gtest/src/gtest-all.cc.o
cd /Users/omer.katz/Documents/osquery/build/darwin10.12/third-party/gmock-1.7.0 && /usr/local/osquery/bin/ccache /usr/local/bin/clang++ -DBOOST_NETWORK_ENABLE_HTTPS -DBOOST_NO_CXX11_VARIADIC_TEMPLATES -DDARWIN -DDARWIN_10_12 -DNDEBUG -DOSQUERY_BUILD_DISTRO=10.12 -DOSQUERY_BUILD_PLATFORM=darwin -DOSQUERY_BUILD_SDK_VERSION=1.6.2 -DOSQUERY_THRIFT="" -DOSQUERY_THRIFT_LIB=thrift -DOSQUERY_THRIFT_POINTER=boost -DOSQUERY_THRIFT_SERVER_LIB=thrift/server -DSTRIP_FLAG_HELP=1 -isystem /Users/omer.katz/Documents/osquery/third-party/sysroots/darwin -isystem /usr/local/osquery/legacy/include -isystem /usr/local/osquery/include -I/usr/local/osquery/include/openssl -I/Users/omer.katz/Documents/osquery/third-party/sqlite3 -I/Users/omer.katz/Documents/osquery/include -I/Users/omer.katz/Documents/osquery -I/Users/omer.katz/Documents/osquery/build/darwin10.12/generated/gen-cpp -I/Users/omer.katz/Documents/osquery/third-party/gmock-1.7.0/include -I/Users/omer.katz/Documents/osquery/third-party/gmock-1.7.0 -I/Users/omer.katz/Documents/osquery/third-party/gmock-1.7.0/gtest/include -I/Users/omer.katz/Documents/osquery/third-party/gmock-1.7.0/gtest -L/usr/local/osquery/lib -L/usr/local/osquery/lib -DGTEST_HAS_PTHREAD=1 -Qunused-arguments -Wstrict-aliasing -Wno-missing-field-initializers -Wno-unused-local-typedef -Wno-deprecated-register -Wno-unknown-warning-option -Wnon-virtual-dtor -Wchar-subscripts -Wpointer-arith -Woverloaded-virtual -Wformat -Wformat-security -Werror=format-security -Wabi-tag -fpermissive -fstack-protector-all -pipe -fdata-sections -ffunction-sections -mmacosx-version-min=10.12 -Os -fPIE -fpie -fPIC -fpic -march=x86-64 -mno-avx -o CMakeFiles/gmock_main.dir/gtest/src/gtest-all.cc.o -c /Users/omer.katz/Documents/osquery/third-party/gmock-1.7.0/gtest/src/gtest-all.cc
In file included from /Users/omer.katz/Documents/osquery/third-party/gmock-1.7.0/gtest/src/gtest-all.cc:39:
/Users/omer.katz/Documents/osquery/third-party/gmock-1.7.0/gtest/include/gtest/gtest.h:54:10: fatal error: 'limits' file not found
#include <limits>
^
1 error generated.
make[3]: *** [third-party/gmock-1.7.0/CMakeFiles/gmock_main.dir/gtest/src/gtest-all.cc.o] Error 1
make[2]: *** [third-party/gmock-1.7.0/CMakeFiles/gmock_main.dir/all] Error 2
make[1]: *** [all] Error 2
make: *** [all] Error 2
XCode is installed correctly
xcode-select --install
xcode-select: error: command line tools are already installed, use "Software Update" to install updates
and the header files are present.
What could be the issue? Is it an environment variable that I need to set?
This is over a year old, and the osquery build system has improved. Doing a 'make dep && make' will get all dependencies and build osqueryi/osqueryd. It takes a good long while, but it's pretty solid.
/usr/local/bin/clang is not a standard location for the system clang installation.
It looks like you have a corrupt installation there maybe. Try the one in /usr/bin and see if you have better luck.
Or download a fresh build here: http://llvm.org/releases/download.html
I can confirm the 3.9 build is an "unzip and go" and it works on Sierra.

make mongo-cxx-driver cannot find includes

I've been trying to compile the mongo-cxx-driver for C++11 on OSX 10.10, but I have some trouble with it.
Both libbson and mongo-c-driver were built and installed successfully, the libraries to to /usr/local/lib, and the headers to /usr/local/include/libbson-1.0 and /usr/local/include/libmongoc-1.0 respectively.
I ran cmake successfully from the mongo-cxx-driver/build directory, and this was the entire output to the shell:
~/code/cpp/mongo-cxx-driver/build ((r3.0.1)) $> cmake -DLIBBSON_DIR=/usr/local/include/libbson-1.0 -DLIBMONGOC_DIR=/usr/local/include/libmongoc-1.0 -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local ..
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/user/code/cpp/mongo-cxx-driver
when I run make form the mongo-cxx-driver directory, I get the following error:
...
[ 4%] Building CXX object src/bsoncxx/CMakeFiles/bsoncxx.dir/array/view.cpp.o
/Users/user/code/cpp/mongo-cxx-driver/src/bsoncxx/array/view.cpp:21:10: fatal error: 'bson.h' file not
found
#include <bson.h>
^
1 error generated.
Apparently the compiler fails to find those includes ... but why? Isn't that what LIBBSON_DIR and LIBMONGOC_DIR were set for in the cmake command line?
Edited:
I built both the C driver and libbson from their git sources, using cmake; make; sudo make install.
Today I started the mongo-cxx-driver from scratch, to document all problems along the way.
cmake in mongo-cxx-driver/build generated following output:
~/code/cpp/mongo-cxx-driver/build (master) $> cmake ..
-- The CXX compiler identification is AppleClang 7.3.0.7030031
-- 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
-- No build type selected, default is Release
-- The C compiler identification is AppleClang 7.3.0.7030031
-- 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
CMake Error at cmake/FindLibBSON.cmake:38 (message):
Don't know how to find libbson; please set LIBBSON_DIR to the prefix
directory with which libbson was configured.
Call Stack (most recent call first):
src/bsoncxx/CMakeLists.txt:67 (find_package)
-- Configuring incomplete, errors occurred!
See also "/Users/user/code/cpp/mongo-cxx-driver/build/CMakeFiles/CMakeOutput.log".
The log from cmake in /mongo-cxx-driver/build/CMakeFiles/CMakeOutput.log contains (only showing the C++11 relevant lines for breverity):
The system is: Darwin - 15.6.0 - x86_64
Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" succeeded.
Compiler: /Library/Developer/CommandLineTools/usr/bin/c++
Build flags:
Id flags:
The output was:
0
Compilation of the CXX compiler identification source "CMakeCXXCompilerId.cpp" produced "a.out"
The CXX compiler identification is AppleClang, found in "/Users/user/code/cpp/mongo-cxx-driver/build/CMakeFiles/3.6.2/CompilerIdCXX/a.out"
Determining if the CXX compiler works passed with the following output:
Change Dir: /Users/user/code/cpp/mongo-cxx-driver/build/CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/make" "cmTC_1ae1a/fast"
/Library/Developer/CommandLineTools/usr/bin/make -f CMakeFiles/cmTC_1ae1a.dir/build.make CMakeFiles/cmTC_1ae1a.dir/build
Building CXX object CMakeFiles/cmTC_1ae1a.dir/testCXXCompiler.cxx.o
/Library/Developer/CommandLineTools/usr/bin/c++ -o CMakeFiles/cmTC_1ae1a.dir/testCXXCompiler.cxx.o -c /Users/user/code/cpp/mongo-cxx-driver/build/CMakeFiles/CMakeTmp/testCXXCompiler.cxx
Linking CXX executable cmTC_1ae1a
/usr/local/Cellar/cmake/3.6.2/bin/cmake -E cmake_link_script CMakeFiles/cmTC_1ae1a.dir/link.txt --verbose=1
/Library/Developer/CommandLineTools/usr/bin/c++ -Wl,-search_paths_first -Wl,-headerpad_max_install_names CMakeFiles/cmTC_1ae1a.dir/testCXXCompiler.cxx.o -o cmTC_1ae1a
Detecting CXX compiler ABI info compiled with the following output:
Change Dir: /Users/user/code/cpp/mongo-cxx-driver/build/CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/make" "cmTC_34702/fast"
/Library/Developer/CommandLineTools/usr/bin/make -f CMakeFiles/cmTC_34702.dir/build.make CMakeFiles/cmTC_34702.dir/build
Building CXX object CMakeFiles/cmTC_34702.dir/CMakeCXXCompilerABI.cpp.o
/Library/Developer/CommandLineTools/usr/bin/c++ -o CMakeFiles/cmTC_34702.dir/CMakeCXXCompilerABI.cpp.o -c /usr/local/Cellar/cmake/3.6.2/share/cmake/Modules/CMakeCXXCompilerABI.cpp
Linking CXX executable cmTC_34702
/usr/local/Cellar/cmake/3.6.2/bin/cmake -E cmake_link_script CMakeFiles/cmTC_34702.dir/link.txt --verbose=1
/Library/Developer/CommandLineTools/usr/bin/c++ -Wl,-search_paths_first -Wl,-headerpad_max_install_names -v -Wl,-v CMakeFiles/cmTC_34702.dir/CMakeCXXCompilerABI.cpp.o -o cmTC_34702
Apple LLVM version 7.3.0 (clang-703.0.31)
Target: x86_64-apple-darwin15.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
"/Library/Developer/CommandLineTools/usr/bin/ld" -demangle -dynamic -arch x86_64 -macosx_version_min 10.11.0 -o cmTC_34702 -search_paths_first -headerpad_max_install_names -v CMakeFiles/cmTC_34702.dir/CMakeCXXCompilerABI.cpp.o -lc++ -lSystem /Library/Developer/CommandLineTools/usr/bin/../lib/clang/7.3.0/lib/darwin/libclang_rt.osx.a
#(#)PROGRAM:ld PROJECT:ld64-264.3.102
configured to support archs: armv6 armv7 armv7s arm64 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em (tvOS)
Library search paths:
/usr/lib
/usr/local/lib
Framework search paths:
/Library/Frameworks/
/System/Library/Frameworks/
Parsed CXX implicit link information from above output:
link line regex: [^( *|.*[/\])(ld|([^/\]+-)?ld|collect2)[^/\]*( |$)]
ignore line: [Change Dir: /Users/user/code/cpp/mongo-cxx-driver/build/CMakeFiles/CMakeTmp]
ignore line: []
ignore line: [Run Build Command:"/usr/bin/make" "cmTC_34702/fast"]
ignore line: [/Library/Developer/CommandLineTools/usr/bin/make -f CMakeFiles/cmTC_34702.dir/build.make CMakeFiles/cmTC_34702.dir/build]
ignore line: [Building CXX object CMakeFiles/cmTC_34702.dir/CMakeCXXCompilerABI.cpp.o]
ignore line: [/Library/Developer/CommandLineTools/usr/bin/c++ -o CMakeFiles/cmTC_34702.dir/CMakeCXXCompilerABI.cpp.o -c /usr/local/Cellar/cmake/3.6.2/share/cmake/Modules/CMakeCXXCompilerABI.cpp]
ignore line: [Linking CXX executable cmTC_34702]
ignore line: [/usr/local/Cellar/cmake/3.6.2/bin/cmake -E cmake_link_script CMakeFiles/cmTC_34702.dir/link.txt --verbose=1]
ignore line: [/Library/Developer/CommandLineTools/usr/bin/c++ -Wl,-search_paths_first -Wl,-headerpad_max_install_names -v -Wl,-v CMakeFiles/cmTC_34702.dir/CMakeCXXCompilerABI.cpp.o -o cmTC_34702 ]
ignore line: [Apple LLVM version 7.3.0 (clang-703.0.31)]
ignore line: [Target: x86_64-apple-darwin15.6.0]
ignore line: [Thread model: posix]
ignore line: [InstalledDir: /Library/Developer/CommandLineTools/usr/bin]
link line: [ "/Library/Developer/CommandLineTools/usr/bin/ld" -demangle -dynamic -arch x86_64 -macosx_version_min 10.11.0 -o cmTC_34702 -search_paths_first -headerpad_max_install_names -v CMakeFiles/cmTC_34702.dir/CMakeCXXCompilerABI.cpp.o -lc++ -lSystem /Library/Developer/CommandLineTools/usr/bin/../lib/clang/7.3.0/lib/darwin/libclang_rt.osx.a]
arg [/Library/Developer/CommandLineTools/usr/bin/ld] ==> ignore
arg [-demangle] ==> ignore
arg [-dynamic] ==> ignore
arg [-arch] ==> ignore
arg [x86_64] ==> ignore
arg [-macosx_version_min] ==> ignore
arg [10.11.0] ==> ignore
arg [-o] ==> ignore
arg [cmTC_34702] ==> ignore
arg [-search_paths_first] ==> ignore
arg [-headerpad_max_install_names] ==> ignore
arg [-v] ==> ignore
arg [CMakeFiles/cmTC_34702.dir/CMakeCXXCompilerABI.cpp.o] ==> ignore
arg [-lc++] ==> lib [c++]
arg [-lSystem] ==> lib [System]
arg [/Library/Developer/CommandLineTools/usr/bin/../lib/clang/7.3.0/lib/darwin/libclang_rt.osx.a] ==> lib [/Library/Developer/CommandLineTools/usr/bin/../lib/clang/7.3.0/lib/darwin/libclang_rt.osx.a]
Library search paths: [;/usr/lib;/usr/local/lib]
Framework search paths: [;/Library/Frameworks/;/System/Library/Frameworks/]
remove lib [System]
collapse lib [/Library/Developer/CommandLineTools/usr/bin/../lib/clang/7.3.0/lib/darwin/libclang_rt.osx.a] ==> [/Library/Developer/CommandLineTools/usr/lib/clang/7.3.0/lib/darwin/libclang_rt.osx.a]
collapse library dir [/usr/lib] ==> [/usr/lib]
collapse library dir [/usr/local/lib] ==> [/usr/local/lib]
collapse framework dir [/Library/Frameworks/] ==> [/Library/Frameworks]
collapse framework dir [/System/Library/Frameworks/] ==> [/System/Library/Frameworks]
implicit libs: [c++;/Library/Developer/CommandLineTools/usr/lib/clang/7.3.0/lib/darwin/libclang_rt.osx.a]
implicit dirs: [/usr/lib;/usr/local/lib]
implicit fwks: [/Library/Frameworks;/System/Library/Frameworks]
Detecting CXX [-std=c++11] compiler features compiled with the following output:
Change Dir: /Users/user/code/cpp/mongo-cxx-driver/build/CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/make" "cmTC_a8d63/fast"
/Library/Developer/CommandLineTools/usr/bin/make -f CMakeFiles/cmTC_a8d63.dir/build.make CMakeFiles/cmTC_a8d63.dir/build
Building CXX object CMakeFiles/cmTC_a8d63.dir/feature_tests.cxx.o
/Library/Developer/CommandLineTools/usr/bin/c++ -std=c++11 -o CMakeFiles/cmTC_a8d63.dir/feature_tests.cxx.o -c /Users/user/code/cpp/mongo-cxx-driver/build/CMakeFiles/feature_tests.cxx
Linking CXX executable cmTC_a8d63
/usr/local/Cellar/cmake/3.6.2/bin/cmake -E cmake_link_script CMakeFiles/cmTC_a8d63.dir/link.txt --verbose=1
/Library/Developer/CommandLineTools/usr/bin/c++ -Wl,-search_paths_first -Wl,-headerpad_max_install_names CMakeFiles/cmTC_a8d63.dir/feature_tests.cxx.o -o cmTC_a8d63
Feature record: CXX_FEATURE:0cxx_aggregate_default_initializers
...
Feature record: CXX_FEATURE:1cxx_variadic_templates
Detecting C [-std=c11] compiler features compiled with the following output:
Change Dir: /Users/user/code/cpp/mongo-cxx-driver/build/CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/make" "cmTC_9a269/fast"
/Library/Developer/CommandLineTools/usr/bin/make -f CMakeFiles/cmTC_9a269.dir/build.make CMakeFiles/cmTC_9a269.dir/build
Building C object CMakeFiles/cmTC_9a269.dir/feature_tests.c.o
/Library/Developer/CommandLineTools/usr/bin/cc -std=c11 -o CMakeFiles/cmTC_9a269.dir/feature_tests.c.o -c /Users/user/code/cpp/mongo-cxx-driver/build/CMakeFiles/feature_tests.c
Linking C executable cmTC_9a269
/usr/local/Cellar/cmake/3.6.2/bin/cmake -E cmake_link_script CMakeFiles/cmTC_9a269.dir/link.txt --verbose=1
/Library/Developer/CommandLineTools/usr/bin/cc -Wl,-search_paths_first -Wl,-headerpad_max_install_names CMakeFiles/cmTC_9a269.dir/feature_tests.c.o -o cmTC_9a269
Feature record: C_FEATURE:1c_function_prototypes
Feature record: C_FEATURE:1c_restrict
Feature record: C_FEATURE:1c_static_assert
Feature record: C_FEATURE:1c_variadic_macros
(if other lines are needed, I'd ba happy to send them).
ls /usr/local/lib/pkgconfig showed the following:
lcms2.pc libbson-1.0.pc libmongoc-1.0.pc libmongoc-ssl-1.0.pc libtiff-4.pc mysqlclient.pc
Found the problem. #acm asked to show the output of pkg-config --cflags --libs libmongoc-1.0 libbson-1.0, which I tried to do:
~/code/cpp/mongo-cxx-driver/build (master) $> pkg-config --cflags --libs libmongoc-1.0 libbson-1.0
-bash: pkg-config: command not found
Apparently pkg-config was not installed. A quick installation through homebrew later, I ran the same line and got:
~/code/cpp/mongo-cxx-driver/build (master) $> pkg-config --cflags --libs libmongoc-1.0 libbson-1.0
-I/usr/local/include/libmongoc-1.0 -I/usr/local/include/libbson-1.0 -L/usr/local/lib -lmongoc-1.0 -lbson-1.0
After that cmake ran just fine, and make also.
Thanks for your help :-)