473,396 Members | 1,666 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Hello World DLL using Microsoft C++ compiler

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

Oct 19 '06 #1
3 6252
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

Oct 19 '06 #2


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" <vt****@gmail.comwrote in message
news:11**********************@k70g2000cwa.googlegr 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

Oct 19 '06 #3
* 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?
Oct 19 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: AIM | last post by:
Error in msvc in building inheritance.obj to build hello.pyd Hello, I am trying to build the boost 1.31.0 sample extension hello.cpp. I can not compile the file inheritance.cpp because the two...
15
by: Rahul Gandhi | last post by:
Hi guys, I'm trying to run small program helloworld.cpp. But i'm not getting any output on the stdout program is #include<iostream.h> main(){ cout<<"hello world"; }
9
by: Brian | last post by:
Greetings: I am trying to compile the following code via command line. It compiles just fine in visual studio 2002 v7 so i took looked at the properties and i got the following command line...
9
by: PG | last post by:
Hi gurus, I have AIX visual age C++ compiler version 5.0.2.3. I have a simple hello world program that gives compilation errors. Any help will be appreciated. Thanks PG ***test.cpp**** ...
33
by: ankursinha | last post by:
Hi, Is it possible to write a C program that prints "Hello World" on screen without having a single semi-colon in the entire program? The extra constraint here is that u r not allowed to use...
42
by: Prashanth Badabagni | last post by:
Hi, Can any body tell me how to print "hello,world" with out using semicolon Thanks in advance .. Bye Prashanth Badabagni
26
by: Santanu Chatterjee | last post by:
Hello all, I would like to know how an OS makes a computer boot up. For that, as a start I would like to see an e_ample (read the underscore as the letter before y, as the keyboard here is...
1
by: KGarvin | last post by:
Open Visual Studio and create a new ASP.NET Web Services Project. Uncomment the test webmethod (Hello World) in the .asmx file, set as starup file, save and build project and run. Click on the...
11
by: cj | last post by:
Perhaps someone knows how to do this. When I open a new ASP.NET web service application in VS 2008, it opens with a simple Hello World web service already written. I want to see this work. ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.