I have a application and several plugins in DLL files. The plugins use symbols from the application via a export library. The application links in several static libraries a
What I tried out to solve this was this:
void afunction( int )
.afunction
.afunction
symbol.How? Since the linker can be told to export functions using the __declspec(dllexport)
directive, a dll needs no more than declare a to-be-exported symbol thusly.
The lib has a header "afunction.h" and an accompanying cpp file containing the function body:
// stat/afunction.h
namespace static_lib { void afunction(int); }
// stat/afunction.cpp
#include "afunction.h"
namespace static_lib { void afunction(int){ } }
The dll has an include file "indirect.h", containing the declaration of the function to be exported. The dll has a link-time dependency to the static lib. (Linker options: Input/Additional Dependencies: "static_library.lib")
// dll/indirect.h
namespace static_lib {
__declspec( dllexport ) void afunction(int);
}
The executable has only the indirectly included file:
#include
int main() { static_lib::afunction(1); }
And guess what? It compiles, links and even runs!