Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VS2015: "error C2011: 'timespec': 'struct' type redefinition" #13

Closed
cmdrf opened this issue Jun 7, 2015 · 10 comments
Closed

VS2015: "error C2011: 'timespec': 'struct' type redefinition" #13

cmdrf opened this issue Jun 7, 2015 · 10 comments

Comments

@cmdrf
Copy link

cmdrf commented Jun 7, 2015

It seems that VS2015 already has an implemention of struct timespec, so the one in threads.h causes said error message. I guess the macro _TIMESPEC_DEFINED is only defined in MinGW.

@kcat
Copy link
Owner

kcat commented Jun 7, 2015

Looks that way. Should be fixed now in commit ed3f32b, please let me know if there's still any issues.

@kcat kcat closed this as completed Jun 7, 2015
@cmdrf
Copy link
Author

cmdrf commented Jun 7, 2015

You're quick ;). I was currently testing fixes in my fork. I'll let you know how testing of both solutions turns out. Thanks!

@cmdrf
Copy link
Author

cmdrf commented Jun 7, 2015

It compiles fine on:

  • VS2013
  • VS2015
  • GCC on Debian 8.0
  • MinGW on Debian 8.0
  • OS X 10.10

Nice work!

@raysan5
Copy link

raysan5 commented Oct 4, 2016

Hi @kcat, I tried to compile OpenAL Soft with MinGW32 (GCC 5.3.0) and I still have this issue...

...
In file included from C:\openal-soft-master\common\rwlock.c:8:0:
C:/openal-soft-master/include/threads.h:38:8: error: redefinition of 'struct timespec'
 struct timespec {
        ^
In file included from C:/openal-soft-master/include/threads.h:4:0,
                 from C:\openal-soft-master\common\rwlock.c:8:
c:\mingw\include\time.h:102:8: note: originally defined here
 struct timespec
        ^
CMakeFiles\common.dir\build.make:112: recipe for target 'CMakeFiles/common.dir/common/rwlock.c.obj' failed
mingw32-make.exe[2]: *** [CMakeFiles/common.dir/common/rwlock.c.obj] Error 1
...

Is it possible to get it working with MinGW32 or should I definitely need to update to MinGW64? :)

@kcat
Copy link
Owner

kcat commented Oct 4, 2016

It should be possible to get working with MinGW32, assuming the compiler can otherwise handle OpenAL Soft. I just need to not be lazy and do a proper check for that struct, rather than try to guess based on some compiler-dependent macros.

@kcat
Copy link
Owner

kcat commented Oct 5, 2016

Commit bb6fba2 should fix that error with MinGW32.

@raysan5
Copy link

raysan5 commented Oct 9, 2016

Hi @kcat! Thank you very much for looking into this issue so quickly and excuse me for my late response.

When trying to build OpenAL Soft with the generated Makefile (cmake -G "MinGW Makefiles" -DLIBTYPE=STATIC ..), now I get the following errors:

C:\openal-soft-master\build>cmake --build .
Scanning dependencies of target common
[  1%] Building C object CMakeFiles/common.dir/common/almalloc.c.obj
[  3%] Building C object CMakeFiles/common.dir/common/atomic.c.obj
[  4%] Building C object CMakeFiles/common.dir/common/rwlock.c.obj
[  6%] Building C object CMakeFiles/common.dir/common/threads.c.obj
[  7%] Building C object CMakeFiles/common.dir/common/uintmap.c.obj
[  9%] Linking C static library libcommon.a
[  9%] Built target common
Scanning dependencies of target OpenAL32
[ 10%] Building C object CMakeFiles/OpenAL32.dir/common/almalloc.c.obj
[ 12%] Building C object CMakeFiles/OpenAL32.dir/common/atomic.c.obj
[ 13%] Building C object CMakeFiles/OpenAL32.dir/common/rwlock.c.obj
[ 15%] Building C object CMakeFiles/OpenAL32.dir/common/threads.c.obj
[ 16%] Building C object CMakeFiles/OpenAL32.dir/common/uintmap.c.obj
[ 18%] Building C object CMakeFiles/OpenAL32.dir/OpenAL32/alAuxEffectSlot.c.obj
In file included from c:\raylib\mingw\include\wchar.h:208:0,
                 from C:/openal-soft-master/Alc/alstring.h:42,
                 from C:/openal-soft-master/OpenAL32/Include/alMain.h:38,
                 from C:\openal-soft-master\OpenAL32\alAuxEffectSlot.c:28:
c:\raylib\mingw\include\sys/stat.h:173:14: error: unknown type name '_dev_t'
 struct _stat __struct_stat_defined( _off_t, time_t );
              ^
c:\raylib\mingw\include\sys/stat.h:173:14: error: unknown type name '_ino_t'
 struct _stat __struct_stat_defined( _off_t, time_t );
              ^
c:\raylib\mingw\include\sys/stat.h:173:14: error: unknown type name '_mode_t'
 struct _stat __struct_stat_defined( _off_t, time_t );
              ^
c:\raylib\mingw\include\sys/stat.h:173:14: error: unknown type name '_dev_t'
 struct _stat __struct_stat_defined( _off_t, time_t );
              ^
c:\raylib\mingw\include\sys/stat.h:173:14: error: unknown type name '_off_t'
 struct _stat __struct_stat_defined( _off_t, time_t );
              ^
c:\raylib\mingw\include\sys/stat.h:173:14: error: unknown type name 'time_t'
 struct _stat __struct_stat_defined( _off_t, time_t );
              ^
c:\raylib\mingw\include\sys/stat.h:173:14: error: unknown type name 'time_t'
 struct _stat __struct_stat_defined( _off_t, time_t );
              ^
c:\raylib\mingw\include\sys/stat.h:173:14: error: unknown type name 'time_t'
 struct _stat __struct_stat_defined( _off_t, time_t );
              ^
c:\raylib\mingw\include\sys/stat.h:180:13: error: unknown type name '_dev_t'
 struct stat __struct_stat_defined( _off_t, time_t );
             ^
c:\raylib\mingw\include\sys/stat.h:180:13: error: unknown type name '_ino_t'
 struct stat __struct_stat_defined( _off_t, time_t );
             ^
c:\raylib\mingw\include\sys/stat.h:180:13: error: unknown type name '_mode_t'
 struct stat __struct_stat_defined( _off_t, time_t );
             ^
c:\raylib\mingw\include\sys/stat.h:180:13: error: unknown type name '_dev_t'
 struct stat __struct_stat_defined( _off_t, time_t );
             ^
c:\raylib\mingw\include\sys/stat.h:180:13: error: unknown type name '_off_t'
 struct stat __struct_stat_defined( _off_t, time_t );
             ^
c:\raylib\mingw\include\sys/stat.h:180:13: error: unknown type name 'time_t'
 struct stat __struct_stat_defined( _off_t, time_t );
             ^
c:\raylib\mingw\include\sys/stat.h:180:13: error: unknown type name 'time_t'
 struct stat __struct_stat_defined( _off_t, time_t );
             ^
c:\raylib\mingw\include\sys/stat.h:180:13: error: unknown type name 'time_t'
 struct stat __struct_stat_defined( _off_t, time_t );
             ^
c:\raylib\mingw\include\sys/stat.h:188:17: error: unknown type name '_dev_t'
 struct _stati64 __struct_stat_defined( __off64_t, time_t );
                 ^
c:\raylib\mingw\include\sys/stat.h:188:17: error: unknown type name '_ino_t'
 struct _stati64 __struct_stat_defined( __off64_t, time_t );
                 ^
c:\raylib\mingw\include\sys/stat.h:188:17: error: unknown type name '_mode_t'
 struct _stati64 __struct_stat_defined( __off64_t, time_t );
                 ^
c:\raylib\mingw\include\sys/stat.h:188:17: error: unknown type name '_dev_t'
 struct _stati64 __struct_stat_defined( __off64_t, time_t );
                 ^
c:\raylib\mingw\include\sys/stat.h:188:17: error: unknown type name '__off64_t'
 struct _stati64 __struct_stat_defined( __off64_t, time_t );
                 ^
c:\raylib\mingw\include\sys/stat.h:188:17: error: unknown type name 'time_t'
 struct _stati64 __struct_stat_defined( __off64_t, time_t );
                 ^
c:\raylib\mingw\include\sys/stat.h:188:17: error: unknown type name 'time_t'
 struct _stati64 __struct_stat_defined( __off64_t, time_t );
                 ^
c:\raylib\mingw\include\sys/stat.h:188:17: error: unknown type name 'time_t'
 struct _stati64 __struct_stat_defined( __off64_t, time_t );
                 ^
c:\raylib\mingw\include\sys/stat.h:195:17: error: unknown type name '_dev_t'
 struct __stat64 __struct_stat_defined( __off64_t, __time64_t );
                 ^
c:\raylib\mingw\include\sys/stat.h:195:17: error: unknown type name '_ino_t'
 struct __stat64 __struct_stat_defined( __off64_t, __time64_t );
                 ^
c:\raylib\mingw\include\sys/stat.h:195:17: error: unknown type name '_mode_t'
 struct __stat64 __struct_stat_defined( __off64_t, __time64_t );
                 ^
c:\raylib\mingw\include\sys/stat.h:195:17: error: unknown type name '_dev_t'
 struct __stat64 __struct_stat_defined( __off64_t, __time64_t );
                 ^
c:\raylib\mingw\include\sys/stat.h:195:17: error: unknown type name '__off64_t'
 struct __stat64 __struct_stat_defined( __off64_t, __time64_t );
                 ^
c:\raylib\mingw\include\sys/stat.h:195:17: error: unknown type name '__time64_t' struct __stat64 __struct_stat_defined( __off64_t, __time64_t );
                 ^
c:\raylib\mingw\include\sys/stat.h:195:17: error: unknown type name '__time64_t' struct __stat64 __struct_stat_defined( __off64_t, __time64_t );
                 ^
c:\raylib\mingw\include\sys/stat.h:195:17: error: unknown type name '__time64_t' struct __stat64 __struct_stat_defined( __off64_t, __time64_t );
                 ^
In file included from c:\raylib\mingw\include\wchar.h:233:0,
                 from C:/openal-soft-master/Alc/alstring.h:42,
                 from C:/openal-soft-master/OpenAL32/Include/alMain.h:38,
                 from C:\openal-soft-master\OpenAL32\alAuxEffectSlot.c:28:
c:\raylib\mingw\include\io.h:335:21: error: unknown type name 'time_t'
 struct _wfinddata_t __struct_finddata_t (time_t, _fsize_t);
                     ^
c:\raylib\mingw\include\io.h:335:21: error: unknown type name 'time_t'
 struct _wfinddata_t __struct_finddata_t (time_t, _fsize_t);
                     ^
c:\raylib\mingw\include\io.h:335:21: error: unknown type name 'time_t'
 struct _wfinddata_t __struct_finddata_t (time_t, _fsize_t);
                     ^
c:\raylib\mingw\include\io.h:336:24: error: unknown type name 'time_t'
 struct _wfinddatai64_t __struct_finddata_t (time_t, __int64);
                        ^
c:\raylib\mingw\include\io.h:336:24: error: unknown type name 'time_t'
 struct _wfinddatai64_t __struct_finddata_t (time_t, __int64);
                        ^
c:\raylib\mingw\include\io.h:336:24: error: unknown type name 'time_t'
 struct _wfinddatai64_t __struct_finddata_t (time_t, __int64);
                        ^
c:\raylib\mingw\include\io.h:362:24: error: unknown type name '__time64_t'
 struct __wfinddata64_t __struct_finddata_t (__time64_t, __int64);
                        ^
c:\raylib\mingw\include\io.h:362:24: error: unknown type name '__time64_t'
 struct __wfinddata64_t __struct_finddata_t (__time64_t, __int64);
                        ^
c:\raylib\mingw\include\io.h:362:24: error: unknown type name '__time64_t'
 struct __wfinddata64_t __struct_finddata_t (__time64_t, __int64);
                        ^
CMakeFiles\OpenAL32.dir\build.make:187: recipe for target 'CMakeFiles/OpenAL32.dir/OpenAL32/alAuxEffectSlot.c.obj' failed
mingw32-make.exe[2]: *** [CMakeFiles/OpenAL32.dir/OpenAL32/alAuxEffectSlot.c.obj] Error 1
CMakeFiles\Makefile2:66: recipe for target 'CMakeFiles/OpenAL32.dir/all' failed
mingw32-make.exe[1]: *** [CMakeFiles/OpenAL32.dir/all] Error 2
Makefile:126: recipe for target 'all' failed
mingw32-make.exe: *** [all] Error 2

C:\openal-soft-master\build>

Maybe the problem is in MinGW32 libraries?

@kcat
Copy link
Owner

kcat commented Oct 9, 2016

Looks like a problem with your headers. OpenAL Soft is including the system's wchar.h, which is including the system's sys/stat.h and io.h which fail to recognize system types. That indicates the system headers aren't including or defining what they need to work.

@raysan5
Copy link

raysan5 commented Oct 9, 2016

Hi @kcat, thanks for your answer.

I investigated a bit on this issue and I got a solution based on this answer: http://stackoverflow.com/questions/38436542/mingw-cxxtest-bizarre-errors

Just replacing -std=c11 and -std=c99 by -std=gnu11 and -std=gnu99 does the trick but other errors pop up when compiling altonegen, related to multiple definition of _fpreset... it seems MinGW-w64 already take care of this issue, but not MinGW32.

Despite getting the libOpenAL32.a, when trying to link with my code, I get a bunch of undefined reference to errors:

c:/raylib/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../libraylib.a(audio.o):audio.c:(.text+0x656d): undefined reference to `alcOpenDevice'
c:/raylib/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../libraylib.a(audio.o):audio.c:(.text+0x6587): undefined reference to `alcCreateContext'
c:/raylib/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../libraylib.a(audio.o):audio.c:(.text+0x6595): undefined reference to `alcMakeContextCurrent'
c:/raylib/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../libraylib.a(audio.o):audio.c:(.text+0x65a1): undefined reference to `alcDestroyContext'
c:/raylib/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../libraylib.a(audio.o):audio.c:(.text+0x65a9): undefined reference to `alcCloseDevice'
c:/raylib/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../libraylib.a(audio.o):audio.c:(.text+0x65dc): undefined reference to `alcGetString'
c:/raylib/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../libraylib.a(audio.o):audio.c:(.text+0x6618): undefined reference to `alListener3f'
c:/raylib/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../libraylib.a(audio.o):audio.c:(.text+0x663c): undefined reference to `alListener3f'
c:/raylib/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../libraylib.a(audio.o):audio.c:(.text+0x6660): undefined reference to `alListener3f'
c:/raylib/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../libraylib.a(audio.o):audio.c:(.text+0x6696): undefined reference to `alcGetCurrentContext'
c:/raylib/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../libraylib.a(audio.o):audio.c:(.text+0x66a4): undefined reference to `alcGetContextsDevice'
c:/raylib/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../libraylib.a(audio.o):audio.c:(.text+0x66b2): undefined reference to `alcMakeContextCurrent'
c:/raylib/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../libraylib.a(audio.o):audio.c:(.text+0x66ba): undefined reference to `alcDestroyContext'
c:/raylib/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../libraylib.a(audio.o):audio.c:(.text+0x66c2): undefined reference to `alcCloseDevice'
...

I used #define AL_LIBTYPE_STATIC before #include "AL/al.h" and #include "AL/alc.h" and generated library build with cmake -G "MinGW Makefiles" -DLIBTYPE=STATIC ...

Am I missing any define or additional configuration?

@raysan5
Copy link

raysan5 commented Oct 14, 2016

Update on this issue: it seems I was trying to link with some other instance of libopenal32.a on my system. I managed to link OpenAL Soft statically with my program using MinGW32.

Just for reference, my example compile-link line is:

gcc -o audio_sound_loading.exe audio_sound_loading.c -L. -lraylib -lglfw3 -lopengl32 -lopenal32 -lwinmm -lgdi32 -std=c99 -Wl,-allow-multiple-definition

Note I must link also with libwinmm (working on Windows 10) and allow -Wl,-allow-multiple-definition

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants