libopenmpt - How to enable openmpt::module_ext?

Started by Danny-E 33, November 26, 2022, 18:02:47

Previous topic - Next topic

Danny-E 33

For my project, I built libopenmpt 0.6.3 from source using the following:
# Build libopenmpt-0.6.3
pushd lib
wget https://lib.openmpt.org/files/libopenmpt/src/libopenmpt-0.6.3+release.autotools.tar.gz
mkdir libopenmpt && tar xf libopenmpt-0.6.3+release.autotools.tar.gz -C libopenmpt --strip-components=1
cd libopenmpt
./configure --prefix="$(realpath "$PWD/../..")" \
    --without-mpg123 \
    --without-ogg \
    --without-vorbis \
    --without-vorbisfile \
    --without-sndfile \
    --without-flac
make CXX="g++-8 -std=c++17"
make install
popd
and have been using the openmpt::module class which has been working great.

I tried changing `new openmpt::module(_data)` to `new openmpt::module_ext(_data)` (and updated the include to #include <libopenmpt/libopenmpt_ext.hpp> of course) which compiles without errors but I get the following error at run-time:
$ ./bin/crystaltrackerd
./bin/crystaltrackerd: symbol lookup error: ./bin/crystaltrackerd: undefined symbol: _ZN7openmpt10module_extC1ERKSt6vectorIhSaIhEERSoRKSt3mapINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESD_St4lessISD_ESaISt4pairIKSD_SD_EEE

Is there something I have to do to "enable" the extensions? (Specifically the "interactive" extension; need access to set_channel_mute_status() etc.)

I hope it's something simple like passing an extra flag to configure and/or make when building libopenmpt from source, but I can't find any documentation on it.

Thanks!

manx

No, you do not need to do anything special to make the _ext interfaces available. What you did looks correct to me.

Just a wild guess: The missing symbol was added in libopenmpt 0.5, and I did a quick test build of 0.6.6 and it indeed does export that symbol. What might be happening is that your binary loads a system-installed libopenmpt instead of the one you built. ldd ./bin/crystaltrackerd | grep libopenmpt might give some clues.

You may solve such issues by either setting -rpath when linking or setting LD_LIBRARY_PATH= when running. Details on what would be the best solution probably depend on your build system.


Danny-E 33

Oh, thank you for the tip. I feel kind of silly, the fix was easy.

ldd ./bin/crystaltrackerd | grep libopenmpt showed that my binary was using /usr/lib/x86_64-linux-gnu/libopenmpt.so.0 by accident.

I just had to edit my LDFLAGS by changing -lopenmpt to lib/libopenmpt.a in my Makefile.

Thanks for the help! The interactive extension is working just fine now  :)