Where to store external DLL/DYLIB files

Hi,

I have problems understanding how to work with external dlls/dylibs file in my Xojo project.

I’m using soft declares to functions of an external dll/dylib file, both on Windows and Mac. On Mac my app can find and use the dylib file if I use the full path to the file, e.g. /Users/username/projects/xojoapp/mylib.dylib. On Windows it only works if I place the dll file into the C:\windws folder.

I can’t imagine that this is the recommended way to handle external libraries. What is the best/usual way to store (and later deploy) external libraries and use them during development (just click the Run button in Xojo) and build/deploy?

Thanks for any help.

right next to your executable on windows (Parent directory).
on mac place them inside the Frameworks folder (using a Post build CopyFileStep)

Then just call the libname.dylib or libname.dll depending on the platform.

Just use a copy file step to place the DLL next to your program executable or in the frameworks bundle folder.

Can you add the an application subfolder to the PATH variable?

System.EnvironmentVariable("PATH") = pathToSubfolder

I have to do this to get VLC and Quicktime (older versions) to work on windows.

The only way I see to achieve that would be to run a .Bat file containing the line you posted. Not shell to it. Point a folderItem to it and do a launch. That way it will be added to the system variables.

On Windows be aware that this will overwrite everything in the PATH variable, which might cause problems. It’s better to append/prepend (ordering is significant) your custom directory to the variable rather than overwrite:

Dim s As String = System.EnvironmentVariable("PATH") System.EnvironmentVariable("PATH") = s + ";" + pathToSubfolder //searched LAST // OR System.EnvironmentVariable("PATH") = pathToSubfolder + ";" + s //searched FIRST

[quote=367157:@Andrew Lambert]On Windows be aware that this will overwrite everything in the PATH variable, which might cause problems. It’s better to append/prepend (ordering is significant) your custom directory to the variable rather than overwrite:

Dim s As String = System.EnvironmentVariable("PATH") System.EnvironmentVariable("PATH") = s + ";" + pathToSubfolder //searched LAST // OR System.EnvironmentVariable("PATH") = pathToSubfolder + ";" + s //searched FIRST[/quote]

Good point, I had problems with PATH being too long to append to and I did not need to look in other locations so this was fine for me. Note this will only effect your running application.

On Mac the PATH wouldn’t work for libraries. There was a setting for a dylibs alternative paths in past, but was removed due to security concerns.

However on Mac you can use the @executable_path shortcut. See https://wincent.com/wiki/%40executable_path%2C_%40load_path_and_%40rpath for more info.