can't call dll functions

Posted on 1998-07-09
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?
Question by:rabbitears
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

Accepted Solution

kashif063098 earned 50 total points
ID: 1167525
__declspec(dllexport) void ExampleFunction(int blah)
function body

need more assistance let me know

LVL 22

Expert Comment

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
LVL 22

Expert Comment

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.
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Expert Comment

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


LVL 22

Expert Comment

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

Expert Comment

ID: 1167530
So what was the problem?

Author Comment

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?
LVL 22

Expert Comment

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.

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

635 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