Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Hello World DLL using Microsoft C++ compiler

Reply
Thread Tools

Hello World DLL using Microsoft C++ compiler

 
 
cybose
Guest
Posts: n/a
 
      10-19-2006
Can someone help me write a HelloWorld dll using Microsoft's C++
compiler. It was straightforward doing it on Cygwin/g++, but it seems
to be an entirely different story on the MS C++ ?

In the case of using g++ ...

1.HelloWorld.h
~~~~~~~~~~~~
extern "C"
void printHelloWorld();

2.HelloWorld.cpp
~~~~~~~~~~~~~
#include <iostream>
extern "C"
void printHelloWorld() {
std::cout << "Hello World" << std::endl;
}

3.TestHW.cpp
~~~~~~~~~~~
#include "HelloWorld.h"
int main() {
printHelloWorld();
}

Once I compile and link 2. into a dll, and link that alongwith 3,
everything works as expected.

How do I mimic this using Microsoft C++ ?

Thanks

 
Reply With Quote
 
 
 
 
mlimber
Guest
Posts: n/a
 
      10-19-2006
cybose wrote:
> Can someone help me write a HelloWorld dll using Microsoft's C++
> compiler. It was straightforward doing it on Cygwin/g++, but it seems
> to be an entirely different story on the MS C++ ?
>
> In the case of using g++ ...
>
> 1.HelloWorld.h
> ~~~~~~~~~~~~
> extern "C"
> void printHelloWorld();
>
> 2.HelloWorld.cpp
> ~~~~~~~~~~~~~
> #include <iostream>
> extern "C"
> void printHelloWorld() {
> std::cout << "Hello World" << std::endl;
> }
>
> 3.TestHW.cpp
> ~~~~~~~~~~~
> #include "HelloWorld.h"
> int main() {
> printHelloWorld();
> }
>
> Once I compile and link 2. into a dll, and link that alongwith 3,
> everything works as expected.
>
> How do I mimic this using Microsoft C++ ?


This is a platform-specific question and is off-topic here. For what is
on-topic and for some suggestions on other newsgroups you could try,
see this FAQ:

http://parashift.com/c++-faq-lite/ho...t.html#faq-5.9

Cheers! --M

 
Reply With Quote
 
 
 
 
Moonlit
Guest
Posts: n/a
 
      10-19-2006


Hi,

I do this from the top of my head so don't take it to litterally.

Why not put it in one program. Anyway if you want it in a DLL just create a
DLL with the 'create project' wizard.
After that you have to create the program itself. Create a project with the
'create project' wizard and select executable (don't know the exact name).
In your case you would probably go for a console app.

Now in the properties of the project goto 'link' . Additional dependecies
and add the import library created in the DLL project (this is NOT the DLL
itself but a file called <your dll project>.lib. Also make sure to either
add the whole path to it. Copy the dll to the debug or release directory of
you project.

Now you would be able to run your project (assuming it has the code you gave
below).

Regards, Ron AF Greve

http://moonlit.xs4all.nl

"cybose" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> Can someone help me write a HelloWorld dll using Microsoft's C++
> compiler. It was straightforward doing it on Cygwin/g++, but it seems
> to be an entirely different story on the MS C++ ?
>
> In the case of using g++ ...
>
> 1.HelloWorld.h
> ~~~~~~~~~~~~
> extern "C"
> void printHelloWorld();
>
> 2.HelloWorld.cpp
> ~~~~~~~~~~~~~
> #include <iostream>
> extern "C"
> void printHelloWorld() {
> std::cout << "Hello World" << std::endl;
> }
>
> 3.TestHW.cpp
> ~~~~~~~~~~~
> #include "HelloWorld.h"
> int main() {
> printHelloWorld();
> }
>
> Once I compile and link 2. into a dll, and link that alongwith 3,
> everything works as expected.
>
> How do I mimic this using Microsoft C++ ?
>
> Thanks
>



 
Reply With Quote
 
Alf P. Steinbach
Guest
Posts: n/a
 
      10-19-2006
* Moonlit:
> [off-topic]


Read the FAQ about topicality before posting. This group is about the
C++ language. Don't post off-topic articles.

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
regular expression to parse {"hello", "hello world","1hello-2*hello"} Roy Java 6 01-07-2008 08:06 PM
to print in the reverse order, ("Hello World" -> "World Hello") vijay C Programming 8 04-26-2005 02:11 AM
The world's shortest 'Hello World!' program: a proposal Larry Perl Misc 27 01-25-2005 07:53 PM
microsoft.public.dotnet.faqs,microsoft.public.dotnet.framework,microsoft.public.dotnet.framework.windowsforms,microsoft.public.dotnet.general,microsoft.public.dotnet.languages.vb Charles A. Lackman ASP .Net 1 12-08-2004 07:08 PM
msvcrt.dll, msvcirt.dll, msvcrt20.dll and msvcrt40.dll, explanation please! Snoopy NZ Computing 16 08-25-2003 12:34 PM



Advertisments