Getting an 'CXX compiler: /usr/local/bin/g++-7 -- broken' with macOS brew install - c++

Trying to use g++-7 with cmake, however, when compiling my g++-7 install is trying to use anaconda's make
base) annaleigh-MacBook-Pro:build annaleigh$ brew reinstall gcc#7
==> Reinstalling gcc#7
==> Downloading https://homebrew.bintray.com/bottles/gcc#7-7.5.0_1.mojave.bottle.tar.gz
Already downloaded: /Users/annaleigh/Library/Caches/Homebrew/downloads/41befd66234ffc03ad4373f51e4c4f87348872de396ac16a79f0a111966ad857--gcc#7-7.5.0_1.mojave.bottle.tar.gz
==> Pouring gcc#7-7.5.0_1.mojave.bottle.tar.gz
🍺 /usr/local/Cellar/gcc#7/7.5.0_1: 1,402 files, 254.7MB
(base) annaleigh-MacBook-Pro:build annaleigh$ cmake ../source -DCMAKE_CXX_COMPILER=/usr/local/bin/g++-7
-- The CXX compiler identification is GNU 7.5.0
-- 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/bin/g++-7
-- Check for working CXX compiler: /usr/local/bin/g++-7 -- broken
CMake Error at /usr/local/Cellar/cmake/3.16.4/share/cmake/Modules/CMakeTestCXXCompiler.cmake:53 (message):
The C++ compiler
"/usr/local/bin/g++-7"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: /Users/annaleigh/Documents/GitHub/delabel/tutorial/build/CMakeFiles/CMakeTmp
Run Build Command(s):/usr/bin/make cmTC_5cede/fast && /Library/Developer/CommandLineTools/usr/bin/make -f CMakeFiles/cmTC_5cede.dir/build.make CMakeFiles/cmTC_5cede.dir/build
Building CXX object CMakeFiles/cmTC_5cede.dir/testCXXCompiler.cxx.o
/usr/local/bin/g++-7 -march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -stdlib=libc++ -fvisibility-inlines-hidden -std=c++14 -fmessage-length=0 -o CMakeFiles/cmTC_5cede.dir/testCXXCompiler.cxx.o -c /Users/annaleigh/Documents/GitHub/delabel/tutorial/build/CMakeFiles/CMakeTmp/testCXXCompiler.cxx
g++-7: error: unrecognized command line option '-stdlib=libc++'
make[1]: *** [CMakeFiles/cmTC_5cede.dir/testCXXCompiler.cxx.o] Error 1
make: *** [cmTC_5cede/fast] Error 2
I've installed g++7 with brew brew reinstall gcc#7
How can I get my g++7 to use the correct make?

Related

CMake error when trying to install Multinest

I've been trying to install Multinest on my laptop (MacBook Air M1) following this guide:https://johannesbuchner.github.io/PyMultiNest/install.html#prerequisites-for-building-the-libraries
However, when running the cmake .. I'm left with the following error message:
-- The CXX compiler identification is unknown
-- Detecting Fortran compiler ABI info
-- Detecting Fortran compiler ABI info - failed
-- Check for working Fortran compiler: /opt/anaconda3/bin/x86_64-apple-darwin13.4.0-gfortran
-- Check for working Fortran compiler: /opt/anaconda3/bin/x86_64-apple-darwin13.4.0-gfortran - broken
CMake Error at /opt/homebrew/Cellar/cmake/3.25.0/share/cmake/Modules/CMakeTestFortranCompiler.cmake:62 (message):
The Fortran compiler
"/opt/anaconda3/bin/x86_64-apple-darwin13.4.0-gfortran"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: /Users/myname/Documents/MultiNest/build/CMakeFiles/CMakeScratch/TryCompile-JLpNaW
Run Build Command(s):/usr/bin/make -f Makefile cmTC_38eb9/fast && /Applications/Xcode.app/Contents/Developer/usr/bin/make -f CMakeFiles/cmTC_38eb9.dir/build.make CMakeFiles/cmTC_38eb9.dir/build
Building Fortran object CMakeFiles/cmTC_38eb9.dir/testFortranCompiler.f.o
/opt/anaconda3/bin/x86_64-apple-darwin13.4.0-gfortran -march=nocona -mtune=core2 -ftree-vectorize -fPIC -fstack-protector -O2 -pipe -c /Users/myname/Documents/MultiNest/build/CMakeFiles/CMakeScratch/TryCompile-JLpNaW/testFortranCompiler.f -o CMakeFiles/cmTC_38eb9.dir/testFortranCompiler.f.o
Linking Fortran executable cmTC_38eb9
/opt/homebrew/Cellar/cmake/3.25.0/bin/cmake -E cmake_link_script CMakeFiles/cmTC_38eb9.dir/link.txt --verbose=1
/opt/anaconda3/bin/x86_64-apple-darwin13.4.0-gfortran -march=nocona -mtune=core2 -ftree-vectorize -fPIC -fstack-protector -O2 -pipe CMakeFiles/cmTC_38eb9.dir/testFortranCompiler.f.o -o cmTC_38eb9
ld: library not found for -lSystem
collect2: error: ld returned 1 exit status
make[1]: *** [cmTC_38eb9] Error 1
make: *** [cmTC_38eb9/fast] Error 2
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:2 (project)
CMake Error at CMakeLists.txt:2 (project):
The CMAKE_CXX_COMPILER:
/sudo
is not a full path to an existing compiler tool.
Tell CMake where to find the compiler by setting either the environment
variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path
to the compiler, or to the compiler name if it is in the PATH.
I've tried to export the C/C++ compiler paths but it hasn't helped.

CMake on linux givs error cc1plus: error: too many filenames given

EDIT 1: verbose make output now included in error, see below as well
I'm currently trying to compile a C++ project with CMake from a different laptop than the one I had been working on before. When I run make after the CMake configuration is done (withouth errors) I get the following error:
$ make
/usr/bin/cmake -S/home/luc/coding/hiwi/peltier-control-panel -B/home/luc/coding/hiwi/peltier-control-panel/build --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start /home/luc/coding/hiwi/peltier-control-panel/build/CMakeFiles /home/luc/coding/hiwi/peltier-control-panel/build//CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory '/home/luc/coding/hiwi/peltier-control-panel/build'
make -f CMakeFiles/sio_client.dir/build.make CMakeFiles/sio_client.dir/depend
make[2]: Entering directory '/home/luc/coding/hiwi/peltier-control-panel/build'
cd /home/luc/coding/hiwi/peltier-control-panel/build && /usr/bin/cmake -E
cmake_depends "Unix Makefiles" /home/luc/coding/hiwi/peltier-control-panel
/home/luc/coding/hiwi/peltier-control-panel /home/luc/coding/hiwi/peltier-control-
panel/build /home/luc/coding/hiwi/peltier-control-panel/build /home/luc/coding/hiwi/peltier-control-
panel/build/CMakeFiles/sio_client.dir/DependInfo.cmake --color=
make[2]: Leaving directory '/home/luc/coding/hiwi/peltier-control-panel/build'
make -f CMakeFiles/sio_client.dir/build.make CMakeFiles/sio_client.dir/build
make[2]: Entering directory '/home/luc/coding/hiwi/peltier-control-panel/build'
[ 6%] Building CXX object CMakeFiles/sio_client.dir/lib/socket.io-client-cpp/src/sio_client.cpp.o
/usr/bin/c++ -DSIMULATION -I/home/luc/coding/hiwi/peltier-control-panel/include
-I/home/luc/coding/hiwi/peltier-control-panel/src
-I/home/luc/coding/hiwi/peltier-control-panel/lib
-I/home/luc/coding/hiwi/peltier-control-panel/lib/websocketpp
-I/home/luc/coding/hiwi/peltier-control-panel/lib/rapidjson/include
-I/home/luc/coding/hiwi/peltier-control-panel/lib/WiringPi/wiringPi
-Wall -Wextra -o3 -std=gnu++11 -MD -MT
CMakeFiles/sio_client.dir/lib/socket.io-client-cpp/src/sio_client.cpp.o
-MF CMakeFiles/sio_client.dir/lib/socket.io-client-cpp/src/sio_client.cpp.o.d
-o CMakeFiles/sio_client.dir/lib/socket.io-client-cpp/src/sio_client.cpp.o
-c /home/luc/coding/hiwi/peltier-control-panel/lib/socket.io-client-cpp/src/sio_client.cpp
cc1plus: error: too many filenames given; type ‘cc1plus --help’ for usage
cc1plus: fatal error: CMakeFiles/sio_client.dir/lib/socket.io-client-cpp/src/sio_client.cpp.d: No such file or directory
compilation terminated.
make[2]: *** [CMakeFiles/sio_client.dir/build.make:79: CMakeFiles/sio_client.dir/lib/socket.io-client-cpp/src/sio_client.cpp.o] Error 1
make[2]: Leaving directory '/home/luc/coding/hiwi/peltier-control-panel/build'
make[1]: *** [CMakeFiles/Makefile2:175: CMakeFiles/sio_client.dir/all] Error 2
make[1]: Leaving directory '/home/luc/coding/hiwi/peltier-control-panel/build'
make: *** [Makefile:94: all] Error 2
On the old laptop the code compiles without a problem (Ubuntu 16), so it must be independent of the code. On this laptop I have Arch installed, which means I have much newer versions of all of the installed compilers and programs. Boost libraries are requried in my project but it seems to fail even before it gets to the point where it starts compiling and linking that so I don't think it's really relevant. I'm including it only for the sake of completeness.
Ubuntu 16:
CMake: 3.15.4
Make: 4.1
g++/gcc: 5.4.0
libboost 1.68.0
Arch:
CMake: 3.21.2
Make: 4.2
g++/gcc: 11.1.0
libboost 1.76.0
I'm not sure this is the reason however, since the only issue I found on the internet that is similar to this has to do with the mingw installation path on Windows, which is certainly not the issue I seem to be facing.
CMake output:
cmake .. -DSIMULATION=TRUE
-- The C compiler identification is GNU 11.1.0
-- The CXX compiler identification is GNU 11.1.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
Using simulated temperature data...
-- Found Boost: /usr/lib64/cmake/Boost-1.76.0/BoostConfig.cmake (found version "1.76.0") found components: system
-- Linking against boost shared libraries
-- location of boost libraries
-- Boost::system
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Check if compiler accepts -pthread
-- Check if compiler accepts -pthread - yes
-- Found Threads: TRUE
-- Linking SIMULATION
-- Configuring done
-- Generating done
-- Build files have been written to: /home/luc/coding/hiwi/peltier-control-panel/build
An interesting fact I have observed is that on the Arch laptop the checks for working C/CXX compilers are skipped whereas they aren't for the Ubuntu laptop. However, I am able to compile programs with gcc/g++ so they must in principle be working.
I've never encountered this problem before, and it's not something that a quick search seems to be able to resolve. I'm hoping someone may have had some experience with this at some point and could point me in the right direction. Any help at all would be greatly appreciated, however.
EDIT
#Stephen Newell thank you very much for your comment, I wasn't aware of this trick! (I'm still somewhat new to using make/cmake.)
Okay so I think I've narrowed it down to this: when running the same CMakeLists.txt on both systems they produce varying compilation commands:
Ubuntu 16:
/usr/bin/c++ -DSIMULATION
-I/home/luc/coding/hiwi/peltier-heater/include
-I/home/luc/coding/hiwi/peltier-heater/src
-I/home/luc/coding/hiwi/peltier-heater/lib -I/home/luc/coding/hiwi/peltier-heater/lib/websocketpp
-I/home/luc/coding/hiwi/peltier-heater/lib/rapidjson/include
-Wall -Wextra -o3 -std=gnu++11
-o CMakeFiles/PIDController.dir/src/PIDController.cpp.o
-c /home/luc/coding/hiwi/peltier-heater/src/PIDController.cpp
Arch:
/usr/bin/c++ -DSIMULATION
-I/home/luc/coding/hiwi/peltier-heater/include
-I/home/luc/coding/hiwi/peltier-heater/src
-I/home/luc/coding/hiwi/peltier-heater/lib
-I/home/luc/coding/hiwi/peltier-heater/lib/websocketpp
-I/home/luc/coding/hiwi/peltier-heater/lib/rapidjson/include
-Wall -Wextra -o3 -std=gnu++11
-MT CMakeFiles/PIDController.dir/src/PIDController.cpp.o
-MF CMakeFiles/PIDController.dir/src/PIDController.cpp.o.d
-o CMakeFiles/PIDController.dir/src/PIDController.cpp.o
-c /home/luc/coding/hiwi/peltier-heater/src/PIDController.cpp
Notice the -MF and -MT flags. If I pass the Ubuntu command in the build folder on my Arch system it compiles without error (though obviously it only does that specific step)
Is there any reason in particular why these flags are being generated on one system but not on the other? Can (and should) I turn them off? Or should I maybe change some configuration in my CMakeLists.txt to correct for this?

CMake can't find stdc++11 after Xcode 10 update

I have a CMake project using SFML which was working fine but after updating to Xcode 10, all of the compiler files that CMake looks for can't be found.
clang: warning: libstdc++ is deprecated; move to libc++
I'm not sure how to move to the different lib source.
I've tried using set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=libc++") to use the flag.
It also tells me: Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -- broken. I can run the g++/c++ commands fine in the terminal. I assume they are being looked for in the same spot.
CMake file I'm trying to compile with. Its the SFML one:
SFML CMake
Full Error Message:
-- 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++ -- broken
CMake Error at /Applications/CMake.app/Contents/share/cmake-3.7/Modules/CMakeTestCXXCompiler.cmake:44 (message):
The C++ compiler
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: /Users/DSchana/Documents/Libraries/SFML/build/CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/make" "cmTC_af3d5/fast"
/Applications/Xcode.app/Contents/Developer/usr/bin/make -f
CMakeFiles/cmTC_af3d5.dir/build.make CMakeFiles/cmTC_af3d5.dir/build
Building CXX object CMakeFiles/cmTC_af3d5.dir/testCXXCompiler.cxx.o
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
-arch x86_64 -isysroot
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.07.sdk
-mmacosx-version-min=10.7 -o
CMakeFiles/cmTC_af3d5.dir/testCXXCompiler.cxx.o -c
/Users/DSchana/Documents/Libraries/SFML/build/CMakeFiles/CMakeTmp/testCXXCompiler.cxx
warning: include path for stdlibc++ headers not found; pass '-std=libc++'
on the command line to use the libc++ standard library instead
[-Wstdlibcxx-not-found]
1 warning generated.
Linking CXX executable cmTC_af3d5
/Applications/CMake.app/Contents/bin/cmake -E cmake_link_script
CMakeFiles/cmTC_af3d5.dir/link.txt --verbose=1
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
-arch x86_64 -isysroot
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.07.sdk
-mmacosx-version-min=10.7 -Wl,-search_paths_first
-Wl,-headerpad_max_install_names
CMakeFiles/cmTC_af3d5.dir/testCXXCompiler.cxx.o -o cmTC_af3d5
clang: warning: libstdc++ is deprecated; move to libc++ with a minimum
deployment target of OS X 10.9 [-Wdeprecated]
ld: library not found for -lstdc++
clang: error: linker command failed with exit code 1 (use -v to see
invocation)
make[1]: *** [cmTC_af3d5] Error 1
make: *** [cmTC_af3d5/fast] Error 2
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:47 (project)
-- Configuring incomplete, errors occurred!
Ok. Turns out I just needed to add set(CMAKE_CXX_FLAGS "-stdlib=libc++") to my CMakeLists.txt

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 :-)