Compilation failing due to confliting definition in openal

Hello there,
I’ve been trying to build openFrameworks on my Alpine system.
Installing all the required packages, my compilation stops at the sound system:
My error log can be found here

ciel@alpine ~/o/s/linux> ./compileOF.sh
Compiling /home/ciel/of_v0.11.0_linux64gcc6_release/libs/openFrameworks/sound/ofOpenALSoundPlayer.cpp
g++ -g3 -DDEBUG -Wall -Werror=return-type -std=c++14 -DGCC_HAS_REGEX -DOF_USING_GTK -DOF_USING_MPG123 -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/uuid -I/usr/include/gstreamer-1.0 -I/usr/include/orc-0.4 -I/usr/include/AL -D_REENTRANT -I/usr/include/libdrm -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/fribidi -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/atk-1.0 -pthread -I/home/ciel/of_v0.11.0_linux64gcc6_release/libs/fmodex/include -I/home/ciel/of_v0.11.0_linux64gcc6_release/libs/glm/include -I/home/ciel/of_v0.11.0_linux64gcc6_release/libs/glm/include/glm -I/home/ciel/of_v0.11.0_linux64gcc6_release/libs/glm/include/glm/gtx -I/home/ciel/of_v0.11.0_linux64gcc6_release/libs/glm/include/glm/ext -I/home/ciel/of_v0.11.0_linux64gcc6_release/libs/glm/include/glm/detail -I/home/ciel/of_v0.11.0_linux64gcc6_release/libs/glm/include/glm/gtc -I/home/ciel/of_v0.11.0_linux64gcc6_release/libs/glm/include/glm/simd -I/home/ciel/of_v0.11.0_linux64gcc6_release/libs/json/include -I/home/ciel/of_v0.11.0_linux64gcc6_release/libs/kiss/include -I/home/ciel/of_v0.11.0_linux64gcc6_release/libs/pugixml/include -I/home/ciel/of_v0.11.0_linux64gcc6_release/libs/tess2/include -I/home/ciel/of_v0.11.0_linux64gcc6_release/libs/utf8/include -I/home/ciel/of_v0.11.0_linux64gcc6_release/libs/utf8/include/utf8 -I/home/ciel/of_v0.11.0_linux64gcc6_release/libs/openFrameworks -I/home/ciel/of_v0.11.0_linux64gcc6_release/libs/openFrameworks/graphics -I/home/ciel/of_v0.11.0_linux64gcc6_release/libs/openFrameworks/gl -I/home/ciel/of_v0.11.0_linux64gcc6_release/libs/openFrameworks/events -I/home/ciel/of_v0.11.0_linux64gcc6_release/libs/openFrameworks/video -I/home/ciel/of_v0.11.0_linux64gcc6_release/libs/openFrameworks/sound -I/home/ciel/of_v0.11.0_linux64gcc6_release/libs/openFrameworks/utils -I/home/ciel/of_v0.11.0_linux64gcc6_release/libs/openFrameworks/3d -I/home/ciel/of_v0.11.0_linux64gcc6_release/libs/openFrameworks/types -I/home/ciel/of_v0.11.0_linux64gcc6_release/libs/openFrameworks/math -I/home/ciel/of_v0.11.0_linux64gcc6_release/libs/openFrameworks/communication -I/home/ciel/of_v0.11.0_linux64gcc6_release/libs/openFrameworks/app  -MMD -MP -MF /home/ciel/of_v0.11.0_linux64gcc6_release/libs/openFrameworksCompiled/lib/linux64/obj/Debug/libs/openFrameworks/sound/ofOpenALSoundPlayer.d -MT/home/ciel/of_v0.11.0_linux64gcc6_release/libs/openFrameworksCompiled/lib/linux64/obj/Debug/libs/openFrameworks/sound/ofOpenALSoundPlayer.o -o /home/ciel/of_v0.11.0_linux64gcc6_release/libs/openFrameworksCompiled/lib/linux64/obj/Debug/libs/openFrameworks/sound/ofOpenALSoundPlayer.o -c /home/ciel/of_v0.11.0_linux64gcc6_release/libs/openFrameworks/sound/ofOpenALSoundPlayer.cpp
In file included from /home/ciel/of_v0.11.0_linux64gcc6_release/libs/openFrameworks/sound/ofOpenALSoundPlayer.cpp:17:
/usr/include/AL/alc.h:34:16: error: using typedef-name 'ALCdevice' after 'struct'
   34 | typedef struct ALCdevice ALCdevice;
      |                ^~~~~~~~~
In file included from /home/ciel/of_v0.11.0_linux64gcc6_release/libs/openFrameworks/sound/ofOpenALSoundPlayer.cpp:1:
/home/ciel/of_v0.11.0_linux64gcc6_release/libs/openFrameworks/sound/ofOpenALSoundPlayer.h:13:33: note: 'ALCdevice' has a previous declaration here
   13 | typedef struct ALCdevice_struct ALCdevice;
      |                                 ^~~~~~~~~
In file included from /home/ciel/of_v0.11.0_linux64gcc6_release/libs/openFrameworks/sound/ofOpenALSoundPlayer.cpp:17:
/usr/include/AL/alc.h:34:26: error: conflicting declaration 'typedef int ALCdevice'
   34 | typedef struct ALCdevice ALCdevice;
      |                          ^~~~~~~~~
In file included from /home/ciel/of_v0.11.0_linux64gcc6_release/libs/openFrameworks/sound/ofOpenALSoundPlayer.cpp:1:
/home/ciel/of_v0.11.0_linux64gcc6_release/libs/openFrameworks/sound/ofOpenALSoundPlayer.h:13:33: note: previous declaration as 'typedef struct ALCdevice_struct ALCdevice'
   13 | typedef struct ALCdevice_struct ALCdevice;
      |                                 ^~~~~~~~~
In file included from /home/ciel/of_v0.11.0_linux64gcc6_release/libs/openFrameworks/sound/ofOpenALSoundPlayer.cpp:17:
/usr/include/AL/alc.h:36:16: error: using typedef-name 'ALCcontext' after 'struct'
   36 | typedef struct ALCcontext ALCcontext;
      |                ^~~~~~~~~~
In file included from /home/ciel/of_v0.11.0_linux64gcc6_release/libs/openFrameworks/sound/ofOpenALSoundPlayer.cpp:1:
/home/ciel/of_v0.11.0_linux64gcc6_release/libs/openFrameworks/sound/ofOpenALSoundPlayer.h:15:34: note: 'ALCcontext' has a previous declaration here
   15 | typedef struct ALCcontext_struct ALCcontext;
      |                                  ^~~~~~~~~~
In file included from /home/ciel/of_v0.11.0_linux64gcc6_release/libs/openFrameworks/sound/ofOpenALSoundPlayer.cpp:17:
/usr/include/AL/alc.h:36:27: error: conflicting declaration 'typedef int ALCcontext'
   36 | typedef struct ALCcontext ALCcontext;
      |                           ^~~~~~~~~~
In file included from /home/ciel/of_v0.11.0_linux64gcc6_release/libs/openFrameworks/sound/ofOpenALSoundPlayer.cpp:1:
/home/ciel/of_v0.11.0_linux64gcc6_release/libs/openFrameworks/sound/ofOpenALSoundPlayer.h:15:34: note: previous declaration as 'typedef struct ALCcontext_struct ALCcontext'
   15 | typedef struct ALCcontext_struct ALCcontext;
      |                                  ^~~~~~~~~~
make[1]: *** [makefileCommon/compile.core.mk:240: /home/ciel/of_v0.11.0_linux64gcc6_release/libs/openFrameworksCompiled/lib/linux64/obj/Debug/libs/openFrameworks/sound/ofOpenALSoundPlayer.o] Error 1
make: *** [makefileCommon/compile.core.mk:212: Debug] Error 2
there has been a problem compiling Debug OF library
please report this problem in the forums

Thank you for your help :slight_smile:

Hi Welcome to the forum!!

Hmm - that sounds like OpenAL on your system might be a newer version with a different typedef for those two structs. We’ll probably need to update the structs on our end going forward.

( the release of OpenAL with those changes was done 6 days ago - see: https://github.com/kcat/openal-soft/releases ).

A fix for this which we should do on our end ( and should work with both old and new releases ) should be:

Change these lines in https://github.com/openframeworks/openFrameworks/blob/master/libs/openFrameworks/sound/ofOpenALSoundPlayer.h#L12-L15:

typedef struct ALCdevice_struct ALCdevice;
/** Opaque context handle */
typedef struct ALCcontext_struct ALCcontext;

to:

struct ALCdevice;
struct ALCcontext;

This should be a forward declaration which is all that is needed for the header file.
The .cpp has the alc.h includes with the full define.

If that doesn’t work could you try changing those lines to:

typedef struct ALCdevice ALCdevice;
typedef struct ALCcontext ALCcontext;

@butterflyofsin - Hi, did either approach work for you?

Thanks,
Theo

I’m sorry I didn’t respond earlier, but yes. removing changing the typedef to just a struct declaration fixed my problem! Thank you very much.

1 Like