I have recently installed macos catalina with Xcode 11.1 and updated cmake, clang and llvm
sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install
$ cmake --version
cmake version 3.15.4
$ which cmake
/usr/local/bin/cmake
$ clang --version
Apple clang version 11.0.0 (clang-1100.0.33.8)
Target: x86_64-apple-darwin19.0.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
$ which clang
/usr/bin/clang
The CMakeLists.txt looks as bellow:
cmake_minimum_required(VERSION 3.14)
project("ROZZETA" VERSION 0.0.1 LANGUAGES C)
# Allow us to import cmake scripts from ./cmake
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS OFF)
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}")
# Compiler flags
set(CMAKE_C_COMPILER /usr/bin/clang CACHE PATH "")
find_package(GMP REQUIRED)
add_executable(Rozzeta main.c)
target_link_libraries(Rozzeta gmp libgmp libgmp.a)
cmake detected gmp successfully :
/usr/local/bin/cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=c++ -G "CodeBlocks - Unix Makefiles" /<path to project>
-- The C compiler identification is AppleClang 11.0.0.11000033
-- Check for working C compiler: /usr/bin/clang
-- Check for working C compiler: /usr/bin/clang -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Using toolchain file: .
-- Found GMP: /usr/local/include/gmp.h and /usr/local/lib/libgmp.a
-- Configuring done
-- Generating done
build failed :
cmake --build .
Scanning dependencies of target Rozzeta
[ 50%] Building C object CMakeFiles/Rozzeta.dir/main.c.o
/Users/gajaka/CLionProjects/Rozzeta/main.c:4:10: fatal error: 'gmp.h' file not found
#include <gmp.h>
^~~~~~~
1 error generated.
make[2]: *** [CMakeFiles/Rozzeta.dir/main.c.o] Error 1
make[1]: *** [CMakeFiles/Rozzeta.dir/all] Error 2
make: *** [all] Error 2
I have compiled manually with:
cc main.c -lgmp
Anyone can help me with this ? Many thanks in advance
MacOS 10.15 (Catalina) will continue to run on your Mac for however long you choose to keep it running on your Mac, and as well as your Mac continuing to physically operate and function.
macOS Catilina is more stable than it was in late 2019 when it first arrived. That said, you should make sure that you pay attention to your situation and to early reports before you install this update. Many Apple Stores remain closed, so if you need support for a problem, it will not be as easy as going into a store.
CMake is used to control the software compilation process using simple platform and compiler independent configuration files, and generate native makefiles and workspaces that can be used in the compiler environment of your choice.
It was very frustrating for me! I am personally using CLion from jetbrains, while tried to build old codes written in C/C++, it's giving me error because MacOS 10.15, Catalina removed the C headers pkg used to be in Mojave. So, found another way around and tried.
If you have installed XCode 11.1, then open the terminal and run the following command:
xcode-select --install
then,
sudo ln -s /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/* /usr/local/include/
Now, you are good to go. Try to build using cmake.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With