Using a DLL in the IDE - is it possible ?

I’ve written a few C functions which I can access on the Windows, Linux and Mac platforms by compiling it into a dll, so or dylib file.

I’m using mingw to create the dll on windows but I think that’s besides the point.

I’m testing this on windows right now. I’m using a declare to initialise the function inside the dll, it’s placed in libs/printdll.dll which is fine once it’s built and I run the program in a directory which contains a ‘libs’ sub directory which contains the dll in question. It works fine once compiled.

Is there any way for me to use the compiled C functions when I click the big green ‘Run’ button in the Xojo IDE ?

Maybe there’s some kind of directive to allow me to specify that when the program’s running in the IDE mode it should load the DLL from somewhere else - a specific location ? If so, I’d like to know how to do this, everything I’ve tried has failed and I can’t find any way to do this.

For example in windows I can use something like this :

#if TargetWin32
Declare Function printdll Lib “libs/printdll.dll” () as Integer
#endif

Does anyone have any idea how I can do this so I can test the program as I write it without having to continuously build it each time I make a change ?

Maybe there’s an option like this :

#if InsideIDE
Declare Function printdll Lib “O:\c\dlltest\libs\printdll.dll” () as Integer
#endif

I’ve played around with the filename and I can’t seem to get it to find the DLL when I click the Run button at all, it only works when the app is compiled and then executed separately.

For example I’ve tried the following :

“O:/c/dlltest/libs/printdll.dll”
“O:\c\dlltest\libs\printdll.dll”

Both fail even with hard coded paths when I run the program inside the IDE saying it can’t find the DLL which is strange as the DLL is right where it should be.

This is a console app, I’m not sure if that makes any difference.

Does anyone have any idea what I’m doing wrong or is what I’m trying to do not possible ?

[quote=121325:@Neil McAliece]
#if InsideIDE
Declare Function printdll Lib “O:\c\dlltest\libs\printdll.dll” () as Integer
#endif[/quote]
Try the DebugBuild constant. So it would be:

#if DebugBuild Declare Function printdll Lib "O:\\c\\dlltest\\libs\\printdll.dll" () as Integer #endif

I have a function that is called early in the life of the app that copies the DLL to the location the app wants to see it (as in Debug special folders are created and the debug app is built there). Using Soft Declare allows the app to find the app at calltime and not runtime, so the function just needs to exist before the DLL gets called, which should be no problem. (Use #DebugBuild of course.)

Thanks guys, this got it working.

I did the following on a Windows test :

#if DebugBuild
Declare Function printdll Lib “O:\c\dll\basic\printdll.dll” () as Integer
#elseif TargetWin32
Declare Function printdll Lib “libs\printdll.dll” () as Integer
#endif
.
.
.
I noticed that #DebugBuild and #TargetWin32 are both set (kind of expected that) if you’re running the Windows IDE hence the use of #elseif in this case.

I’ll take a look into the soft declares method too, I should probably be using that anyway.

http://www.xojo.com/blog/en/2014/08/the-libs-folder.php