Solved

can't call dll functions

Posted on 1998-07-09
8
218 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
 

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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
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 viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

705 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now