简体   繁体   中英

C++ Plug-in Version Checking via Function Export

I have two DLLs, Core and Extension . Extension implicitly links Core (using Core.lib). Extension is intended to be a plug-in (explicitly linked) into an executable which also implicitly links Core .

Core declares a function which is exported in Core.dll ( extern "C" __declspec(dllexport) int GetCoreVersion() ), which I would also like to export in Extension.dll.

The intended purpose is to compare versions--I want to be able to ensure that the plug-in (Extension) was linked against the same version of Core.dll as the executable. This check would be performed in the executable, as it explicitly links Extension.dll (via LoadLibrary and GetProcAddress ). Is there a better way?

I added the following to Extension, which causes the GetCoreVersion symbol to be exported:

#pragma comment(linker, "/export:_GetCoreVersion");

The executable is now able to find the function (via GetProcAddress("GetCoreVersion") ).

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM