Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fluidsynth.pc doesn't include static libraries #904

Closed
Roboron3042 opened this issue Jun 3, 2021 · 7 comments · Fixed by #933
Closed

Fluidsynth.pc doesn't include static libraries #904

Roboron3042 opened this issue Jun 3, 2021 · 7 comments · Fixed by #933
Labels
Milestone

Comments

@Roboron3042
Copy link

FluidSynth version

Any.

Describe the bug

A static version of FluidSynth does not include the statically linked libraries in the fluidsynth.pc file.

Expected behavior

Executing pkg-config --libs --static fluidsynth returns the list of static libraries (depending on which libraries have been used). Instead, currently only "-lfluidsynth" is returned.

Steps to reproduce

Build FluidSynth with CMake option -DBUILD_SHARED_LIBS=OFF

Additional context

Related issues with suggested solutions

To sum up: the Libs.private section of fluidsynth.pc.in needs to be set to a CMake variable containing all the libraries used for static linking.

@derselbst
Copy link
Member

Sorry, it took a bit longer. But a PR is ready now. Feel free to test. CMake 3.12 or newer is required.

@Roboron3042
Copy link
Author

Roboron3042 commented Jul 4, 2021

Test case: I compiled fluidsynth with the following parameters (this is the minimum set my project needs).

-Denable-aufile=0 -Denable-dbus=0 -Denable-ipv6=0 -Denable-jack=0 -Denable-ladspa=0 -Denable-midishare=0 -Denable-opensles=0 -Denable-oboe=0 -Denable-oss=0 -Denable-readline=0 -Denable-winmidi=0 -Denable-waveout=0 -Denable-libsndfile=0 -Denable-network=0 -Denable-pulseaudio=0 -Denable-dsound=1 -Denable-sdl2=0

For reference: this is what my project needs to link statically against fluidsynth (obtained by trial and error, there could be something missing or not necessary at all):

-lfluidsynth -lharfbuzz -lgraphite2 -lglib-2.0 -lintl -liconv -ldsound -lole32 -lws2_32 -lgomp -lksuser

And this is what pkg-config --libs --static fluidsynth report after compiling:

-lfluidsynth -lgthread-2.0 -lglib-2.0 -lintl -ldsound -lksuser -lole32

The linking then failed with some undefined references, as expected. You probably need to include required libraries of libraries used by fluidsynth (such as gomp for glib if I am not mistaken).

/usr/lib/gcc/i686-w64-mingw32/11.1.0/../../../../i686-w64-mingw32/bin/ld: /usr/lib/gcc/i686-w64-mingw32/11.1.0/../../../../i686-w64-mingw32/lib/../lib/libfluidsynth.a(fluid_defsfont.c.obj): in function `fluid_defsfont_load_all_sampledata._omp_fn.0':
/home/rober/Archivos/Descargas/temp/fluidsynth/src/fluidsynth/src/sfloader/fluid_defsfont.c:397: undefined reference to `GOMP_single_start'
/usr/lib/gcc/i686-w64-mingw32/11.1.0/../../../../i686-w64-mingw32/bin/ld: /home/rober/Archivos/Descargas/temp/fluidsynth/src/fluidsynth/src/sfloader/fluid_defsfont.c:406: undefined reference to `GOMP_task'
/usr/lib/gcc/i686-w64-mingw32/11.1.0/../../../../i686-w64-mingw32/bin/ld: /home/rober/Archivos/Descargas/temp/fluidsynth/src/fluidsynth/src/sfloader/fluid_defsfont.c:425: undefined reference to `GOMP_task'
/usr/lib/gcc/i686-w64-mingw32/11.1.0/../../../../i686-w64-mingw32/bin/ld: /usr/lib/gcc/i686-w64-mingw32/11.1.0/../../../../i686-w64-mingw32/lib/../lib/libfluidsynth.a(fluid_defsfont.c.obj): in function `fluid_defsfont_load_all_sampledata._omp_fn.1':
/home/rober/Archivos/Descargas/temp/fluidsynth/src/fluidsynth/src/sfloader/fluid_defsfont.c:410: undefined reference to `GOMP_critical_start'
/usr/lib/gcc/i686-w64-mingw32/11.1.0/../../../../i686-w64-mingw32/bin/ld: /usr/lib/gcc/i686-w64-mingw32/11.1.0/../../../../i686-w64-mingw32/lib/../lib/libfluidsynth.a(fluid_defsfont.c.obj): in function `fluid_defsfont_load_all_sampledata':
/home/rober/Archivos/Descargas/temp/fluidsynth/src/fluidsynth/src/sfloader/fluid_defsfont.c:396: undefined reference to `GOMP_parallel'
/usr/lib/gcc/i686-w64-mingw32/11.1.0/../../../../i686-w64-mingw32/bin/ld: /usr/lib/gcc/i686-w64-mingw32/11.1.0/../../../../i686-w64-mingw32/lib/../lib/libfluidsynth.a(fluid_defsfont.c.obj): in function `fluid_defsfont_load_all_sampledata._omp_fn.0':
/home/rober/Archivos/Descargas/temp/fluidsynth/src/fluidsynth/src/sfloader/fluid_defsfont.c:396: undefined reference to `GOMP_barrier'
/usr/lib/gcc/i686-w64-mingw32/11.1.0/../../../../i686-w64-mingw32/bin/ld: /usr/lib/gcc/i686-w64-mingw32/11.1.0/../../../../i686-w64-mingw32/lib/../lib/libfluidsynth.a(fluid_defsfont.c.obj): in function `fluid_defsfont_load_all_sampledata._omp_fn.1':
/home/rober/Archivos/Descargas/temp/fluidsynth/src/fluidsynth/src/sfloader/fluid_defsfont.c:410: undefined reference to `GOMP_critical_end'
/usr/lib/gcc/i686-w64-mingw32/11.1.0/../../../../i686-w64-mingw32/bin/ld: /usr/lib/gcc/i686-w64-mingw32/11.1.0/../../../../i686-w64-mingw32/lib/../lib/libintl.a(dcigettext.o):(.text+0x671): undefined reference to `libiconv_open'
/usr/lib/gcc/i686-w64-mingw32/11.1.0/../../../../i686-w64-mingw32/bin/ld: /usr/lib/gcc/i686-w64-mingw32/11.1.0/../../../../i686-w64-mingw32/lib/../lib/libintl.a(dcigettext.o):(.text+0x84f): undefined reference to `libiconv'
/usr/lib/gcc/i686-w64-mingw32/11.1.0/../../../../i686-w64-mingw32/bin/ld: /usr/lib/gcc/i686-w64-mingw32/11.1.0/../../../../i686-w64-mingw32/lib/../lib/libintl.a(dcigettext.o):(.text+0xa5f): undefined reference to `libiconv_open'
/usr/lib/gcc/i686-w64-mingw32/11.1.0/../../../../i686-w64-mingw32/bin/ld: /usr/lib/gcc/i686-w64-mingw32/11.1.0/../../../../i686-w64-mingw32/lib/../lib/libintl.a(relocatable.o):(.text+0x4b): undefined reference to `libiconv_set_relocation_prefix'

@derselbst
Copy link
Member

Thanks for testing.

You probably need to include required libraries of libraries used by fluidsynth

I don't think so:

Libs.private: This line should list any private libraries in use. Private libraries are libraries which are not exposed through your library, but are needed in the case of static linking.

"needed for static linking" means any symbol that fluidsynth itself uses from other libraries, or in other words all the libs that fluidsynth uses directly should be included. But not the dependencies of the dependencies of the dependencies...

In your case, you're using a static libintl (i.e. one of glibs dependencies), so I think you would also need to include
pkg-config --libs --static intl (or if there is no intl.pc file, try pkg-config --libs --static glib-2.0).

However, I do agree that openMP should be among the private libs. In my case it's working as expected:

-lgthread-2.0 -lglib-2.0 -lgmodule-2.0 -lglib-2.0 -ljack -lasound -lpulse-simple -lpulse -lsndfile -lSDL2 -ldbus-1 -lm -linstpatch-1.0 -lgobject-2.0 -lgthread-2.0 -lglib-2.0 -lsndfile /usr/lib64/libreadline.so /usr/lib64/gcc/x86_64-suse-linux/7/libgomp.so /usr/lib64/libpthread.so -lpthread

To investigate: I've committed some debug prints to the CMake configure output. Can you please run CMake and post the output?

@Roboron3042
Copy link
Author

I understand, that makes sense.

Here's the CMake output https://gist.github.com/Roboron3042/fc7fbeb8c7caaea2227b41598060ae36

@derselbst
Copy link
Member

Unfortunately, the few debug lines are missing. Have you pulled the branch again?

@Roboron3042
Copy link
Author

Sorry, I messed up and instead of changing to the remote branch I created a local branch 😅

-- CMAKE_VERSION: 3.20.5
-- OpenMP_C_FLAGS: -fopenmp
-- OpenMP_C_LIBRARIES: /usr/i686-w64-mingw32/lib/libgomp.dll.a;/usr/i686-w64-mingw32/lib/libmingwthrd.a;/usr/i686-w64-mingw32/lib/libmingwthrd.a
-- OpenMP_C_LIB_NAMES: gomp;mingwthrd;mingwthrd

@derselbst
Copy link
Member

I cannot reproduce the missing libgomp. Even with cmake 3.20.5, an absolute path to libgomp is always included in the .pc file and pkg-config is reporting that correctly. I've reviewed the .pc file generated by our MinGW CI build and it's also including libgomp. I'm not sure if it's good practice to include absolute paths at all. Probably not. Probably one could switch to using OpenMP_C_LIB_NAMES, but as long as MacOS11 isn't available for CI builds, I will not make further changes to this to avoid a regression for #917.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants