[C-API]: relocation against `jl_gc_have_ pending_finalizers' in read-only section `.text'

Hi, I have a simple C++ executable using the julia C-API:

CMakeLists.txt

cmake_minimum_required(VERSION 3.12)
project(MyProject VERSION 0.0.0 LANGUAGES CXX)

add_executable(hello_world ${CMAKE_SOURCE_DIR}/main.cpp)
target_link_libraries(hello_world PRIVATE
    ${jluna}
    "/home/clem/Applications/julia/lib/libjulia.so"
)

target_include_directories(hello_world PRIVATE
    ${CMAKE_SOURCE_DIR}
    ${JULIA_INCLUDE_DIR}
)

Where /home/clem/Applications/julia/lib/libjulia.so is the correct location of my julia shared library, freshly downloaded just now.

main.cpp

#include <julia.h>

int main()
{
    jl_init();

	auto* mutex = new jl_mutex_t();
    jl_mutex_init(mutex);
	jl_mutex_lock(mutex);
	jl_mutex_unlock(mutex);
	return 0;
}

There are no other files in the project.

When compiling using

cmake ..

It throws this linker error:

clem@birdnest:~/Desktop/MyProject/build$ cmake ..  -DCMAKE_CXX_COMPILER=g++-11
-- Configuring done
-- Generating done
-- Build files have been written to: /home/clem/Desktop/MyProject/build
clem@birdnest:~/Desktop/MyProject/build$ make
Scanning dependencies of target hello_world
[ 50%] Building CXX object CMakeFiles/hello_world.dir/main.cpp.o
[100%] Linking CXX executable hello_world
/usr/bin/ld: CMakeFiles/hello_world.dir/main.cpp.o: warning: relocation against `jl_gc_have_pending_finalizers' in read-only section `.text'
/usr/bin/ld: CMakeFiles/hello_world.dir/main.cpp.o: in function `jl_lock_frame_push':
main.cpp:(.text+0x153): undefined reference to `small_arraylist_grow'
/usr/bin/ld: CMakeFiles/hello_world.dir/main.cpp.o: in function `jl_mutex_unlock':
main.cpp:(.text+0x34e): undefined reference to `jl_gc_have_pending_finalizers'
/usr/bin/ld: main.cpp:(.text+0x370): undefined reference to `jl_gc_run_pending_finalizers'
/usr/bin/ld: warning: creating DT_TEXTREL in a PIE
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/hello_world.dir/build.make:105: hello_world] Error 1
make[1]: *** [CMakeFiles/Makefile2:95: CMakeFiles/hello_world.dir/all] Error 2
make: *** [Makefile:103: all] Error 2

All other features of the julia C-API work fine, it is only the jl_mutex related things that throw this error.
It is compiler independent, both clang-12, g++10 and g++11 throw the same linker error.

Any ideas? Do I have to link against an additional target somehow? Again, all other functionality is available, so it is definitely linking to a correct and working libjulia.so.

To positively verify it is only the mutex, the following main.cpp:

#include <julia.h>

int main()
{
   jl_eval_string("println(\"hello julia\"");
   return 0;
}

Compiles with

clem@birdnest:~/Desktop/MyProject/build$ cmake .. -DCMAKE_CXX_COMPILER=g++-11
-- Configuring done
-- Generating done
-- Build files have been written to: /home/clem/Desktop/MyProject/build
clem@birdnest:~/Desktop/MyProject/build$ make
Scanning dependencies of target hello_world
[ 50%] Building CXX object CMakeFiles/hello_world.dir/main.cpp.o
[100%] Linking CXX executable hello_world
[100%] Built target hello_world

and prints hello julia. No other files or arguments where changed, except the content of main.cpp