Solved

How to Import dll

Posted on 2009-07-02
1
1,592 Views
Last Modified: 2013-11-26

Hello,
When i was using c# i was simply adding refence to a dll and start to use its public functions.
Now i am using c++ 2008  (all of my code is native c++). And i want to use a dll that i have created in my project.  Can you show me how to import dll in native c++ ?
How should i prepare my dll l so that it will be able to export its functions ?

Thank you.
 
0
Comment
Question by:parabellum
1 Comment
 
LVL 8

Accepted Solution

by:
dericstone earned 500 total points
ID: 24765663
In your code that you want to export functions or objects define them with this syntax
  __declspec(dllexport) void myfunc(/* insert your arguments */);
and in your code that you want to use the exported functions or objects, you need to declare them with this syntax
  __declspec(dllimport) void myfunc(/* insert your arguments */);
Usually you put all the declarations in a header (.h) file like myfuncs.h and then in your code where you use the exported functions, include the header file like this
  #include "myfuncs.h"
C++ also includes a linking step unlike C# where the calling .exe or .dll needs to be linked with the .lib file from the exported dll. So make sure you include this, otherwise you will get an "unresolved external" error.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Concerto provides fully managed cloud services and the expertise to provide an easy and reliable route to the cloud. Our best-in-class solutions help you address the toughest IT challenges, find new efficiencies and deliver the best application expe…

930 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now