Solved

can't call dll functions

Posted on 1998-07-09
8
224 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
  • 5
  • 2
8 Comments
 

Accepted Solution

by:
kashif063098 earned 50 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
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.

 

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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

821 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