Reputation: 2849
How can we create a .dll file from an existing .cpp file? I have my HelloWorld.cpp and HelloWorld.h file already created.
Please help. Thank you.
Upvotes: 0
Views: 2812
Reputation: 78
It depends, what compiler (and version) are you using? I'm guessing MSVC++, so Dynamic Libraries are normally a built-in template (probably named 'Win32 DLL') you can use. (There is also 'Class Library', which is similar.)
Your header file signatures should probably also contain __declspec(dllexport)
to make sure the compiler makes them visible.
Change the configuration type to 'Dynamic Library' (under Properties->Configuration Properties->General) and build.
Remember: DLL files are just normal plain old executables... They can contain a Main(), but they don't need to, just a collection of classes is also perfectly fine... You can often even simply rename .exe to .dll, though every compiler has its own little things...
A useful link might be: http://msdn.microsoft.com/en-us/library/ms235636%28v=vs.80%29.aspx
Upvotes: 1
Reputation: 28991
That's platform/compiler dependent. On Windows, with Microsoft Visual C++, you would say:
cl /LD HelloWorld.cpp
Upvotes: 1