Linking a library in an addon on windows using addon_config.mk

Hi, i have coded ofxPDSP ( https://github.com/npisanti/ofxPDSP ) but at the moment it still doesn’t support sample loading on windows. To load samples i am using libsndfile on linux and the included libaudiodecoder on osx/ios, but making libaudiodecoder work on windows is a bit tricky . I’d like to use libsndfile, that is linked by default on linux, but not on windows. What is the correct way to do it? Can i just install libsndfile, then add

msys2:
ADDON_LDFLAGS = -llibsndfile
vs:
ADDON_LDFLAGS = -llibsndfile

to the addon_config.mk file and expect it to work?

PS: one of my main problems is that i don’t have a windows machine for testing at the moment, so i am just asking if there is a well know solution that just works

that should work, for msys2 it’s probably the most reasonable since you have pacman to easily install libraries in the system, for visual studio perhaps it’s easier to distribute if you compile the libraries and put them inside the addon in:

libs
   |_sndfile
       |_include
       |_lib
         |_vs
           |_x64
           |_Win32

Thanks for the answer arturo, i’m trying to avoid compiling libsndfile and putting it directly in my addon as it would change the license, actually i’m using a MIT License but libsndfile is LGPL so i have to make people install it separately and link it.

as far as i understand as long as you include a dynamic library it shoulnd’t be a problem but in any case what you posted should work for msys2 but not sure about the flag for vs, if you check the command line output in any vs project it’ll tell you what’s the correct flag

ok there could be some issues with vs, i will try to make it work as soon as i have time (and a windows machine)

this could also be useful for this purpose—>

ooh, this one is really annoying. I haven’t tried with libsndfile on windows, but I did try to get addon_config.mk to add libaudiodecoder correctly on VS when using ofxSoundObjects, but it didn’t work and I kinda gave up. Don’t remember the specifics, but I do remember having to dig into project generators code to figure out what was going on, but it didn’t work out. I’ve seen that @elliotwoods uses some stuff that is kinda helpful for adding and managing libs and addons on VS.

Hey @roymacdonald!
Thanks for mentioning.

The pattern is described in ofxAddonLib:
https://github.com/elliotwoods/ofxAddonLib

I’d love if this became more widely used, and eventually gained project generator support (i.e. Project generator would use an addon’s project in your solution where available)

Elliot

1 Like