Cmake Can't Find Libraries

I’m running Big Sur 11.2.3.

I’m trying to compile a built-in example, but it seems like it can’t find libraries.

I appreciate any help!

git clone https://github.com/juce-framework/JUCE

cd JUCE

cmake . -B cmake-build -DJUCE_BUILD_EXAMPLES=ON -DJUCE_BUILD_EXTRAS=ON

I get the following error from CMakeError.log.

Compiling the C compiler identification source file "CMakeCCompilerId.c" failed.
Compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc 
Build flags: 
Id flags:  

The output was:
1
ld: library not found for -lSystem
clang: error: linker command failed with exit code 1 (use -v to see invocation)


Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed.
Compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ 
Build flags: 
Id flags:  

The output was:
1
ld: library not found for -lc++
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Are you using a recent CMake? Also, have you tried running xcode-select --install?

After searching this it looks like a few people have encountered this issue on Big Sur systems with libraries other than JUCE. Unfortunately I couldn’t find any definitive solutions.

Thanks for your response.

Yes. I tried xcode-select --install, and it says xcode command line tools is already installed.

Also my cmake is 3.19.3.

Should I file an issue on Juce Github?

No, you’ll get the same audience for the issue there.

Unfortunately I’m not sure what to suggest - from what I’ve seen while researching this issue, I think it’s unlikely to be a problem with JUCE itself, as the issue seems to affect people building other projects as well. It’s more likely to be a CMake bug, or a configuration issue on your system.

There’s a thread about the issue here on the CMake forum. You could try some of the suggestions in that thread, if you haven’t already.

Interestingly, if I make a simple Hello World in cpp with cmake, it
compiles fine.

Am I missing dependencies for Juce? Where can I find list of
dependencies for MacOS?

A while ago I was able to compile the gain example in Catalina, but I
don’t remember what else I had to install.

Whatever worth, I just compiled QT 6.1 static build from source with
cmake, so it seems like cmake is working fine?

Have you definitely accepted the Xcode license? A user on this page says that running this command fixed the issue for them:

sudo xcodebuild -license accept

Yes, I can build an App in XCode, and get it notarized from Apple. XCode
is all good.

Hmm, I might have found something else.

I did not touch anything after git clone, so CMakeLists.txt should be fine.

However, the cmake complains that CMakeLists.txt doesn’t have
cmake_minimum_required() and project() commands.

However, I checked CMakeLists.txt, and it did have those lines.

I’m including the output I get after running cmake command below.

Also here’s the CMakeOutput.log.

https://pastebin.com/raw/2ZW52eKw

Thanks so much for your help!

% cmake . -B cmake-build -DJUCE_BUILD_EXAMPLES=ON -DJUCE_BUILD_EXTRAS=ON
CMake Warning (dev) in CMakeLists.txt:
No project() command is present. The top-level CMakeLists.txt file must
contain a literal, direct call to the project() command. Add a line of
code such as

 project(ProjectName)

near the top of the file, but after cmake_minimum_required().

CMake is pretending there is a “project(Project)” command on the first
line.
This warning is for project developers. Use -Wno-dev to suppress it.

– The C compiler identification is AppleClang 12.0.0.12000032
– The CXX compiler identification is AppleClang 12.0.0.12000032
– Detecting C compiler ABI info
– Detecting C compiler ABI info - done
– Check for working C compiler:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/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:
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
  • skipped
    – Detecting CXX compile features
    – Detecting CXX compile features - done
    CMake Error at CMakeLists.txt:24 (_juce_add_pips):
    Unknown CMake command “_juce_add_pips”.

CMake Warning (dev) in CMakeLists.txt:
No cmake_minimum_required command is present. A line of code such as

 cmake_minimum_required(VERSION 3.19)

should be added at the top of the file. The version specified may be
lower
if you wish to support older CMake versions for this project. For more
information run “cmake --help-policy CMP0000”.
This warning is for project developers. Use -Wno-dev to suppress it.

– Configuring incomplete, errors occurred!
See also
“/Users/jl/Desktop/Code/JUCE/cmake-build/CMakeFiles/CMakeOutput.log”.
See also
“/Users/jl/Desktop/Code/JUCE/cmake-build/CMakeFiles/CMakeError.log”.

From which folder are you invoking CMake?

JUCE only supports invoking CMake from the very top level of the project. If CMake is complaining that _juce_add_pips is missing, it could be because you’re attempting to configure one of the individual examples folders.

In your initial post it definitely looks like you’re running from the top-level directory. However, I can’t think of another plausible explanation for the errors you’re seeing, so I’d recommend double-checking that you’re configuring the top-level directory.

Yes, I am running cmake in the top JUCE folder that contains README.md
and LICENSE.md.

Basically git clone, cd JUCE, and cmake…

Again, thanks so much for taking time to troubleshoot this for me.

I’m happy to report that I finally built it!

I trashed the entire folder, git cloned from scratch, and it just worked!

I wish I tried that earlier.

1 Like