stsaz / fmedia

fast audio player/recorder/converter
BSD 2-Clause "Simplified" License
216 stars 21 forks source link

Building on FreeBSD #85

Closed Jehops closed 2 years ago

Jehops commented 2 years ago

Hello,

I tried building on FreeBSD (14), however there is a build failure in the first step building alib3.

root@14amd64-default:/wrkdirs/usr/ports/multimedia/fmedia/work/fmedia/alib3 # gmake
gmake -Rr -C ALAC
gmake[1]: Entering directory '/wrkdirs/usr/ports/multimedia/fmedia/work/fmedia/alib3/ALAC'
curl -L -o master.zip https://github.com/macosforge/alac/archive/refs/heads/master.zip
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100 83035    0 83035    0     0   157k      0 --:--:-- --:--:-- --:--:--  157k
unzip -n master.zip
Archive:  master.zip
   creating: alac-master/
 extracting: alac-master/ALACMagicCookieDescription.txt
 extracting: alac-master/CONTRIBUTING.md
 extracting: alac-master/LICENSE
 extracting: alac-master/PULL_REQUEST_TEMPLATE.md
 extracting: alac-master/ReadMe.txt
   creating: alac-master/codec/
 extracting: alac-master/codec/ALACAudioTypes.h
 extracting: alac-master/codec/ALACBitUtilities.c
 extracting: alac-master/codec/ALACBitUtilities.h
 extracting: alac-master/codec/ALACDecoder.cpp
 extracting: alac-master/codec/ALACDecoder.h
 extracting: alac-master/codec/ALACEncoder.cpp
 extracting: alac-master/codec/ALACEncoder.h
 extracting: alac-master/codec/APPLE_LICENSE.txt
 extracting: alac-master/codec/EndianPortable.c
 extracting: alac-master/codec/EndianPortable.h
 extracting: alac-master/codec/ag_dec.c
 extracting: alac-master/codec/ag_enc.c
 extracting: alac-master/codec/aglib.h
 extracting: alac-master/codec/dp_dec.c
 extracting: alac-master/codec/dp_enc.c
 extracting: alac-master/codec/dplib.h
 extracting: alac-master/codec/makefile
 extracting: alac-master/codec/matrix_dec.c
 extracting: alac-master/codec/matrix_enc.c
 extracting: alac-master/codec/matrixlib.h
   creating: alac-master/convert-utility/
 extracting: alac-master/convert-utility/ALACconvert.sln
 extracting: alac-master/convert-utility/ALACconvert.vcproj
   creating: alac-master/convert-utility/ALACconvert.xcodeproj/
 extracting: alac-master/convert-utility/ALACconvert.xcodeproj/project.pbxproj
 extracting: alac-master/convert-utility/CAFFileALAC.cpp
 extracting: alac-master/convert-utility/CAFFileALAC.h
 extracting: alac-master/convert-utility/main.cpp
 extracting: alac-master/convert-utility/makefile
touch alac-master
cd alac-master && cat ../*.patch | patch -p1
Hmm...  Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|From 4be5a2e2075831d48483ab81e73f02a731748dd8 Mon Sep 17 00:00:00 2001
|From: Simon Zolin <stsaz@yandex.ru>
|Date: Tue, 23 Feb 2016 09:35:05 +0300
|Subject: [PATCH] Decode(): don't set output sample number if nothing was
| decoded
|
|---
| codec/ALACDecoder.cpp | 2 +-
| 1 file changed, 1 insertion(+), 1 deletion(-)
|
|diff --git a/codec/ALACDecoder.cpp b/codec/ALACDecoder.cpp
|index ce3340d..5f98520 100644
|--- a/codec/ALACDecoder.cpp
|+++ b/codec/ALACDecoder.cpp
--------------------------
Patching file codec/ALACDecoder.cpp using Plan A...
Hunk #1 succeeded at 207.
Hmm...  Ignoring the trailing garbage.
done
gmake -rR libALAC-ff.so
gmake[2]: Entering directory '/wrkdirs/usr/ports/multimedia/fmedia/work/fmedia/alib3/ALAC'
clang++ -c -O3 -fpic -fvisibility=hidden -Wall -Ialac-master/codec ALAC-ff.cpp -o ALAC-ff.o
clang++ -c -O3 -fpic -fvisibility=hidden -Wall -Ialac-master/codec alac-master/codec/ALACDecoder.cpp -o alac-master/codec/ALACDecoder.o
alac-master/codec/ALACDecoder.cpp:189:14: warning: variable 'samples' set but not used [-Wunused-but-set-variable]
        int16_t *                       samples;
                                        ^
alac-master/codec/ALACDecoder.cpp:659:11: warning: variable 'element_instance_tag' set but not used [-Wunused-but-set-variable]
        uint8_t         element_instance_tag;
                        ^
alac-master/codec/ALACDecoder.cpp:38:16: warning: unused variable 'kMaxBitDepth' [-Wunused-const-variable]
const uint32_t kMaxBitDepth = 32;                       // max allowed bit depth is 32
               ^
3 warnings generated.
clang++ -c -O3 -fpic -fvisibility=hidden -Wall -Ialac-master/codec alac-master/codec/ALACEncoder.cpp -o alac-master/codec/ALACEncoder.o
alac-master/codec/ALACEncoder.cpp:279:13: warning: variable 'denShift' set but not used [-Wunused-but-set-variable]
        uint32_t                        denShift;
                                        ^
alac-master/codec/ALACEncoder.cpp:559:13: warning: variable 'denShift' set but not used [-Wunused-but-set-variable]
        uint32_t                        denShift;
                                        ^
alac-master/codec/ALACEncoder.cpp:48:16: warning: unused variable 'kALACEncoderMagic' [-Wunused-const-variable]
const uint32_t kALACEncoderMagic        = 'dpge';
               ^
alac-master/codec/ALACEncoder.cpp:94:23: warning: unused variable 'sSupportediPodSampleRates' [-Wunused-const-variable]
static const uint32_t sSupportediPodSampleRates[] =
                      ^
4 warnings generated.
clang -c -O3 -fpic -fvisibility=hidden -Wall -Ialac-master/codec alac-master/codec/EndianPortable.c -o alac-master/codec/EndianPortable.o
clang -c -O3 -fpic -fvisibility=hidden -Wall -Ialac-master/codec alac-master/codec/ALACBitUtilities.c -o alac-master/codec/ALACBitUtilities.o
clang -c -O3 -fpic -fvisibility=hidden -Wall -Ialac-master/codec alac-master/codec/ag_dec.c -o alac-master/codec/ag_dec.o
clang -c -O3 -fpic -fvisibility=hidden -Wall -Ialac-master/codec alac-master/codec/ag_enc.c -o alac-master/codec/ag_enc.o
alac-master/codec/ag_enc.c:101:38: warning: unused function 'read32bit' [-Wunused-function]
static inline uint32_t ALWAYS_INLINE read32bit( uint8_t * buffer )
                                     ^
1 warning generated.
clang -c -O3 -fpic -fvisibility=hidden -Wall -Ialac-master/codec alac-master/codec/dp_dec.c -o alac-master/codec/dp_dec.o
clang -c -O3 -fpic -fvisibility=hidden -Wall -Ialac-master/codec alac-master/codec/dp_enc.c -o alac-master/codec/dp_enc.o
clang -c -O3 -fpic -fvisibility=hidden -Wall -Ialac-master/codec alac-master/codec/matrix_dec.c -o alac-master/codec/matrix_dec.o
clang -c -O3 -fpic -fvisibility=hidden -Wall -Ialac-master/codec alac-master/codec/matrix_enc.c -o alac-master/codec/matrix_enc.o
clang -fpic -Wl,-no-undefined -static-libgcc  -s -lm -static-libstdc++ -shared ALAC-ff.o alac-master/codec/ALACDecoder.o alac-master/codec/ALACEncoder.o alac-master/codec/EndianPortable.o alac-master/codec/ALACBitUtilities.o alac-master/codec/ag_dec.o alac-master/codec/ag_enc.o alac-master/codec/dp_dec.o alac-master/codec/dp_enc.o alac-master/codec/matrix_dec.o alac-master/codec/matrix_enc.o -o libALAC-ff.so
clang: warning: argument unused during compilation: '-static-libgcc' [-Wunused-command-line-argument]
clang: warning: argument unused during compilation: '-static-libstdc++' [-Wunused-command-line-argument]
ld: error: undefined symbol: operator new(unsigned long)
>>> referenced by ALAC-ff.cpp
>>>               ALAC-ff.o:(alac_init)

ld: error: undefined symbol: operator delete(void*)
>>> referenced by ALAC-ff.cpp
>>>               ALAC-ff.o:(alac_init)
>>> referenced by ALAC-ff.cpp
>>>               ALAC-ff.o:(alac_init)
>>> referenced by ALAC-ff.cpp
>>>               ALAC-ff.o:(alac_free)
>>> referenced 1 more times

ld: error: undefined symbol: __gxx_personality_v0
>>> referenced by ALAC-ff.cpp
>>>               ALAC-ff.o:(DW.ref.__gxx_personality_v0)

ld: error: undefined symbol: vtable for __cxxabiv1::__class_type_info
>>> referenced by ALACEncoder.cpp
>>>               alac-master/codec/ALACEncoder.o:(typeinfo for ALACEncoder)
>>> the vtable symbol may be undefined because the class is missing its key function (see https://lld.llvm.org/missingkeyfunction)
clang: error: linker command failed with exit code 1 (use -v to see invocation)
gmake[2]: *** [Makefile:49: libALAC-ff.so] Error 1
gmake[2]: Leaving directory '/wrkdirs/usr/ports/multimedia/fmedia/work/fmedia/alib3/ALAC'
gmake[1]: *** [Makefile:13: all] Error 2
gmake[1]: Leaving directory '/wrkdirs/usr/ports/multimedia/fmedia/work/fmedia/alib3/ALAC'
gmake: *** [Makefile:8: all] Error 2
root@14amd64-default:/wrkdirs/usr/ports/multimedia/fmedia/work/fmedia/alib3 #
Jehops commented 2 years ago

Rather than downloading alac can we point to an installation of the FreeBSD port?

stsaz commented 2 years ago

Hello!

undefined symbol: operator new

It seems like clang doesn't generate new/delete operators for a struct by default (in ALAC-ff.cpp), that's interesting. I don't have a solution for this at the moment, but I guess that if you'd convert it to a class with public: fields, then it will work.

can we point to an installation of the FreeBSD port?

In theory you may use any source code package you want for ALAC, as long as you patch it appropriately and compile *-ff.c files into it. The patch file and additional C++ file are needed because fmedia doesn't use official libALAC functions directly but via a custom wrapper/interface. And that's also true for most other 3rd party dependencies.

stsaz commented 2 years ago

Fixed. The solution was to just use clang++ to link C++ object files.