Skip to content

Instantly share code, notes, and snippets.

@meng-hui
Created August 7, 2012 02:23
Show Gist options
  • Save meng-hui/3280790 to your computer and use it in GitHub Desktop.
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
// 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
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.
@roalz
Copy link

roalz commented Nov 13, 2015

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment