[Csnd] pkgsrc: audio/csound6, .dylib, Darwin (macOS)

Hi!

I'm in the process of updating the audio/csound6 package in pkgsrc. My
inital problem was, that the audio/csound6 package was out of date and
wouldn't build on Darwin. With the help of pkgsrc-users@NetBSD.org I was
able to update csound6 to 6.18.1 (residing in wip/csound6181). The next
problem arose: if built with pkgsrc, csound doesn't build the .dylibs,
necessary for, e.g. audio (librtjack.dylib). I've seen, that the .pkg in
the .dmg of csound installs CsoundLib64.framework to
"/Library/Frameworks".

Now my question: do I need special compiler flags for cmake / have to
edit CMakeLists.txt for the .dylibs?

I'm at loss right now, and don't know how to proceed...

Thank you in advance!

Kind regards.

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        Issues · csound/csound · GitHub
Discussions of bugs and features can be posted here

So your problem is that you can't build

librtjack.dylib

and what else?

For this one you need Jack to be installed (e.g. Jack DMP). The others are

librtpa.dylib needs Portaudio (v19)

The other (librtauhal) uses mac frameworks so no other deps are needed.

Prof. Victor Lazzarini
Maynooth University
Ireland

Also you can look at

installer/macosx/release-build.sh

to see how the installer is built. It assumes dependencies to be in /usr/local and does all the copying and editing of links that is needed for things to work.

There is a Custom.sh there as well which Cmake uses.

Prof. Victor Lazzarini
Maynooth University
Ireland

Exactly - jack is installed (/opt/pkg) but I'm only able to produce a
(librtjack|librtpa|librtauhal).so with pkgsrc.

With only the .so csound doesn't output sound on Darwin, no matter which
module I select (with -+rtaudio).

I'll take a closer look at "installer/macosx/release-build.sh", but at
the first glance, I couldn't spot that much differences to the Makefile
in pkgsrc...

Thank you for your time!

Kind regards.

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        Issues · csound/csound · GitHub
Discussions of bugs and features can be posted here

I think Jack is not being found because /opt/pkg is not in the search path for libraries in CMake. The
command is (InOut/CMakeLists.txt:57)

find_library(JACK_LIBRARY jack)

and the header is hard coded

set(JACK_HEADER “jack/jack.h”)

So the required dependencies are

check_deps(USE_JACK JACK_HEADER JACK_LIBRARY)

In the MacOS case JACK_HEADER is set already so I think the only thing that can fail is JACK_LIBRARY

In my build I have the message,

– USE_JACK is enabled.

can you check what you have?

If the problem is find_library(JACK_LIBRARY jack), see

[

find_library — CMake 3.28.0-rc2 Documentation
cmake.org

cmake-favicon.ico

](find_library — CMake 3.28.0-rc2 Documentation)

and maybe try adding PATHS

find_library(JACK_LIBRARY jack PATHS )

Prof. Victor Lazzarini
Maynooth University
Ireland

Hi!

Thank you for your answer! I re-checked the Makefile and the logs: if I
build csound (default options of pkgsrc enabled, this means jack) within
pkgsrc, the following log can be observed:

- - - - - - - - - - %< - - - - - - - - - -

-- ## REALTIME AUDIO AND MIDI ##
-- Looking for jack/jack.h
-- Looking for jack/jack.h - found
-- USE_ALSA is disabled.
-- USE_PULSEAUDIO is disabled.
-- Not building Portaudio Driver...
-- Portaudio v19 Found: .
-- USE_JACK is enabled.

- - - - - - - - - - %< - - - - - - - - - -

It doesn't matter which audio system I select - the *.so libraries are
built, but no *.dylib for the selected audio module:

Please let me re-phrase my problems into two questions:

a) Are the *.dylibs necessary for csound to work on Darwin?

As far as I can observe and understand, they are - since csound falls
back to a dummy rtaudio module, if only the *.so are present.

b) If the *.dylibs are necessary: how are they generated, i.e. for the
.pkg installer of csound for Darwin from upstream?
"installer/macosx/build-release.sh"?

If necessary, I can re-check the Makefile and maybe pass the following
arguments to cmake via options.mk:
-DJACK_HEADER=
-DJACK_LIBRARY=

But I don't think that's where the problem lies...

Thank you for your time!

Kind regards.

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        Issues · csound/csound · GitHub
Discussions of bugs and features can be posted here

Can't edit an e-mail:

mk ~/.../csound-6.18.1/cmake-pkgsrc-build $ ls -l lib*
-rwxr-xr-x 1 root wheel 50512 23 Okt 19:21 libampmidid.so
-rwxr-xr-x 1 root wheel 93712 23 Okt 19:21 libarrayops.so
-rwxr-xr-x 1 root wheel 67792 23 Okt 19:21 libbformdec2.so
-rwxr-xr-x 1 root wheel 51512 23 Okt 19:21 libcmidi.so
-rwxr-xr-x 1 root wheel 51504 23 Okt 19:21 libcontrol.so
-rwxr-xr-x 1 root wheel 231584 23 Okt 19:21 libcsnd6.6.0.dylib
lrwxr-xr-x 1 root wheel 18 23 Okt 19:21 libcsnd6.dylib -> libcsnd6.6.0.dylib
-rwxr-xr-x 1 root wheel 2748392 23 Okt 19:20 libcsound64.6.0.dylib
lrwxr-xr-x 1 root wheel 21 23 Okt 19:20 libcsound64.dylib -> libcsound64.6.0.dylib
-rwxr-xr-x 1 root wheel 50896 23 Okt 19:21 libdeprecated.so
-rwxr-xr-x 1 root wheel 52448 23 Okt 19:20 libdoppler.so
-rwxr-xr-x 1 root wheel 51936 23 Okt 19:21 libfractalnoise.so
-rwxr-xr-x 1 root wheel 78096 23 Okt 19:21 libftsamplebank.so
-rwxr-xr-x 1 root wheel 50960 23 Okt 19:21 libipmidi.so
-rwxr-xr-x 1 root wheel 50264 23 Okt 19:21 liblfsr.so
-rwxr-xr-x 1 root wheel 54120 23 Okt 19:21 libmixer.so
-rwxr-xr-x 1 root wheel 53416 23 Okt 19:21 libosc.so
-rwxr-xr-x 1 root wheel 51440 23 Okt 19:21 libpadsynth.so
-rwxr-xr-x 1 root wheel 68528 23 Okt 19:21 libpvsops.so
-rwxr-xr-x 1 root wheel 51824 23 Okt 19:21 librtauhal.so
-rwxr-xr-x 1 root wheel 69872 23 Okt 19:21 librtjack.so
-rwxr-xr-x 1 root wheel 67872 23 Okt 19:21 libscansyn.so
-rwxr-xr-x 1 root wheel 121080 23 Okt 19:21 libsignalflowgraph.so
-rwxr-xr-x 1 root wheel 172016 23 Okt 19:21 libstdutil.so
-rwxr-xr-x 1 root wheel 51968 23 Okt 19:21 libtrigenvsegs.so
-rwxr-xr-x 1 root wheel 50320 23 Okt 19:21 liburandom.so

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        Issues · csound/csound · GitHub
Discussions of bugs and features can be posted here

This is MacOS and .so libs are being produced instead of .dylib?

That's really strange, but also probably Csound will not load these as plugins, because they are not .dylibs (I have to check the code but I think a .dylib extension is searched for).

I don't understand why .so libraries are being produced.

Can you print all the terminal output and attach it as a file? Please build with -DCMAKE_VERBOSE_MAKEFILE=1

I am really puzzled now. I've never seen this CMake behaviour before.

Prof. Victor Lazzarini
Maynooth University
Ireland

Hi!

Yes, this is macOS and yes, only .so libraries are produced:

Darwin Mac-mini-von-Manuel.local 23.0.0 Darwin Kernel Version 23.0.0:
Fri Sep 15 14:41:34 PDT 2023; root:xnu-10002.1.13~1/RELEASE_ARM64_T8103
arm64

Build log is attached - let me know, if you need more information :slight_smile:

As written earlier: thank you for your time!

Kind regards.

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        Issues · csound/csound · GitHub
Discussions of bugs and features can be posted here

(Attachment build.log is missing)

Thanks. I see this:

[ 78%] Linking C shared module ../librtjack.so
cd /Users/mk/pkgsrc/wip/csound6181/work/csound-6.18.1/cmake-pkgsrc-build/InOut && /opt/pkg/bin/cmake -E cmake_link_script CMakeFiles/rtjack.dir/link.txt --verbose=1
/Users/mk/pkgsrc/wip/csound6181/work/.cwrapper/bin/clang -DHAVE_CLOCK_GETTIME -O2 -I/opt/pkg/include -I/opt/pkg/include/glib-2.0 -I/opt/pkg/include/gio-unix-2.0 -I/opt/pkg/lib/glib-2.0/include -I/opt/pkg/include/readline -I/opt/pkg/include/ncurses -I/opt/pkg/include/python3.11 -DLDAP_DEPRECATED -ffast-math -msse2 -fomit-frame-pointer -fvisibility=hidden -std=gnu99 -DHAVE_VECLIB -DSNDFILE_MP3 -DHAVE_ATOMIC_BUILTIN -DHAVE_CURL -DHAVE_PTHREAD -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk -mmacosx-version-min=11.3 -bundle -Wl,-headerpad_max_install_names -L/opt/pkg/lib/csound6 -L/opt/pkg/lib -o ../librtjack.so CMakeFiles/rtjack.dir/rtjack.c.o CMakeFiles/rtjack.dir/alphanumcmp.c.o /opt/pkg/lib/libjack.dylib /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk/usr/lib/libpthread.tbd

Note the -o ../librtjack.so <http://librtjack.so/&gt;

This is what I get here:

[ 78%] Linking C shared library ../librtjack.dylib
cd /Users/victor/src/csound/debug/InOut && /Applications/CMake.app/Contents/bin/cmake -E cmake_link_script CMakeFiles/rtjack.dir/link.txt --verbose=1
/Library/Developer/CommandLineTools/usr/bin/cc -DHAVE_CLOCK_GETTIME -ffast-math -fomit-frame-pointer -g -Wno-error -Wno-missing-field-initializers -Wno-unused-parameter -DBETA -Wall -Werror -Wno-missing-field-initializers -fvisibility=hidden -std=gnu99 -DHAVE_VECLIB -DSNDFILE_MP3 -DHAVE_ATOMIC_BUILTIN -DHAVE_CURL -DHAVE_PTHREAD -g -arch arm64 -arch x86_64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX13.3.sdk -mmacosx-version-min=10.7 -dynamiclib -Wl,-headerpad_max_install_names -o ../librtjack.dylib -install_name @rpath/librtjack.dylib CMakeFiles/rtjack.dir/rtjack.c.o CMakeFiles/rtjack.dir/alphanumcmp.c.o /usr/local/lib/libjack.dylib /Library/Developer/CommandLineTools/SDKs/MacOSX13.3.sdk/usr/lib/libpthread.tbd

and it is -o ../librtjack.dylib

I wonder if there is any difference in CMake options?

Hi!

The Makefile currently includes these arguments:

- - - - - - - - - - %< - - - - - - - - - -

CFLAGS+= -g -DBETA
CFLAGS+= -DCS_DEFAULT_PLUGINDIR=\"${PREFIX}/lib/csound/plugins64-6.0\"
USE_CMAKE= yes
CMAKE_ARGS+= -DBUILD_RELEASE=1
CMAKE_ARGS+= -DCMAKE_BUILD_TYPE=Release
CMAKE_ARGS+= -DCMAKE_VERBOSE_MAKEFILE=1

#CMAKE_INSTALL_RPATH doesn't work for some reason, so do it here.
LDFLAGS+= \{COMPILER\_RPATH\_FLAG\}{PREFIX}/lib/csound6

- - - - - - - - - - %< - - - - - - - - - -

These options were taken from audio/csound6 and can be changed /
removed. I'm not 99,9% confident, that these are the necessary
arguments, especially the CFLAGS...

options.mk includes these arguments:

- - - - - - - - - - %< - - - - - - - - - -

PKG_OPTIONS_VAR= PKG_OPTIONS.csound6
PKG_SUPPORTED_OPTIONS= jack portaudio pulseaudio

.include "../../mk/bsd.fast.prefs.mk"

.if \{OPSYS\} == &quot;Linux&quot; PKG\_SUPPORTED\_OPTIONS\+= alsa PKG\_SUGGESTED\_OPTIONS\+= alsa \.elif {OPSYS} != "Darwin" && ${OPSYS} != "Haiku"
PKG_SUGGESTED_OPTIONS+= portaudio
.endif

.include "../../mk/bsd.options.mk"

PLIST_VARS+= alsa
.if !empty(PKG_OPTIONS:Malsa)
.include "../../audio/alsa-lib/buildlink3.mk"
CMAKE_ARGS+= -DUSE_ALSA=ON
PLIST.alsa= yes
.else
CMAKE_ARGS+= -DUSE_ALSA=OFF
.endif

PLIST_VARS+= jack
.if !empty(PKG_OPTIONS:Mjack)
.include "../../audio/jack/buildlink3.mk"
CMAKE_ARGS+= -DUSE_JACK=ON
PLIST.jack= yes
.else
CMAKE_ARGS+= -DUSE_JACK=OFF
.endif

PLIST_VARS+= portaudio
.if !empty(PKG_OPTIONS:Mportaudio)
.include "../../audio/portaudio/buildlink3.mk"
CMAKE_ARGS+= -DUSE_PORTAUDIO=ON
CMAKE_ARGS+= -DCMAKE_INCLUDE_PATH=\{BUILDLINK\_PREFIX\.portaudio\}/include/portaudio2 CMAKE\_ARGS\+= \-DCMAKE\_LIBRARY\_PATH={BUILDLINK_PREFIX.portaudio}/lib/portaudio2
PLIST.portaudio= yes
.else
CMAKE_ARGS+= -DUSE_PORTAUDIO=OFF
.endif

PLIST_VARS+= pulseaudio
.if !empty(PKG_OPTIONS:Mpulseaudio)
.include "../../audio/pulseaudio/buildlink3.mk"
CMAKE_ARGS+= -DUSE_PULSEAUDIO=ON
PLIST.pulseaudio= yes
.else
CMAKE_ARGS+= -DUSE_PULSEAUDIO=OFF
.endif

- - - - - - - - - - %< - - - - - - - - - -

options.mk is mainly for the audio backend; the default setting is jack
(doesn't matter if the system is Darwin).

I tried setting in the Makefile:

CMAKE_ARGS+= -DBUILD_SHARED_LIBS=1

The reason was, that I spotted the "-dynamiclib" compiler flag in your
logs. But no change...

Kind regards.

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        Issues · csound/csound · GitHub
Discussions of bugs and features can be posted here

You need -dynamiclib for all dylibs (including plugins) and have to name them with .dylib extension.

Is this a hand written makefile? Or is it generated by CMake?

Prof. Victor Lazzarini
Maynooth University
Ireland

Hi!

O.K., so my first guess was right :slight_smile:

This is a handwritten Makefile (for NetBSD's pkgsrc); if I either add:

CFLAGS+= -g -DBETA -shared

or

CFLAGS+= -g -DBETA -dynamiclib

this is the output:

- - - - - - - - - - %< - - - - - - - - - -

[ 65%] Linking CXX shared module ../libdoppler.so
cd /Users/mk/pkgsrc/wip/csound6181/work/csound-6.18.1/cmake-pkgsrc-build/Opcodes && /opt/pkg/bin/cmake -E cmake_link_script CMakeFiles/doppler.dir/link.txt --verbose=1
/Users/mk/pkgsrc/wip/csound6181/work/.cwrapper/bin/clang++ -O2 -g -DBETA -shared -DCS_DEFAULT_PLUGINDIR=\"/opt/pkg/lib/csound/plugins64-6.0\" -I/opt/pkg/include -I/opt/pkg/include/glib-2.0 -I/opt/pkg/include/gio-unix-2.0 -I/opt/pkg/lib/glib-2.0/include -I/opt/pkg/include/readline -I/opt/pkg/include/ncurses -I/opt/pkg/include/python3.11 -DLDAP_DEPRECATED -std=c++11 -ffast-math -msse2 -fomit-frame-pointer -DNDEBUG -stdlib=libc++ -fvisibility=hidden -fvisibility=hidden -DHAVE_ATOMIC_BUILTIN -O3 -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk -mmacosx-version-min=11.3 -bundle -Wl,-headerpad_max_install_names -L/opt/pkg/lib/csound6 -L/opt/pkg/lib -o ../libdoppler.so CMakeFiles/doppler.dir/doppler.cpp.o
clang: error: invalid argument '-bundle' not allowed with '-dynamiclib'
*** [libdoppler.so] Error code 1

- - - - - - - - - - %< - - - - - - - - - -

Where can I remove the "-bundle" argument? I see no occurence in
Makefile, options.mk or CMakeLists.txt?

Kind regards.

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        Issues · csound/csound · GitHub
Discussions of bugs and features can be posted here

Can't edit an e-mail:

I'm not sure which argument and flag to use; I tried both of the
arguments and CFGLASG and LDFLAGS, but no changes... I'm not very
educated with compilers...

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        Issues · csound/csound · GitHub
Discussions of bugs and features can be posted here

I had a quick try with:

- - - - - - - - - - %< - - - - - - - - - -

NetBSD

--- Custom.cmake.ex.orig 2022-11-23 19:53:55.000000000 +0000
+++ Custom.cmake.ex
@@ -6,6 +6,7 @@ set(CMAKE_VERBOSE_MAKEFILE ON)
set(BUILD_STATIC_LIBRARY ON)
set(TCL_VERSION 8.5)
set(PYTHON_INCLUDE_DIRS "/usr/include/python2.7")
+set(CMAKE_SHARED_MODULE_CREATE_C_FLAGS "-dynamiclib -Wl,-headerpad_max_install_names")

#### NOTE the processor type needs setting
#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -W -Wall -mtune=core2")

- - - - - - - - - - %< - - - - - - - - - -

But no luck - somehow cmake falls back to "-bundle", at least the cmake,
installed via pkgsrc. I guess we are on the right track - but if it's
related to pkgsrc's cmake or the invocation of cmake is beyond my
knowledge...

FWIW: I'm not the first one to stumble upon this problem:

* Wireshark · Wireshark-dev: Re: [Wireshark-dev] configure fails with cmake on macosx
* #44232 (patch to have cmake use -dynamiclib in CMAKE_SHARED_MODULE_CREATE) – MacPorts
* https://public.kitware.com/Bug/view.php?id=15126

Kind regards.

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        Issues · csound/csound · GitHub
Discussions of bugs and features can be posted here

Ok, it's not a bundle, that's a different type of dynamic lib (we don't use). So

1. You need to find where -bundle is being added

2. You need to use -dynamiclib

3. the plugin libs need to have the extension .dylib in their names.

So here's a command line example for building a Csound plugin (with no dependencies)

cc -dynamiclib mysrc.c -o myplug.dylib -I<path to csound headers>

This command compiles and links the opcode. If you are using object files then you just replace the .c by a .o file.

Basically the solution is to fix the makefiles so you use -dynamiclib to build the libraries.

Prof. Victor Lazzarini
Maynooth University
Ireland

Got it! One question before I start searching and editing:

"Custom.cmake.ex" is the right place to pass custom commands to cmake?

It is my first time explicitly using cmake...

Kind regards.

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        Issues · csound/csound · GitHub
Discussions of bugs and features can be posted here

O.K., Custom.cmake.ex is the right place, according to CmakeLists.txt; I
re-named the example file to Custom.cmake and added the following two
lines:

- - - - - - - - - - %< - - - - - - - - - -

NetBSD

--- Custom.cmake.orig 2022-11-23 19:53:55.000000000 +0000
+++ Custom.cmake
@@ -6,6 +6,10 @@ set(CMAKE_VERBOSE_MAKEFILE ON)
set(BUILD_STATIC_LIBRARY ON)
set(TCL_VERSION 8.5)
set(PYTHON_INCLUDE_DIRS "/usr/include/python2.7")
+SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-dynamiclib - headerpad_max_install_names")
+SET(CMAKE_FIND_LIBRARY_SUFFIXES ".dylib" ".so" ".a")

#### NOTE the processor type needs setting
#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -W -Wall -mtune=core2")

- - - - - - - - - - %< - - - - - - - - - -

The result is:

- - - - - - - - - - %< - - - - - - - - - -

CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
PTHREAD_LIBRARY
    linked by target "rtjack" in directory /Users/mk/pkgsrc/wip/csound6181/work/csound-6.18.1/InOut

-- Generating done (0.2s)
CMake Generate step failed. Build files cannot be regenerated correctly.
*** Error code 1

Stop.
bmake[1]: stopped in /Users/mk/pkgsrc/wip/csound6181
*** Error code 1

Stop.
bmake: stopped in /Users/mk/pkgsrc/wip/csound6181
(1) mk ~/.../wip/csound6181 $

- - - - - - - - - - %< - - - - - - - - - -

I'm in need of a hint again :frowning:

Kind regards.

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        Issues · csound/csound · GitHub
Discussions of bugs and features can be posted here

Nevermind the bollocks - I have to write pkgsrc-users@NetBSD.org again,
since it is an error within pkgsrc (pthread is linked, but not found).

Kind regards.

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        Issues · csound/csound · GitHub
Discussions of bugs and features can be posted here

You can also see the Custom.cmake used in the installer build

installer/macosx/Custom_10.9.cmake

The script copies it and renames as Custom.cmake before building.

Prof. Victor Lazzarini
Maynooth University
Ireland