Cannot determine link language for target

Hi everyone,
i try to compile a target and as a result i get the error message “Cannot determine link language for target”.

my code looks as following:
set(CMAKE_C_COMPILER gcc)
set(CMAKE_C_LINKER_FLAGS “-g -Wall -Werror”)

target_include_directories(LIB_GLAD_EXAMPLE_CBASIC PRIVATE ${LIB_GLAD_INC_PATH})
target_link_directories(LIB_GLAD_EXAMPLE_CBASIC PRIVATE ${LIB_GLAD_LIB_PATH})
target_link_libraries(LIB_GLAD_EXAMPLE_CBASIC PRIVATE ${LIB_GLAD_STATIC_LIBS})

set_target_properties(LIB_GLAD_EXAMPLE_CBASIC PROPERTIES RELEASE_OUTPUT_NAME ${LIB_GLAD_EXAMPLE_CBASIC_OUTPUT_NAME_RELEASE})
set_target_properties(LIB_GLAD_EXAMPLE_CBASIC PROPERTIES DEBUG_OUTPUT_NAME ${LIB_GLAD_EXAMPLE_CBASIC_OUTPUT_NAME_DEBUG})

add_dependencies(LIB_GLAD_EXAMPLE_CBASIC ${LIB_GLAD_DEPS})
install(
TARGETS LIB_GLAD_EXAMPLE_CBASIC
RUNTIME DESTINATION ${LIB_GLAD_EXAMPLE_CBASIC_INSTALL_PATH}
)

what am i doing wrong here ?

Hi,

you haven’t shown how you actually define the target in question (there’s no add_library() or add_executable() command in the code you posted), so it’s next to impossible to say what’s wrong. Please try providing a minimised but complete CMakeList that would reproduced the issue.

These are typically compile flags, not link flags. Do things work better if you comment this out?

I have now come to another problem with my CMakeList.txt file. I get the error

/usr/bin/ld: /home/stuv/projects/programming/cpp/bsAllrounder/out/Debug/lib/glad/lib/libglad.a(glad.c.o): undefined reference to symbol ‘dlclose@@GLIBC_2.2.5
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/…/…/…/x86_64-linux-gnu/libdl.so: error adding symbols: DSO missing from command line

here is the complete output of make

To help you get a better understanding what i’m trying to do i post my cmake files:

lib_glad.cmake
lib_glad_example_cbasic.cmake

I think you need to link to ${CMAKE_DL_LIBS} for that symbol to be satisfied.