Const DLL path - odd business?

How can I create a single Const “path” to an external library? My problem is I need a const for the “pathtolib” to the library and I use it in a lot of places, cross platform, debug and production. Is there any way to make a single instance of this? I suppose I could put all the methods into a class and do it once there but the methods belong in other classes, imho…I’d love to hear how others might be approaching this.

#If TargetMacOS
#If DebugBuild
Const pathtolib As String ="…/MyBridge.debug Libs/pluginDylib/slvsPlugin.dylib"
#Else
Const pathtolib As String ="…/MyBridgeLibs/pluginDylib/slvsPlugin.dylib"
#EndIf
#Else
#If DebugBuild
Const pathtolib As String =“DebugMyBridgeWin Libs/slvsPlugin.dll”
#Else
Const pathtolib As String =“MyBridgeWin Libs/slvsPlugin.dll”
#EndIf
#EndIf

With a CopyFiles step to put the library in the Libs/Frameworks folder, I only need one constant for the path to the library. Have you tried that?

I did - and thats great, but this is inside another helper app so another level. How did you get it into a const? Like App.ExecuatbleFile.Name + “Libs” + “dllname.dll” How do you only need one with the debug app name changing?

My helper app is packaged in Helpers on macOS, which allows Frameworks to still be in the correct location. The Windows helper includes the Libs folder. The constant is defined like this:

1 Like

Thank you Tim, thats the ticket!

Wait a sec, I am not able to get a Win version of @executable_path, so how can I change from debug to production on win or lin? Why does the path need to be a const anyway?

With the library inside the Libs folder on Windows you don’t need a path. Try System.IsFunctionAvailable to see if your library is loaded and ready.

All I can tell you is that the documentation for declare says that LibraryName must be a String Literal or String Constant.

Forum for Xojo Programming Language and IDE. Copyright © 2021 Xojo, Inc.