|
-
May 11th, 2010, 10:52 AM
#1
Calling a C function
Hi! I have a static library where I have a function defined like:
EXPORT_API BOOL Function(...)
where I have:
#define EXPORT_API extern "C" __declspec( dllexport )
I'm writing a C++ class in which I would like to call this function. So, I linked the .lib file, and I defined:
extern "C" BOOL Function(...)
at the top of my source. Unfortunaly, I noticed it simply doesn't enter the function... and my method doesn't go on. No crash and the application is still working correctly. Any idea what I've done wrong?
Thanks guys!
-
May 11th, 2010, 11:03 AM
#2
Re: Calling a C function
I know very little about the dllexport keyword. Is this function actually in a DLL, or just in a static library?
-
May 11th, 2010, 01:09 PM
#3
Re: Calling a C function
Do you have the source code of the static-library? If yes, then just add it as another dependent project. Also make sure you set project dependency properly, AND that output generated by lib-project is actually used by your application.
Then you'll be able to debug it.
-
May 11th, 2010, 03:22 PM
#4
Re: Calling a C function
To be sincere, I have a doubt... I was told it was a static library... but I see now the project from which the library is taken produces a DLL... Then it is not a static library, right? Anyway, I placed the DLL in my directory and it still has the same behavior. I will try with the way you suggested, unfortunately, as far as I can see from the messageboxes I placed, the function is simply not called. Thanks for your advice!
-
May 11th, 2010, 09:41 PM
#5
Re: Calling a C function
Since you have source code of DLL, just include that project in the solution. Set dependencies, and make sure DLL and EXE goes in the same path. Then you can do single stepping into the DLL function. If you cannot do, there is something wrong, or something else that you aren't aware of, or not telling us.
-
May 12th, 2010, 03:23 AM
#6
Re: Calling a C function
It seems it simply doesn't go into that function and immediately stops the method which called the function of my library. I placed a breakpoint immediately before the call, and the breakpoint is hit. I place breakpoints even in the first instruction of the function and after the function and none of those is hit.
However, I noticed that, despite my solution now contains the two projects, and dependencies are correctly set, the deploy doesn't place the dll in the directory with the others I use... Maybe I'm doing something wrong...
-
May 12th, 2010, 03:55 AM
#7
Re: Calling a C function
Check if the same DLL is being loaded (in Output window)
Also make sure DLL is build with debugging information enabled.
-
May 12th, 2010, 04:04 AM
#8
Re: Calling a C function
Among the other DLLs, that one is not listed in debug mode indeed. Maybe its related to the fact that I have to deploy it manually as I get an error in deploy which can be translated as "files exhausted".
-
May 12th, 2010, 04:56 AM
#9
Re: Calling a C function
I went back to the original way I was loading the DLL, by linking against the .lib file and providing the DLL. Now it seems the debugger is telling me the DLL is loaded, but still, when it reaches the function, nothing happens at all. The first instruction is not executed...
EDIT: I made it work. Everything was fine, except the fact that there was some king of mistake in one parameter passed to the function. No compile nor runtime error was displayed. I corrected that and everything works now. Thanks!
Last edited by Luc484; May 12th, 2010 at 06:00 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|