Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to Import dll

Posted on 2009-07-02
1
Medium Priority
?
1,598 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 8

Accepted Solution

by:
dericstone earned 2000 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

The Orion Papers

Are you interested in becoming an AWS Certified Solutions Architect?

Discover a new interactive way of training for the exam.

Question has a verified solution.

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

Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

722 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