Where to put supporting file?
Quick question, so my external depends on a 3rd party dylib file but the dylib looks for the file isports.ini either in /dev or in the directory that the application is running in. Problem is that when it’s compiled as an external I don’t know where to put the .ini file. Doesn’t seem to work when included in the MXO as contents/resources, in the Max5 folder, in the same directory as the .mxo builds to. Am I missing something obvious?
Oh, and I can’t sudo cp the file to the /dev directory so I don’t think that’s an option.
Is this an external you are building? If so, you can use the max/msp "nameinpath()" and "path_topathname()" functions to find the file somewhere on the max search path.
If not, I think there are some shell variables you can set (like $LIBS or something) that may work, but not sure if max/msp will pay heed to them.
Not sure. Have you tried Contents/MacOS/ ? That’s where your external’s executable is.
My first guess would have been the Max5/ directory, but you said that didn’t work.
Thanks so much for the replies!
I did also try in the MACOS/ directory, but now I’m starting to think that maybe I had multiple files which confuses (what I’m assuming is) the fopen command. So I might have to go through things methodically, painstakingly, moving the file around.
I also appealed to the developer who sent me a new dylib which may allow me to set the path internally, but it’s not foolproof, so I might have to try doing it manually anyhow.
Will post a solution if/when that happens. All suggestions are still welcome!!
Max’s searchpath does not drill down into bundles. If it did then the searchpath would become gigantic and performance would suffer. So…
You can first determine the path of your mxo bundle (the extern) using Max’s API. Then you can use Apple’s functions for finding the folders (e.g. the Resources folder) inside your bundle (or just append the path using the CFURL API or whatever it is you need to do).
Hope that helps.
Ultimately the developer of the .dylib changed the behaviour to check the PATH first so by using:
and keeping the ini file in the / dir all is well.
Wish I had a more elequent solution but doubtful many people are going to use this external when it’s done anyways.