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

Installed pkg-config files vary between Autotools and CMake #954

Open
arkadijs opened this issue Aug 2, 2024 · 1 comment
Open

Installed pkg-config files vary between Autotools and CMake #954

arkadijs opened this issue Aug 2, 2024 · 1 comment
Labels
build-cmake CMake build system

Comments

@arkadijs
Copy link
Contributor

arkadijs commented Aug 2, 2024

Describe the bug
portaudio-2.0.pc installed by Autotools and CMake builds vary, making predictable linking hard to attain.

Due to #918, an installation built with CMake is not functional because:

  • only static library installed
  • dependent libraries are not enumerated via pkg-config leading to linking errors.

User then must add platform-specific libs to link an application. Would shared library be also installed then it would just work, masking the issue. Developers who link statically know what to do but on average, as a developer, I'm presented with Undefined symbols error.

diff -u ./portaudio-2.0.pc.in ./cmake/portaudio-2.0.pc.in
--- ./portaudio-2.0.pc.in	2024-07-04 00:24:22
+++ ./cmake/portaudio-2.0.pc.in	2024-08-02 22:41:43
...
-Libs: -L${libdir} -lportaudio @LIBS@
-Cflags: -I${includedir} @THREAD_CFLAGS@
+Libs: -L${libdir} -lportaudio
+Libs.private: @PKGCONFIG_LDFLAGS_PRIVATE@
+Cflags: -I${includedir} @PKGCONFIG_CFLAGS@
+Requires.private: @PKGCONFIG_REQUIRES_PRIVATE@
sudo cmake --install build
-- Install configuration: "Release"
-- Installing: /usr/local/share/doc/PortAudio/portaudio/README.md
-- Installing: /usr/local/share/doc/PortAudio/portaudio/LICENSE.txt
-- Installing: /usr/local/lib/pkgconfig/portaudio-2.0.pc
-- Installing: /usr/local/lib/cmake/portaudio/PortAudioTargets.cmake
-- Installing: /usr/local/lib/cmake/portaudio/PortAudioTargets-release.cmake
-- Installing: /usr/local/lib/cmake/portaudio/PortAudioConfig.cmake
-- Installing: /usr/local/lib/cmake/portaudio/PortAudioConfigVersion.cmake
-- Installing: /usr/local/lib/libportaudio.a
-- Installing: /usr/local/include/portaudio.h
-- Installing: /usr/local/include/pa_mac_core.h

Autotools:

Libs: -L${libdir} -lportaudio -framework CoreAudio -framework AudioToolbox -framework AudioUnit -framework CoreFoundation -framework CoreServices
Cflags: -I${includedir} 

(missing -lm, BTW)

CMake:

cat /usr/local/lib/pkgconfig/portaudio-2.0.pc
...
Libs: -L${libdir} -lportaudio
Libs.private: -lm -framework CoreAudio -framework AudioToolbox -framework AudioUnit -framework CoreFoundation -framework CoreServices
Cflags: -I${includedir}
Requires.private: 

To Reproduce
Build with Autotools and attempt (static) link - it works.
Build with CMake - it doesn't, a lot of undefined symbols.

Expected behavior
If only static version is installed then linking against PortAudio must not require enumerating all dependent libraries - that should be handled via pkg-config.

Actual behavior

/opt/local/lib/go/pkg/tool/darwin_amd64/link: running /usr/bin/clang failed: exit status 1
Undefined symbols for architecture x86_64:
  "_AudioComponentFindNext", referenced from:
      _OpenAndSetupOneAudioUnit in libportaudio.a[15](pa_mac_core.c.o)
  "_AudioComponentInstanceDispose", referenced from:
      _CloseStream in libportaudio.a[15](pa_mac_core.c.o)
      _CloseStream in libportaudio.a[15](pa_mac_core.c.o)
      _OpenAndSetupOneAudioUnit in libportaudio.a[15](pa_mac_core.c.o)
  "_AudioComponentInstanceNew", referenced from:
      _OpenAndSetupOneAudioUnit in libportaudio.a[15](pa_mac_core.c.o)
...
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

(this is a Go app but the toolchain uses pkg-config internally)

Desktop:

  • OS: any, in this case macOS
  • PortAudio version: master HEAD
@arkadijs arkadijs changed the title Installed pkg-config files vary between autotools and CMake Installed pkg-config files vary between Autotools and CMake Aug 2, 2024
@RossBencina RossBencina added the build-cmake CMake build system label Aug 8, 2024
@RossBencina
Copy link
Collaborator

So #918 breaks the cmake install target?

But the earlier changes mean no static library is installed?

Am I correct to say that in our 19.7 release CMake built both static and dynamic libraries and installed them correctly? Whereas the current master builds only static or dynamic (not both), and does not install either correctly?

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

No branches or pull requests

2 participants