Juceaide failing to build on Linux

I’m new to JUCE and I want to play with it to see if it’s suitable for my work, but I’ve hit an issue right away. Juceaide is failing to build during cmake setup if I specify clang-18 as the compiler. I’ve stripped my set up down to a minimum that reproduces it and put it up on gitlab.

I get this problem on MacOS and Linux.

I’m running cmake as…

cmake -S . -B build -DCMAKE_CXX_COMPILER=clang-18 -DCMAKE_C_COMPILER=clang-18

My minimal CMakeLists.txt is

cmake_minimum_required(VERSION 3.15 FATAL_ERROR)

include(CPM.txt)

set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_SCAN_FOR_MODULES OFF)
set (CMAKE_CXX_FLAGS_INIT "-Wall -std=c++23 -stdlib=libc++ -Wno-deprecated-declarations")
add_link_options(-lc++ -lm)

# set the project name and version
project(HelloWorld VERSION 1.0)

# add juce, commenting out this line and it will work
CPMAddPackage("gh:juce-framework/JUCE#8.0.0")

# add our c++23 test program
add_executable(hello
  "hello.cpp"
)

I get copious errors along the lines of…

check_atomic_cDtk0I0RpHz3y4Og.cpp:(.text._ZNKSt13__atomic_baseIxE12is_lock_freeEv[_ZNKSt13__atomic_baseIxE12is_lock_freeEv]+0x19):
    undefined reference to `__atomic_is_lock_free'

It appears that the juceaide build is being passed the compiler, it is not being passed the compiler flags. Is there any way I can force juceaide to just use the default system compiler; have it use my flags; or just have it built separately and installed somehow before I invoke cmake? This is a complete blocker for me.

Does it work if you set clang++-18 as the CXX compiler instead?

1 Like

That fixed it on Linux thank you.

Annoyingly installing llvm on macos doesn’t create a clang++-18 symlink, which is why I just set it as clang-18. I’ll see what I can bodge to get it working on macos.

Thank you very much for help! Very appreciated.

It’s more annoying on MacOS. Even setting CXX as /usr/local/opt/llvm/bin/clang++ (which is LLVM installs on macos via brew) it won’t link as it needs the argument in -L/usr/local/opt/llvm/lib/c++ to link with the object files emited by clang-18. See the clang docs on linking to libc++

I can’t see a way to force this into the linker args for juceaide (LD_LIBRARY_PATH is ignored). Is there a way of building juceaide externally, installing it somewhere and telling JUCE’s cmake to go find it there and not build it?

Figured it, I can force extra flags to be passed to juceaide cmake invocation via the extra_compiler_flag_arguments variable, if I set that before I load JUCE into cmake it now links.

set(extra_compiler_flag_arguments "-DCMAKE_EXE_LINKER_FLAGS=-L/usr/local/opt/llvm/lib/c++")
1 Like