Solved

How to Import dll

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

803 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