Solved

How to Import dll

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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
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…

617 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