today I started a new wxWidgets project, I use wxWidgets by submodules. The project is based on CMake, you can find it here: https://gitlab.imanuel.dev/DerKnerd/netcup-dns-tool
When I try to built the project I get a weird linking error that only happens with the most recent master branch, the previous versions (3.1.x) I used in other projects build fine. This is the error I get:
Code: Select all
/usr/bin/ld: libs/wxWidgets/lib/libwx_gtk3u_core-3.2.a(imagpng.cpp.o): undefined reference to symbol 'png_set_read_fn@@PNG16_0'
/usr/bin/ld: /usr/lib/libpng16.so.16: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make[3]: *** [CMakeFiles/netcup_dns_tool.dir/build.make:170: netcup_dns_tool] Error 1
make[2]: *** [CMakeFiles/Makefile2:420: CMakeFiles/netcup_dns_tool.dir/all] Error 2
make[1]: *** [CMakeFiles/Makefile2:427: CMakeFiles/netcup_dns_tool.dir/rule] Error 2
make: *** [Makefile:169: netcup_dns_tool] Error 2
Code: Select all
set(wxUSE_STL ON)
set(wxUSE_OPENGL OFF)
set(wxBUILD_SHARED OFF)
set(wxUSE_ZLIB builtin)
set(wxUSE_EXPAT builtin)
set(wxUSE_LIBJPEG builtin)
set(wxUSE_LIBPNG builtin)
set(wxUSE_LIBTIFF builtin)
add_subdirectory(libs/wxWidgets)
What confuses me, the CMakeLists.txt specifies to use the builtin version of libpng, but the linker tries to link against the system one. Can someone point me in the right direction?
Greetings
DerKnerd
Code: Select all
cmake_minimum_required(VERSION 3.24)
project(netcup_dns_tool)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
include(building/cmake/ucm.cmake)
include(conan.cmake)
ucm_set_runtime(STATIC)
if (WIN32 OR MINGW)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static")
add_compile_definitions(__WXMSW__ _UNICODE)
set(BUILD_SHARED_LIBS false)
set(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_SYSTEM_PROCESSOR x86_64)
set(CMAKE_WIN32_EXECUTABLE 1)
set(CMAKE_CXX_COMPILER_WORKS TRUE)
set(CMAKE_C_COMPILER_WORKS TRUE)
endif ()
set(wxUSE_STL ON)
set(wxUSE_OPENGL OFF)
set(wxBUILD_SHARED OFF)
set(wxUSE_ZLIB builtin)
set(wxUSE_EXPAT builtin)
set(wxUSE_LIBJPEG builtin)
set(wxUSE_LIBPNG builtin)
set(wxUSE_LIBTIFF builtin)
add_subdirectory(libs/wxWidgets)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR})
list(APPEND CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR})
conan_add_remote(NAME conan.imanuel.dev
URL https://conan.imanuel.dev/artifactory/api/conan/conan-virtual)
conan_cmake_configure(
REQUIRES
cpp-httplib/0.11.3
nlohmann_json/3.10.5
GENERATORS cmake_find_package
)
if (MINGW)
conan_cmake_install(PATH_OR_REFERENCE .
BUILD missing
REMOTE conan.imanuel.dev
PROFILE ${CMAKE_SOURCE_DIR}/building/conan/linux_to_win64_conan)
else ()
conan_cmake_autodetect(settings)
conan_cmake_install(PATH_OR_REFERENCE .
BUILD missing
REMOTE conan.imanuel.dev
SETTINGS ${settings})
endif ()
find_package(httplib)
find_package(nlohmann_json)
add_executable(netcup_dns_tool main.cpp netcup/client.cpp netcup/client.h windows/LoginDialog.cpp windows/LoginDialog.h windows/LoginDialog.cpp windows/LoginDialog.h NetcupApp.cpp NetcupApp.h wxDefaultHeader.h)
target_link_libraries(netcup_dns_tool PRIVATE wx::base wx::core httplib::httplib nlohmann_json::nlohmann_json)