Created
August 7, 2012 02:23
-
-
Save meng-hui/3280790 to your computer and use it in GitHub Desktop.
Configuring a Visual Studio Project to create a managed no entry c++ dll wrapper of an unmanaged c++ dll
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// defining what symbols to export or import | |
// more details here http://www.codeguru.com/cpp/cpp/cpp_managed/interop/article.php/c6867/Consuming-Unmanaged-C-Class-Libraries-from-NET-Clients.htm | |
#ifdef UNMANAGED_EXPORTS | |
#define UNMANAGED_API __declspec(dllexport) | |
#else | |
#define UNMANAGED_API __declspec(dllimport) | |
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
New Project > Visual C++ > CLR > Class Library | |
Configuration Properties > C/C++ > Command Line > add /Zl | |
Configuration Properties > Linker > Input > add mscoree.lib msvcrt.lib msvcmrt.lib to Additional Dependencies | |
Configuration Properties > Linker > Input > add __DllMainCRTStartup@12 to Force Symbol References | |
Configuration Properties > Linker > Command Line > add /noentry | |
Add reference to this project for projects that require this dll. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When building for x64 target, the instruction:
Configuration Properties > Linker > Input > add __DllMainCRTStartup@12 to Force Symbol References
must be replaced by:
Configuration Properties > Linker > Input > add _DllMainCRTStartup to Force Symbol References
NOTE: _DllMainCRTStartup with only 1 underscore and without the training @12