问题
I have a main application wich can be controlled by dynamically loaded plugins (.dll on win - .so on linux). Now i want to create a lot of these plugins where just on function is implemented different.
Lets say i have the following files in my Project:
- plugin.h
- plugin.cpp
- i001.cpp
i001.cpp contains one implementation of the of the "run" function of my plugin class. Now this Project compiles to "plugin.dll".
What i want to achieve is something like this:
- plugin.h + plugin.cpp + i001.cpp --> i001.dll
- plugin.h + plugin.cpp + i002.cpp --> i002.dll
- plugin.h + plugin.cpp + i003.cpp --> i003.dll
- plugin.h + plugin.cpp + i004.cpp --> i004.dll
Is there an easy way to get these outputs out of one project? I'm using Qt-Creator on both Windows and Linux.
回答1:
There are two ways to solve the problem.
You should use subprojects. Extract your common source-files into separate subproject as static library. More info here
You may create .pri file:
SOURCES += plugin.cpp HEADERS += plugin.h
and include it in all .pro files:
include(deployment.pri)
来源:https://stackoverflow.com/questions/34432748/multiple-shared-libraries-from-one-project-with-common-source-files