Friday, July 31, 2009

Building a "Hello World" DLL using the Microsoft C++ compiler.?

Can anyone help me write a "Hello World" DLL console app. using MS C++ compiler ? Without using the Visual Studio .NET IDE.


(It seems to be next to impossible getting a simple answer for that question, by trawling the web)

Building a "Hello World" DLL using the Microsoft C++ compiler.?
Here are the steps:


1. Open the Visual Studio 2005 Command Prompt window. Note: The Visual Studio 2005 Command Prompt automatically sets up the correct path to the Visual C++ compiler and any needed libraries, so it is used instead of the regular Command Prompt window.





2. At the command prompt, type notepad and press Enter. In notepad select the File menu and save the file as hello.cpp and press Enter.





In Notepad, type the following lines:





#include %26lt;iostream%26gt;





using namespace std;





int _tmain()


{


cout%26lt;%26lt; "Hello World!! " %26lt;%26lt; endl;





return EXIT_SUCCESS;


}





3. On the File menu, click Save. You have created a Visual C++ source file. On the File menu, click Exit to close Notepad.





4. At the command line prompt, type cl /EHsc /LD hello.cpp and press Enter. The /EHsc command line option instructs the compiler to enable C++ exception handling while the /LD option sets the file output to a .DLL file.





Look in the folder where the hello.cpp file was saved and you will find a hello.dll file.
Reply:I'm not sure what you mean. Do you want a console app, a DLL, or a console app that calls a DLL?





A console app is simple. A DLL is a bit more work. I've never called a DLL from a console app, so I would have to check if that's even possible. Let us know what it is that you're trying to do.
Reply:just open a project ... write :


void main()


{


printf("Hello world");


}





and you are done


No comments:

Post a Comment