ivansafrin/Polycode — pull request #163 by bope (2013-03-14 17:52:24+00:00)
Title: OpenAL examples build fails on Linux

[ 85%] Built target openal
Scanning dependencies of target alstream
[ 88%] Building C object CMakeFiles/alstream.dir/examples/alhelpers.o
[ 91%] Building C object CMakeFiles/alstream.dir/examples/alffmpeg.o
/home/peer/tmp/Polycode/Dependencies/Build/Debug/openal/src/openal/examples/alffmpeg.c: In function ‘MemData_seek’:
/home/peer/tmp/Polycode/Dependencies/Build/Debug/openal/src/openal/examples/alffmpeg.c:101:37: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
/home/peer/tmp/Polycode/Dependencies/Build/Debug/openal/src/openal/examples/alffmpeg.c:107:39: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
/home/peer/tmp/Polycode/Dependencies/Build/Debug/openal/src/openal/examples/alffmpeg.c:108:38: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
/home/peer/tmp/Polycode/Dependencies/Build/Debug/openal/src/openal/examples/alffmpeg.c:114:37: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
/home/peer/tmp/Polycode/Dependencies/Build/Debug/openal/src/openal/examples/alffmpeg.c: In function ‘openAVFile’:
/home/peer/tmp/Polycode/Dependencies/Build/Debug/openal/src/openal/examples/alffmpeg.c:176:9: warning: ‘av_close_input_file’ is deprecated (declared at /usr/include/libavformat/avformat.h:1680) [-Wdeprecated-declarations]
/home/peer/tmp/Polycode/Dependencies/Build/Debug/openal/src/openal/examples/alffmpeg.c: In function ‘openAVData’:
/home/peer/tmp/Polycode/Dependencies/Build/Debug/openal/src/openal/examples/alffmpeg.c:208:13: warning: ‘av_close_input_file’ is deprecated (declared at /usr/include/libavformat/avformat.h:1680) [-Wdeprecated-declarations]
/home/peer/tmp/Polycode/Dependencies/Build/Debug/openal/src/openal/examples/alffmpeg.c: In function ‘openAVCustom’:
/home/peer/tmp/Polycode/Dependencies/Build/Debug/openal/src/openal/examples/alffmpeg.c:243:13: warning: ‘av_close_input_file’ is deprecated (declared at /usr/include/libavformat/avformat.h:1680) [-Wdeprecated-declarations]
/home/peer/tmp/Polycode/Dependencies/Build/Debug/openal/src/openal/examples/alffmpeg.c: In function ‘closeAVFile’:
/home/peer/tmp/Polycode/Dependencies/Build/Debug/openal/src/openal/examples/alffmpeg.c:283:5: warning: ‘av_close_input_file’ is deprecated (declared at /usr/include/libavformat/avformat.h:1680) [-Wdeprecated-declarations]
/home/peer/tmp/Polycode/Dependencies/Build/Debug/openal/src/openal/examples/alffmpeg.c: In function ‘getAVAudioStream’:
/home/peer/tmp/Polycode/Dependencies/Build/Debug/openal/src/openal/examples/alffmpeg.c:338:13: warning: ‘avcodec_open’ is deprecated (declared at /usr/include/libavcodec/avcodec.h:3674) [-Wdeprecated-declarations]
/home/peer/tmp/Polycode/Dependencies/Build/Debug/openal/src/openal/examples/alffmpeg.c: In function ‘getAVAudioData’:
/home/peer/tmp/Polycode/Dependencies/Build/Debug/openal/src/openal/examples/alffmpeg.c:504:5: warning: ‘avcodec_decode_audio3’ is deprecated (declared at /usr/include/libavcodec/avcodec.h:3957) [-Wdeprecated-declarations]
[ 94%] Building C object CMakeFiles/alstream.dir/examples/alstream.o
Linking C executable alstream
/usr/bin/ld: CMakeFiles/alstream.dir/examples/alffmpeg.o: undefined reference to symbol 'av_malloc@@LIBAVUTIL_52'
/usr/bin/ld: note: 'av_malloc@@LIBAVUTIL_52' is defined in DSO /usr/lib/libavutil.so.52 so try adding it to the linker command line
/usr/lib/libavutil.so.52: could not read symbols: Invalid operation
collect2: error: ld returned 1 exit status
make[5]: *** [alstream] Error 1
make[4]: *** [CMakeFiles/alstream.dir/all] Error 2
make[3]: *** [all] Error 2
make[2]: *** [openal/src/openal-stamp/openal-build] Error 2
make[1]: *** [CMakeFiles/openal.dir/all] Error 2
make: *** [all] Error 2

Adding "-lavutil" to CMAKE_EXE_LINKER_FLAGS solved the error but caused the examples to link against the systems libavutil:

libopenald.so:
linux-vdso.so.1 (0x00007fffe7fff000)
librt.so.1 => /usr/lib/librt.so.1 (0x00007fd9e2f1e000)
libpthread.so.0 => /usr/lib/libpthread.so.0 (0x00007fd9e2d02000)
libdl.so.2 => /usr/lib/libdl.so.2 (0x00007fd9e2afe000)
libm.so.6 => /usr/lib/libm.so.6 (0x00007fd9e27ff000)
libc.so.6 => /usr/lib/libc.so.6 (0x00007fd9e2452000)
/usr/lib64/ld-linux-x86-64.so.2 (0x00007fd9e33b7000)
alstream:
linux-vdso.so.1 (0x00007fff8145f000)
libavutil.so.52 => /usr/lib/libavutil.so.52 (0x00007f301c8e9000)
libavcodec.so.54 => /usr/lib/libavcodec.so.54 (0x00007f301b97b000)
libavformat.so.54 => /usr/lib/libavformat.so.54 (0x00007f301b61c000)
libopenald.so.1 => /home/peer/tmp/Polycode/Dependencies/Build/Debug/openal/src/openal-build/libopenald.so.1 (0x00007f301b3b1000)
librt.so.1 => /usr/lib/librt.so.1 (0x00007f301b1a9000)
libpthread.so.0 => /usr/lib/libpthread.so.0 (0x00007f301af8d000)
libdl.so.2 => /usr/lib/libdl.so.2 (0x00007f301ad89000)
libm.so.6 => /usr/lib/libm.so.6 (0x00007f301aa8b000)
libc.so.6 => /usr/lib/libc.so.6 (0x00007f301a6de000)
libva.so.1 => /usr/lib/libva.so.1 (0x00007f301a4c7000)
libxvidcore.so.4 => /usr/lib/libxvidcore.so.4 (0x00007f301a1af000)
libx264.so.129 => /usr/lib/libx264.so.129 (0x00007f3019e60000)
libvpx.so.1 => /usr/lib/libvpx.so.1 (0x00007f3019bc0000)
libvorbisenc.so.2 => /usr/lib/libvorbisenc.so.2 (0x00007f30196f1000)
libvorbis.so.0 => /usr/lib/libvorbis.so.0 (0x00007f30194c4000)
libtheoraenc.so.1 => /usr/lib/libtheoraenc.so.1 (0x00007f3019286000)
libtheoradec.so.1 => /usr/lib/libtheoradec.so.1 (0x00007f301906b000)
libspeex.so.1 => /usr/lib/libspeex.so.1 (0x00007f3018e52000)
libschroedinger-1.0.so.0 => /usr/lib/libschroedinger-1.0.so.0 (0x00007f3018b86000)
libz.so.1 => /usr/lib/libz.so.1 (0x00007f3018970000)
libopus.so.0 => /usr/lib/libopus.so.0 (0x00007f3018730000)
libopenjpeg.so.1 => /usr/lib/libopenjpeg.so.1 (0x00007f3018508000)
libopencore-amrwb.so.0 => /usr/lib/libopencore-amrwb.so.0 (0x00007f30182f4000)
libopencore-amrnb.so.0 => /usr/lib/libopencore-amrnb.so.0 (0x00007f30180ca000)
libmp3lame.so.0 => /usr/lib/libmp3lame.so.0 (0x00007f3017e53000)
libgsm.so.1 => /usr/lib/libgsm.so.1 (0x00007f3017c48000)
librtmp.so.0 => /usr/lib/librtmp.so.0 (0x00007f3017a2c000)
libmodplug.so.1 => /usr/lib/libmodplug.so.1 (0x00007f301775b000)
libbluray.so.1 => /usr/lib/libbluray.so.1 (0x00007f301752d000)
libbz2.so.1.0 => /usr/lib/libbz2.so.1.0 (0x00007f301731d000)
/lib64/ld-linux-x86-64.so.2 (0x00007f301cb1b000)
libogg.so.0 => /usr/lib/libogg.so.0 (0x00007f3017117000)
liborc-0.4.so.0 => /usr/lib/liborc-0.4.so.0 (0x00007f3016e9c000)
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00007f3016b99000)
libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x00007f3016984000)
libssl.so.1.0.0 => /usr/lib/libssl.so.1.0.0 (0x00007f3016718000)
libcrypto.so.1.0.0 => /usr/lib/libcrypto.so.1.0.0 (0x00007f301630e000)
libxml2.so.2 => /usr/lib/libxml2.so.2 (0x00007f3015fb2000)
liblzma.so.5 => /usr/lib/liblzma.so.5 (0x00007f3015d8f000)
makehrtf:
linux-vdso.so.1 (0x00007fff1adff000)
libavutil.so.52 => /usr/lib/libavutil.so.52 (0x00007f006d4b0000)
libm.so.6 => /usr/lib/libm.so.6 (0x00007f006d1b2000)
libc.so.6 => /usr/lib/libc.so.6 (0x00007f006ce05000)
libpthread.so.0 => /usr/lib/libpthread.so.0 (0x00007f006cbe9000)
/lib64/ld-linux-x86-64.so.2 (0x00007f006d6e2000)
openal-info:
linux-vdso.so.1 (0x00007fff3fdff000)
libavutil.so.52 => /usr/lib/libavutil.so.52 (0x00007fe3eec57000)
libopenald.so.1 => /home/peer/tmp/Polycode/Dependencies/Build/Debug/openal/src/openal-build/libopenald.so.1 (0x00007fe3ee9ed000)
librt.so.1 => /usr/lib/librt.so.1 (0x00007fe3ee7e5000)
libpthread.so.0 => /usr/lib/libpthread.so.0 (0x00007fe3ee5c9000)
libdl.so.2 => /usr/lib/libdl.so.2 (0x00007fe3ee3c5000)
libm.so.6 => /usr/lib/libm.so.6 (0x00007fe3ee0c7000)
libc.so.6 => /usr/lib/libc.so.6 (0x00007fe3edd1a000)
/lib64/ld-linux-x86-64.so.2 (0x00007fe3eee89000)

I'm not that familiar with cmake but setting EXAMPLES to OFF in `CMake/openal.cmake` seems to be a better idea.