Could not load...

Im trying to load a .dll on windows to use in an application im trying on xojo. If the error is:
Could not load InitTryThis from Plugin.dll.

Does it mean that it was able to find the library but the function couldnt be loaded but the library was found? I have placed the .dll next to the xojo workspace and tried hard pathing it to a c:\ location but neither lets me access the .dll. Now, I suspect its only exprting c++ but I am wondering if theres a way to tell where one should place the .dll during a debug “run” and Im assuming it need to be at the root application level for a build unless otherwise specified in the load path


There may be dependencies.
Did you check with Dependency Walker?

Hi Christian, thank you - I have not, but this runs on other apps built in VS with a c++ sample. So I think its that its not exprting C. SO I am really most interested in where the .dll should be placed for; running in debug and then running once built.

Put the dll next to your exectuable on windows systems.

I looked in dependancy walker and now I see all C exports, but still cant load the functions - I get the “Function not found” error. Where does one put the library for debug running? Do I need a full Windows license for this to work?

@Derk Jochems - what executable? I am just debugging so far. Do you know where it should go for debugging? I tried just a folder in 'c:\xojolibs\lib.ddl" and hard code loading to that path but the same error comes up

you probably dont have a dir next to the Xojo IDE executable called “Debug Plugins”
create that and drop your dll in there
that should then load IF its a dll implementing a Xojo plugin and all the required Xojo plugin entry points

you do have to restart the IDE to make it load

Thanks Norm, that didnt work. Its not an IDE plugin, its an external 3rd party .dll that does some data manipulation. The function are all experted as C in dep walker. I have hard pathed the Declares;

Declare Function Initdll Lib "c:\\XojoLibs\\Plugin.dll" () As Integer

since the initdll function returns a 1 or 0.

result = Initdll()

I get the “Function not found” rte, and deeper msg, “Could not load initdll from c:\XojoLibs\Plugin.dll” which seems like Im doing it right…

ah didn’t realize you’re trying to load it manually

double check exported names match case etc
probably the path to it as well

quite honestly you might put the dll next to the exe when you debug and use

soft Declare Function Initdll Lib "Plugin.dll" () As Integer  

soft because the runtime wont try to load the dll until this code is somehow run
and putting it next to the exe to eliminate the possibility that loading it frmo that path is whats faling
dlls next to the exe should work no matter what

Well, I tried the soft decalre and putting it next to the Xojo exe and that didnt work. I tried also a break on the return call that soft declares it, and then pasting a copy of the dll into the debug application folder at run time (since it only exisits at that time) and that also failed with the same errors. Im thinking theres something wrong with the exports in the .dll. Is there any such “dummy” dll out there that I could load in this manner to know the process is correct?

Or were you referring to another exe Norm?

Yeah putting it right next to the exe you’re about to debug

If the dll is there by the time you get to the soft declare & its not loading I’d think there’s some other issue

I’m just not sure what assuming things are all properly declared entry points for a DLL
they use the right declspec ?
__declspec(dllexport) rest of the function decl ???

No one’s asked at this point, but is the DLL written by you to be turned into a Xojo Plugin, or is it a normal DLL that has an API that allows it to be used in VC++ apps?

CopyFileStep add it to pre-build settings in the app parent folder on windows systems

Ooh and, .net dlls won’t work with xojo. You need native dlls (such as c, c++)

Hi Tim - thank you for that. It is the latter; a normal .dll that allows it to be used in C/C++ apps. The “sdk” suggests using visual studio, which obviously I do not want to do. I did open it in the dependancy walker and can see C and C++ exports.

@Derek - thank you also. This is a “normal” .dll. I am wondering now does it need to be AciveX/COM compliant? Is thart whats wrong?

it shouldnt but you can only load C exports
C++ ones require runtime support that wont be present

Thanks Norm. I am not sure why its not working then. I can see the C exports in DepWalker. I can also see the C++ exports - that wouldnt cause a problem would it?

Dunno to be honest
But if you open debug view or something and run your app I dont know if that would show dll loading errors
I’m sure there has to be one of the many tools available that would show you if there were

Can you share the DLL file?

DLL function names are case sensitive; maybe it’s supposed to be InitDll, InitDLL, etc.

@Derek - I tried creating the build CopyFileStep and placed it under the windows build setting per the docs, added my .dll and then set the “applies to” to both “Both” and “Debug” and I get an error, “The script ‘CopyDll’ cant copy files to the destination in a pre build step. The destination does nto exist yet. This step will not be executed.” Wierd, re reading as I must have something wrong…also now getting an update and second try wont let me move the CopyFileStep from Contents to BuildSettings. arghh.

@Andrew - thank you for the offer but it has some unprotected IP in it. I am copying the calls from the export list in the header file and have compared the cases to the DepWalker exports - one can copy the name right outta there and paste into xojo. So Im sure its not a case issue.