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!

Community
  • 1
  • 1
  • When asking a question, please post the minimum amount of code required to demonstrate the problem, along with any relevant compiler errors. – James McNellis Jan 02 '12 at 19:27

2 Answers2

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.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
TonySalimi
  • 8,257
  • 4
  • 33
  • 62
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

Sebastian Hoffmann
  • 11,127
  • 7
  • 49
  • 77
  • 2
    What is so hard about calling `LoadLibrary` and `GetProcAddress`? It's not rocket science! – David Heffernan Jan 02 '12 at 19:23
  • 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? –  Jan 02 '12 at 19:25
  • I agree with David. It's not hard and it certainly has a better learning effect to use those functions directly. – Niklas B. Jan 02 '12 at 19:25
  • @DavidHeffernan: It might be if you're loading `rocket32.dll`. – James McNellis Jan 02 '12 at 19:25
  • @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). – Sebastian Hoffmann Jan 02 '12 at 19:27
  • @James: Who'd use a Windows for that? ;) – Niklas B. Jan 02 '12 at 19:27