0

Following a previous question I posted and received an excellent answer to -

Dynamically load a function from a DLL

I have further problems. I must be going wrong somewhere but I am pretty sure I got the .DLL built correctly and I'm sure from the previously answered question it is linked to the .DLL correctly.

I have the following:

http://pastie.org/3113984

I have also used DependencyWalker to make sure the .DLL is exporting the function that I am attempting to call and it is showing it is being exported correctly.

PS: I am receiving the error when compiling the program that calls the .dll with the "was not declared in this scope" error for the exported function.

Thank you for your time and help!

1
  • When asking a question, please post the minimum amount of code required to demonstrate the problem, along with any relevant compiler errors. Commented Jan 2, 2012 at 19:27

2 Answers 2

7

The answer is clear. Instead of writing:

int a = Isworking(); 

You should write:

int a = funci(); 

Isworking is the name of the function in the DLL, but the function pointer that you imported is called funci.

Sign up to request clarification or add additional context in comments.

2 Comments

Could well be this really is the issue.
This and your comment was the problem David, a stupid mistake by me. I don't know why it was downvoted either. +1 from me
0

Maybe not directly addressing your problem (since your using win32) but the Poco library provides a very clean and easy to use way to load symbols from shared libraries (DLLs included). So you could try using Poco instead.

See: http://pocoproject.org/slides/120-SharedLibraries.pdf

6 Comments

What is so hard about calling LoadLibrary and GetProcAddress? It's not rocket science!
Thanks for the suggestion, I was actually looking into how the equivalent of .dll's, so's? run in Unix as well, Poco is a sort of cross platform .dll linker? can the same function and method call a .dll and .so respectively?
I agree with David. It's not hard and it certainly has a better learning effect to use those functions directly.
@DavidHeffernan: It might be if you're loading rocket32.dll.
@DavidHeffernan: I never said that its rocket science. I personally just prefer Poco since its more convinient for me. Poco code is even portable (which win32 is definitly not).
|