I am utilizing the wxWidgets library in my projects to develop GUI applications. While I am able to successfully link against the library and run my application within my IDE environment, issues arise when attempting to execute the final .exe file independently. The attempt to run the executable will result in numerous “DLL not found” errors, which is anticipated since the program cannot find the necessary dependencies when trying to run the program. Therefore, I wanted to know if there exists a method to direct CMake to automatically identify the required DLLs and copy them to the binary directory alongside the executable, thus eliminating the need for a manual copy operation.
Here is my current code for linking against wxWidgets:
set(wxWidgets_USE_STATIC ON)
set(wxWidgets_EXCLUDE_COMMON_LIBRARIES TRUE)
set(wxWidgets_USE_UNICODE ON)
find_package(wxWidgets REQUIRED gl core base)
include(${wxWidgets_USE_FILE})
target_link_libraries(${EXECUTABLE_NAME} PRIVATE ${wxWidgets_LIBRARIES})
PS: despite the fact that I have the setting wxWidgets_USE_STATIC
set to ON
, the library just refuses to link statically and always defaults to dynamic linking. Any idea why this is?