I am trying to build very simple application with Dear ImGui.
I copied some Dear ImGui files to my source directory and I compiled with CMake as follows.
cmake_minimum_required(VERSION 3.12)
project(imgui)
find_package(GLEW REQUIRED)
find_package(glfw3 REQUIRED)
find_package(OpenGL REQUIRED)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
add_executable(min
min.cpp
${CMAKE_SOURCE_DIR}/imgui.cpp
${CMAKE_SOURCE_DIR}/imgui_demo.cpp
${CMAKE_SOURCE_DIR}/imgui_draw.cpp
${CMAKE_SOURCE_DIR}/imgui_tables.cpp
${CMAKE_SOURCE_DIR}/imgui_widgets.cpp
${CMAKE_SOURCE_DIR}/imgui_impl_opengl3.cpp
${CMAKE_SOURCE_DIR}/imgui_impl_glfw.cpp
)
target_link_libraries(min
glfw
GLEW
GL
#${CMAKE_DL_LIBS} <If this command is used, build successfully!>
)
But I got following error.
-- Configuring done
-- Generating done
-- Build files have been written to: /home/harumo/program/cpp/imgui/minimal/build
[ 11%] Linking CXX executable min
/usr/bin/ld: CMakeFiles/min.dir/imgui_impl_opengl3.cpp.o: undefined reference to symbol 'dlclose@@GLIBC_2.2.5'
/usr/bin/ld: /lib/x86_64-linux-gnu/libdl.so.2: error adding symbols: DSO missing from command line
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [CMakeFiles/min.dir/build.make:189: min] Error 1
make[1]: *** [CMakeFiles/Makefile2:76: CMakeFiles/min.dir/all] Error 2
make: *** [Makefile:84: all] Error 2
If you have any other information you need, please let me know.
Thanks in advance!