Solved

How to Import dll

Posted on 2009-07-02
1
1,591 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

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…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

708 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

16 Experts available now in Live!

Get 1:1 Help Now