Opendigitalradio / ODR-AudioEnc

ODR-AudioEnc is a DAB and DAB+ audio encoder, part of the ODR-mmbTools.
https://www.opendigitalradio.org
24 stars 17 forks source link

Compiling under Mac OS fails with duplicate symbols #2

Closed amuso closed 7 years ago

amuso commented 7 years ago

Hi, I'm trying to compile under Mac OS X 10.9 using X-Code command line tools (make). Looking for tips to compile successfully.

I've fetched the source using git:

git clone https://github.com/Opendigitalradio/ODR-AudioEnc

fdk-aac and other needed libraries compiled from source to /usr/local

Here's the versions of the tools used.

$ gcc -v
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 6.0 (clang-600.0.57) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin13.4.0
Thread model: posix
$ make -v
GNU Make 3.81
Copyright (C) 2006  Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.

This program built for i386-apple-darwin11.3.0
$ ld -v
@(#)PROGRAM:ld  PROJECT:ld64-241.9
configured to support archs: armv6 armv7 armv7s arm64 i386 x86_64 x86_64h armv6m armv7m armv7em
LTO support using: LLVM version 3.5svn
$ pkg-config --version
0.29.1

To compile I performed these steps:

$ ./bootstrap 
You can call ./configure now

Since -lrt isn't supported, I've commented out lines 16145-16190 in configure before running it.

$ ./configure 
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... ./install-sh -c -d
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether UID '501' is supported by ustar format... yes
checking whether GID '20' is supported by ustar format... yes
checking how to create a ustar tar archive... gnutar
checking whether make supports nested variables... (cached) yes
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether gcc understands -c and -o together... yes
checking for style of include used by make... GNU
checking dependency style of gcc... gcc3
checking for g++... g++
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking dependency style of g++... gcc3
checking build system type... x86_64-apple-darwin13.4.0
checking host system type... x86_64-apple-darwin13.4.0
checking how to print strings... printf
checking for a sed that does not truncate output... /usr/bin/sed
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for fgrep... /usr/bin/grep -F
checking for ld used by gcc... /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld
checking if the linker (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld) is GNU ld... no
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm
checking the name lister (/usr/bin/nm) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 196608
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... yes
checking how to convert x86_64-apple-darwin13.4.0 file names to x86_64-apple-darwin13.4.0 format... func_convert_file_noop
checking how to convert x86_64-apple-darwin13.4.0 file names to toolchain format... func_convert_file_noop
checking for /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld option to reload object files... -r
checking for objdump... no
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for ar... ar
checking for archiver @FILE support... no
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm output from gcc object... ok
checking for sysroot... no
checking for mt... no
checking if : is a manifest tool... no
checking for dsymutil... dsymutil
checking for nmedit... nmedit
checking for lipo... lipo
checking for otool... otool
checking for otool64... no
checking for -single_module linker flag... yes
checking for -exported_symbols_list linker flag... yes
checking for -force_load linker flag... yes
checking how to run the C preprocessor... gcc -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... yes
checking for gcc option to produce PIC... -fno-common -DPIC
checking if gcc PIC flag -fno-common -DPIC works... yes
checking if gcc static flag -static works... no
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld) supports shared libraries... yes
checking dynamic linker characteristics... darwin13.4.0 dyld
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking how to run the C++ preprocessor... g++ -E
checking for ld used by g++... /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld
checking if the linker (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld) is GNU ld... no
checking whether the g++ linker (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld) supports shared libraries... yes
checking for g++ option to produce PIC... -fno-common -DPIC
checking if g++ PIC flag -fno-common -DPIC works... yes
checking if g++ static flag -static works... no
checking if g++ supports -c -o file.o... yes
checking if g++ supports -c -o file.o... (cached) yes
checking whether the g++ linker (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld) supports shared libraries... yes
checking dynamic linker characteristics... darwin13.4.0 dyld
checking how to hardcode library paths into programs... immediate
checking whether g++ supports C++11 features by default... no
checking whether g++ supports C++11 features with -std=c++11... yes
checking whether gcc is Clang... yes
checking whether Clang needs flag to prevent "argument unused" warning when linking with -pthread... -Qunused-arguments
checking for joinable pthread attribute... PTHREAD_CREATE_JOINABLE
checking whether more special flags are required for pthreads... no
checking for PTHREAD_PRIO_INHERIT... yes
checking for sin in -lm... yes
checking for pkg-config... /usr/local/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for zmq_init in -lzmq... yes
checking for aacEncOpen in -lfdk-aac... yes
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating config.h
config.status: executing depfiles commands
config.status: executing libtool commands

***********************************************

Features enabled:
  Enabled: 
  Disabled:  jack vlc alsa

$ make
/Applications/Xcode.app/Contents/Developer/usr/bin/make  all-am
  CC       libtoolame-dab/libtoolame_dab_la-common.lo
  CC       libtoolame-dab/libtoolame_dab_la-encode.lo
  CC       libtoolame-dab/libtoolame_dab_la-ieeefloat.lo
  CC       libtoolame-dab/libtoolame_dab_la-toolame.lo
  CC       libtoolame-dab/libtoolame_dab_la-portableio.lo
  CC       libtoolame-dab/libtoolame_dab_la-psycho_n1.lo
  CC       libtoolame-dab/libtoolame_dab_la-psycho_0.lo
  CC       libtoolame-dab/libtoolame_dab_la-psycho_1.lo
  CC       libtoolame-dab/libtoolame_dab_la-psycho_2.lo
  CC       libtoolame-dab/libtoolame_dab_la-psycho_3.lo
  CC       libtoolame-dab/libtoolame_dab_la-psycho_4.lo
  CC       libtoolame-dab/libtoolame_dab_la-fft.lo
  CC       libtoolame-dab/libtoolame_dab_la-subband.lo
  CC       libtoolame-dab/libtoolame_dab_la-bitstream.lo
  CC       libtoolame-dab/libtoolame_dab_la-mem.lo
  CC       libtoolame-dab/libtoolame_dab_la-crc.lo
  CC       libtoolame-dab/libtoolame_dab_la-tables.lo
  CC       libtoolame-dab/libtoolame_dab_la-availbits.lo
  CC       libtoolame-dab/libtoolame_dab_la-ath.lo
  CC       libtoolame-dab/libtoolame_dab_la-encode_new.lo
  CC       libtoolame-dab/libtoolame_dab_la-utils.lo
  GEN      libtoolame-dab.la
clang: warning: argument unused during compilation: '-pthread'
clang: warning: argument unused during compilation: '-pthread'
clang: warning: argument unused during compilation: '-pthread'
duplicate symbol _glopts in:
    libtoolame-dab/.libs/libtoolame_dab_la-common.o
    libtoolame-dab/.libs/libtoolame_dab_la-encode.o
duplicate symbol _glopts in:
    libtoolame-dab/.libs/libtoolame_dab_la-common.o
    libtoolame-dab/.libs/libtoolame_dab_la-toolame.o
duplicate symbol _glopts in:
    libtoolame-dab/.libs/libtoolame_dab_la-common.o
    libtoolame-dab/.libs/libtoolame_dab_la-psycho_3.o
duplicate symbol _glopts in:
    libtoolame-dab/.libs/libtoolame_dab_la-common.o
    libtoolame-dab/.libs/libtoolame_dab_la-psycho_0.o
duplicate symbol _glopts in:
    libtoolame-dab/.libs/libtoolame_dab_la-common.o
    libtoolame-dab/.libs/libtoolame_dab_la-psycho_1.o
duplicate symbol _glopts in:
    libtoolame-dab/.libs/libtoolame_dab_la-common.o
    libtoolame-dab/.libs/libtoolame_dab_la-psycho_2.o
duplicate symbol _glopts in:
    libtoolame-dab/.libs/libtoolame_dab_la-common.o
    libtoolame-dab/.libs/libtoolame_dab_la-psycho_4.o
duplicate symbol _glopts in:
    libtoolame-dab/.libs/libtoolame_dab_la-common.o
    libtoolame-dab/.libs/libtoolame_dab_la-subband.o
duplicate symbol _glopts in:
    libtoolame-dab/.libs/libtoolame_dab_la-common.o
    libtoolame-dab/.libs/libtoolame_dab_la-availbits.o
duplicate symbol _glopts in:
    libtoolame-dab/.libs/libtoolame_dab_la-common.o
    libtoolame-dab/.libs/libtoolame_dab_la-encode_new.o
ld: 10 duplicate symbols for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [libtoolame-dab.la] Error 1
make: *** [all] Error 2
mpbraendli commented 7 years ago

One thing that might be wrong on principle is that the symbol glopts is defined in libtoolame-dab/options.h. This means that if you include that header from two C files, it would be defined twice. In commit d04c019ce (on the next branch) I have put extern options glopts in options.h and moved the declaration to toolame.c. Can you try again?

amuso commented 7 years ago

That fixed the duplicate symbols. Thanks!

To get it to compile fully I also needed to make the following tweaks:

Removed -ltr on line 476 in Makefile.in

fdk_aac may have obsoloted the usage of AOT_DABPLUS and TT_DABPLUS (see https://github.com/nu774/fdkaac/issues/23 so I got the variables from https://github.com/mstorsjo/fdk-aac/pull/48/files and libSYS/include/FDK_audio.h) so I added the following at line 200 in src/odr-audioenc.cpp:

int AOT_DABPLUS_AAC_LC = 135;
int AOT_DABPLUS_SBR = 136;
int AOT_DABPLUS_PS = 137;
int TT_DABPLUS = 13;
$ make
/Applications/Xcode.app/Contents/Developer/usr/bin/make  all-am
  CC       libtoolame-dab/libtoolame_dab_la-common.lo
  CC       libtoolame-dab/libtoolame_dab_la-encode.lo
  CC       libtoolame-dab/libtoolame_dab_la-ieeefloat.lo
  CC       libtoolame-dab/libtoolame_dab_la-toolame.lo
  CC       libtoolame-dab/libtoolame_dab_la-portableio.lo
  CC       libtoolame-dab/libtoolame_dab_la-psycho_n1.lo
  CC       libtoolame-dab/libtoolame_dab_la-psycho_0.lo
  CC       libtoolame-dab/libtoolame_dab_la-psycho_1.lo
  CC       libtoolame-dab/libtoolame_dab_la-psycho_2.lo
  CC       libtoolame-dab/libtoolame_dab_la-psycho_3.lo
  CC       libtoolame-dab/libtoolame_dab_la-psycho_4.lo
  CC       libtoolame-dab/libtoolame_dab_la-fft.lo
  CC       libtoolame-dab/libtoolame_dab_la-subband.lo
  CC       libtoolame-dab/libtoolame_dab_la-bitstream.lo
  CC       libtoolame-dab/libtoolame_dab_la-mem.lo
  CC       libtoolame-dab/libtoolame_dab_la-crc.lo
  CC       libtoolame-dab/libtoolame_dab_la-tables.lo
  CC       libtoolame-dab/libtoolame_dab_la-availbits.lo
  CC       libtoolame-dab/libtoolame_dab_la-ath.lo
  CC       libtoolame-dab/libtoolame_dab_la-encode_new.lo
  CC       libtoolame-dab/libtoolame_dab_la-utils.lo
  GEN      libtoolame-dab.la
clang: warning: argument unused during compilation: '-pthread'
clang: warning: argument unused during compilation: '-pthread'
clang: warning: argument unused during compilation: '-pthread'
  CXX      src/odr_audioenc-odr-audioenc.o
  CXX      src/odr_audioenc-FileInput.o
  CXX      src/odr_audioenc-AlsaInput.o
  CXX      src/odr_audioenc-JackInput.o
  CXX      src/odr_audioenc-VLCInput.o
  CC       src/odr_audioenc-encryption.o
  CC       src/odr_audioenc-utils.o
  CC       src/odr_audioenc-wavreader.o
  CC       contrib/fec/odr_audioenc-decode_rs_char.o
  CC       contrib/fec/odr_audioenc-encode_rs_char.o
  CC       contrib/fec/odr_audioenc-init_rs_char.o
  CXXLD    odr-audioenc
libtool: link: warning: `-no-install' is ignored for x86_64-apple-darwin13.4.0
libtool: link: warning: assuming `-no-fast-install' instead

I now have a working binary and libraries. Have not tested it with any input yet though.

$ ./odr-audioenc -V
Welcome to ODR-AudioEnc v1.2.0-12-geecb436-dirty, compiled at Jan  7 2017, 06:01:23
  http://opendigitalradio.org

No output URI defined
mpbraendli commented 7 years ago

Hi, The -lrt option probably has to be taken care of by a change to the configure.ac script. fdk-aac did obsolete the DAB+ AOTs because it never implemented them, your addition to odr-audioenc.cpp is unnecessary, because if you install Opendigitalradio/fdk-aac it will work properly. With upstream fdk-aac it will not work.