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

x
?
Solved

can't call dll functions

Posted on 1998-07-09
8
Medium Priority
?
230 Views
Last Modified: 2010-04-01
I'm pretty new to both hooks and dll's.. i've written a standard win32 dll which compiles fine.. i'm using the __cdeclspec(dllexport) void ExampleFunction(int blah) in a header file..
the implimentation of course would look like:
void ExampleFunction(int blah) {
....

the dll compiles perfectly fine..

i've included my dll's header file in the calling MFC application, but when i try to call ExampleFunction, i get the error:

MonitorXDlg.obj : error LNK2001: unresolved external symbol "void __cdecl SetDll(struct HWND__ *)" (?SetDll@@YAXPAUHWND__@@@Z)

all i did was copy the dll and the header file to the main program's dir so it could find it.. where did i go wrong?
0
Comment
Question by:rabbitears
[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
  • 5
  • 2
8 Comments
 

Accepted Solution

by:
kashif063098 earned 200 total points
ID: 1167525
use
__declspec(dllexport) void ExampleFunction(int blah)
{
function body
}

need more assistance let me know

0
 
LVL 22

Expert Comment

by:nietod
ID: 1167526
Since it is compiling fine and getting a linker error the declaration is not the problem.

It sounds like the .lib file for the DLL containing the exported function needs to be linked into the EXE or DLL that is trying toi use the DLL
0
 
LVL 22

Expert Comment

by:nietod
ID: 1167527
To link int the .lib file, add it to the project, just right-click on the project and select "add files to project".  Then set the file type to "library" (.lib) and select the .lib file for the DLL you are trying to use.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Expert Comment

by:kashif063098
ID: 1167528
Its seems like You did not include yourDllName.lib file in to the project setting.Here you need to check if you have done that correctly

Click on Build menu option then Settings then click on Linker Tab
 on the right type your yourDll.lib path in Object/Library Modules make sure to include your file path for exmaple

c:\users\kashif\myDll.lib


kashif
 
0
 
LVL 22

Expert Comment

by:nietod
ID: 1167529
Great idea--I wish I had thought of that.
0
 
LVL 22

Expert Comment

by:nietod
ID: 1167530
So what was the problem?
0
 

Author Comment

by:rabbitears
ID: 1167531
it was the lib that was giving me trouble.. i included it in my project and it worked.. curious though, where did it include the lib?  it's not in the project settings that i can see.. it's not in the file view.. where?
0
 
LVL 22

Expert Comment

by:nietod
ID: 1167532
It is in the project workspace.  It will appear under the project (or sub-project) for the EXE without an extension.  

I would just like to point out that was the solution I suggested.  In the future, you should make sure that you are grading the answer from the export that gives the correct answer.  Since kashik's answer was not correct , you should have rejected it.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

661 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