I am developing a project in C++11, and am not the biggest expert in distrubition, compiling, packaging, etc. I use
Moreover, I want the program to work on both OS X and Windows. Therefore, my IDEs include:
I am having troubles with the Windows build. As of now, I am not able to copy the executables to another computer, since the DLL-files are not included. If I copy all the DLL-files that I receive errors from, it simply says the program was not able to run. I have read a bit about static library linking, but am unsure whether this is what I need.
My CMakeLists.txt looks like this:
set(libsources file1.cpp file2.cpp)
set(exec1sources file3.cpp file4.cpp)
set(exec2sources file5.cpp file6.cpp)
# some qt commands
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ..)
add_library(sharedlib ${libsources])
generate_export_header(sharedlib)
add_executable(exec1 ${exec1sources})
add_executable(exec2 ${exec2sources})
target_link_libraries(sharedlib Qt5::A Qt5::B)
target_link_libraries(exec1 Qt5::A Qt5::B sharedlib)
target_link_libraries(exec2 Qt5::A Qt5::C sharedlib)
install(TARGETS exec1 RUNTIME DESTINATION bin)
install(TARGETS exec2 RUNTIME DESTINATION bin)
As you can probably see, I want 2 executables, that each use some functionality from a shared library. And I want them working stand-alone.
I am likely not the first in the world to have this issue, but I was unable to find a similar thread on StackOverflow.
Have you tried windeployqt ? It will automatically copy all dependencies for you application. You can find it in the bin-folder of your Qt-Kit
For Mac, there is a similar tool, called macdeployqt .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.