Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

can't call dll functions

Posted on 1998-07-09
8
Medium Priority
?
234 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 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
Industry Leaders: 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

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

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.

Question has a verified solution.

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

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

877 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