简体   繁体   中英

C++ and DLL was not declared in this scope

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!

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 .

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM