I am still trying to learn C, SDL and AmigaOS4 SDK, so I will be doing strange things :)
But when I don't use -lphtread, I receive following errors:
ppc-amigaos-g++ -athread=native 10_color_keying.cpp -o 10_SDL -lSDL2 -lSDL2_image -ljpeg -lpng -ltiff -lwebp -lz /usr/local/amiga/ppc-amigaos/SDK/local/newlib/lib/libwebp.a(libwebpdsp_la-alpha_processing.o): In function `WebPInitAlphaProcessing': /home/Michael/libwebp-1.0.3/src/dsp/alpha_processing.c:412: undefined reference to `pthread_mutex_lock' /home/Michael/libwebp-1.0.3/src/dsp/alpha_processing.c:412: undefined reference to `pthread_mutex_unlock' /usr/local/amiga/ppc-amigaos/SDK/local/newlib/lib/libwebp.a(libwebpdsp_la-dec.o): In function `VP8DspInit': /home/Michael/libwebp-1.0.3/src/dsp/dec.c:744: undefined reference to `pthread_mutex_lock' /home/Michael/libwebp-1.0.3/src/dsp/dec.c:744: undefined reference to `pthread_mutex_unlock' /usr/local/amiga/ppc-amigaos/SDK/local/newlib/lib/libwebp.a(libwebpdsp_la-filters.o): In function `VP8FiltersInit': /home/Michael/libwebp-1.0.3/src/dsp/filters.c:241: undefined reference to `pthread_mutex_lock' /home/Michael/libwebp-1.0.3/src/dsp/filters.c:241: undefined reference to `pthread_mutex_unlock' /usr/local/amiga/ppc-amigaos/SDK/local/newlib/lib/libwebp.a(libwebpdsp_la-lossless.o): In function `VP8LDspInit': /home/Michael/libwebp-1.0.3/src/dsp/lossless.c:597: undefined reference to `pthread_mutex_lock' /home/Michael/libwebp-1.0.3/src/dsp/lossless.c:597: undefined reference to `pthread_mutex_unlock' /usr/local/amiga/ppc-amigaos/SDK/local/newlib/lib/libwebp.a(libwebpdsp_la-rescaler.o): In function `WebPRescalerDspInit': /home/Michael/libwebp-1.0.3/src/dsp/rescaler.c:205: undefined reference to `pthread_mutex_lock' /home/Michael/libwebp-1.0.3/src/dsp/rescaler.c:205: undefined reference to `pthread_mutex_unlock' /usr/local/amiga/ppc-amigaos/SDK/local/newlib/lib/libwebp.a(libwebpdsp_la-upsampling.o): In function `WebPInitYUV444Converters': /home/Michael/libwebp-1.0.3/src/dsp/upsampling.c:222: undefined reference to `pthread_mutex_lock' /home/Michael/libwebp-1.0.3/src/dsp/upsampling.c:222: undefined reference to `pthread_mutex_unlock' /usr/local/amiga/ppc-amigaos/SDK/local/newlib/lib/libwebp.a(libwebpdsp_la-upsampling.o): In function `WebPInitUpsamplers': /home/Michael/libwebp-1.0.3/src/dsp/upsampling.c:263: undefined reference to `pthread_mutex_lock' /home/Michael/libwebp-1.0.3/src/dsp/upsampling.c:263: undefined reference to `pthread_mutex_unlock' /usr/local/amiga/ppc-amigaos/SDK/local/newlib/lib/libwebp.a(libwebpdsp_la-yuv.o): In function `WebPInitSamplers': /home/Michael/libwebp-1.0.3/src/dsp/yuv.c:78: undefined reference to `pthread_mutex_lock' /home/Michael/libwebp-1.0.3/src/dsp/yuv.c:78: undefined reference to `pthread_mutex_unlock' /usr/local/amiga/ppc-amigaos/SDK/local/newlib/lib/libwebp.a(libwebpdsp_la-yuv.o): In function `WebPInitConvertARGBToYUV': /home/Michael/libwebp-1.0.3/src/dsp/yuv.c:263: undefined reference to `pthread_mutex_lock' /home/Michael/libwebp-1.0.3/src/dsp/yuv.c:263: undefined reference to `pthread_mutex_unlock' /usr/local/amiga/ppc-amigaos/SDK/local/newlib/lib/libwebp.a(thread_utils.o): In function `ChangeState': /home/Michael/libwebp-1.0.3/src/utils/thread_utils.c:238: undefined reference to `pthread_mutex_lock' /home/Michael/libwebp-1.0.3/src/utils/thread_utils.c:242: undefined reference to `pthread_cond_wait' /home/Michael/libwebp-1.0.3/src/utils/thread_utils.c:256: undefined reference to `pthread_mutex_unlock' /home/Michael/libwebp-1.0.3/src/utils/thread_utils.c:251: undefined reference to `pthread_mutex_unlock' /home/Michael/libwebp-1.0.3/src/utils/thread_utils.c:252: undefined reference to `pthread_cond_signal' /usr/local/amiga/ppc-amigaos/SDK/local/newlib/lib/libwebp.a(thread_utils.o): In function `End': /home/Michael/libwebp-1.0.3/src/utils/thread_utils.c:335: undefined reference to `pthread_join' /home/Michael/libwebp-1.0.3/src/utils/thread_utils.c:336: undefined reference to `pthread_mutex_destroy' /home/Michael/libwebp-1.0.3/src/utils/thread_utils.c:337: undefined reference to `pthread_cond_destroy' /usr/local/amiga/ppc-amigaos/SDK/local/newlib/lib/libwebp.a(thread_utils.o): In function `Reset': /home/Michael/libwebp-1.0.3/src/utils/thread_utils.c:287: undefined reference to `pthread_mutex_init' /home/Michael/libwebp-1.0.3/src/utils/thread_utils.c:290: undefined reference to `pthread_cond_init' /home/Michael/libwebp-1.0.3/src/utils/thread_utils.c:294: undefined reference to `pthread_mutex_lock' /home/Michael/libwebp-1.0.3/src/utils/thread_utils.c:295: undefined reference to `pthread_create' /home/Michael/libwebp-1.0.3/src/utils/thread_utils.c:297: undefined reference to `pthread_mutex_unlock' /home/Michael/libwebp-1.0.3/src/utils/thread_utils.c:299: undefined reference to `pthread_mutex_destroy' /home/Michael/libwebp-1.0.3/src/utils/thread_utils.c:300: undefined reference to `pthread_cond_destroy' /home/Michael/libwebp-1.0.3/src/utils/thread_utils.c:297: undefined reference to `pthread_mutex_unlock' /home/Michael/libwebp-1.0.3/src/utils/thread_utils.c:291: undefined reference to `pthread_mutex_destroy' /usr/local/amiga/ppc-amigaos/SDK/local/newlib/lib/libwebp.a(thread_utils.o): In function `ThreadLoop': /home/Michael/libwebp-1.0.3/src/utils/thread_utils.c:209: undefined reference to `pthread_mutex_lock' /home/Michael/libwebp-1.0.3/src/utils/thread_utils.c:211: undefined reference to `pthread_cond_wait' /home/Michael/libwebp-1.0.3/src/utils/thread_utils.c:224: undefined reference to `pthread_mutex_unlock' /home/Michael/libwebp-1.0.3/src/utils/thread_utils.c:225: undefined reference to `pthread_cond_signal' /home/Michael/libwebp-1.0.3/src/utils/thread_utils.c:224: undefined reference to `pthread_mutex_unlock' /home/Michael/libwebp-1.0.3/src/utils/thread_utils.c:225: undefined reference to `pthread_cond_signal' /home/Michael/libwebp-1.0.3/src/utils/thread_utils.c:224: undefined reference to `pthread_mutex_unlock' /home/Michael/libwebp-1.0.3/src/utils/thread_utils.c:225: undefined reference to `pthread_cond_signal'
Btw I tried compiling same source on Sam460 with SDK53.30 installed with gcc 4.2.4:
Is 4.2.4 not capable fo compiling SDL2 stuff ?
NTFS-USB1:SDLEXAMPLES> g++ 10_color_keying.cpp -o 10_SDL2 -lSDL2 -SDL2_image -ljpeg -lpng -ltiff -lwebp -lz -lpthread In file included from /gcc/lib/gcc/ppc-amigaos/4.2.4/../../../../include/c++/4.2.4/bits/stl_algobase.h:73, from /gcc/lib/gcc/ppc-amigaos/4.2.4/../../../../include/c++/4.2.4/bits/char_traits.h:46, from /gcc/lib/gcc/ppc-amigaos/4.2.4/../../../../include/c++/4.2.4/string:47, from 10_color_keying.cpp:8: /gcc/lib/gcc/ppc-amigaos/4.2.4/../../../../include/c++/4.2.4/ext/type_traits.h:41:19: error: /SDK/include/include_h/utility: Is a directory
And compiled it with g++ version 4.2.4 but didn't hit the same issue. bits/stl_algobase.h includes <utility> which is a header in the C++ standard library and also a directory in the AmigaOS 4 SDK but I don't understand how these get mixed up now.
What happens if you compile my 1-line example above?
And compiled it with g++ version 4.2.4 but didn't hit the same issue. bits/stl_algobase.h includes <utility> which is a header in the C++ standard library and also a directory in the AmigaOS 4 SDK but I don't understand how these get mixed up now.
In older adtools gcc ports the SDK include directories were before the gcc prefix include directories, which is probably why the SDK:include/include_h/utility directory is causing problems. This has been fixed in newer adtools gcc ports since it caused even more problems for C++ support with gcc 6 and later.
@Sinan That "assertion" error is wellknown crap of older gcc which in SDK. You can get rid of it by run "sh" and then compile things in.
The only was for now to deal with all this it use 8.4.0 adtools version, or what is better 10.0.2 one from Sodero's fork till it not merget to adtools repo.
I had the same assertion when compiling on "RAM Disk" but not when compiling on a "Test" partition. Could white space in "RAM Disk" have caused that issue?
/usr/local/amiga/ppc-amigaos/SDK/local/newlib/lib/libSDL2_mixer.a(mixer.o): In function `Mix_LoadWAV_RW': /home/Michael/SDL2_mixer-2.0.1/mixer.c:627: undefined reference to `SDL_LoadWAV_RW' /usr/local/amiga/ppc-amigaos/SDK/local/newlib/lib/libSDL2_mixer.a(dynamic_ogg.o): In function `Mix_InitOgg': /home/Michael/SDL2_mixer-2.0.1/dynamic_ogg.c:119: undefined reference to `ov_clear' /home/Michael/SDL2_mixer-2.0.1/dynamic_ogg.c:119: undefined reference to `ov_clear' /home/Michael/SDL2_mixer-2.0.1/dynamic_ogg.c:120: undefined reference to `ov_info' /home/Michael/SDL2_mixer-2.0.1/dynamic_ogg.c:120: undefined reference to `ov_info' /home/Michael/SDL2_mixer-2.0.1/dynamic_ogg.c:121: undefined reference to `ov_open_callbacks' /home/Michael/SDL2_mixer-2.0.1/dynamic_ogg.c:121: undefined reference to `ov_open_callbacks' /home/Michael/SDL2_mixer-2.0.1/dynamic_ogg.c:122: undefined reference to `ov_pcm_total' /home/Michael/SDL2_mixer-2.0.1/dynamic_ogg.c:122: undefined reference to `ov_pcm_total' /home/Michael/SDL2_mixer-2.0.1/dynamic_ogg.c:123: undefined reference to `ov_read' /home/Michael/SDL2_mixer-2.0.1/dynamic_ogg.c:123: undefined reference to `ov_read' /home/Michael/SDL2_mixer-2.0.1/dynamic_ogg.c:124: undefined reference to `ov_time_seek' /home/Michael/SDL2_mixer-2.0.1/dynamic_ogg.c:124: undefined reference to `ov_time_seek'
As you can see you need to place the corresponding libs after their "master" includes...so, image libs after -lSDL2_image and audio libs after -SDL2_mixer.
You should also always place -lpthread and -lz at the end of your linker line, as it will be used "globally" then and don't need to be repeated (if needed).
Thanks for the suggestion..I didn't know that linking order is important, but I still errors related to ogg.
/usr/local/amiga/ppc-amigaos/SDK/local/newlib/lib/libSDL2_mixer.a(dynamic_ogg.o): In function `Mix_InitOgg': /home/Michael/SDL2_mixer-2.0.1/dynamic_ogg.c:119: undefined reference to `ov_clear' /home/Michael/SDL2_mixer-2.0.1/dynamic_ogg.c:119: undefined reference to `ov_clear' /home/Michael/SDL2_mixer-2.0.1/dynamic_ogg.c:120: undefined reference to `ov_info' /home/Michael/SDL2_mixer-2.0.1/dynamic_ogg.c:120: undefined reference to `ov_info' /home/Michael/SDL2_mixer-2.0.1/dynamic_ogg.c:121: undefined reference to `ov_open_callbacks' /home/Michael/SDL2_mixer-2.0.1/dynamic_ogg.c:121: undefined reference to `ov_open_callbacks' /home/Michael/SDL2_mixer-2.0.1/dynamic_ogg.c:122: undefined reference to `ov_pcm_total' /home/Michael/SDL2_mixer-2.0.1/dynamic_ogg.c:122: undefined reference to `ov_pcm_total' /home/Michael/SDL2_mixer-2.0.1/dynamic_ogg.c:123: undefined reference to `ov_read' /home/Michael/SDL2_mixer-2.0.1/dynamic_ogg.c:123: undefined reference to `ov_read' /home/Michael/SDL2_mixer-2.0.1/dynamic_ogg.c:124: undefined reference to `ov_time_seek' /home/Michael/SDL2_mixer-2.0.1/dynamic_ogg.c:124: undefined reference to `ov_time_seek'
I can see them at vorbisfile.h from libvorbis at OS4Depot
extern int ov_clear(OggVorbis_File *vf); extern int ov_fopen(const char *path,OggVorbis_File *vf); extern int ov_open(FILE *f,OggVorbis_File *vf,const char *initial,long ibytes); extern int ov_open_callbacks(void *datasource, OggVorbis_File *vf, const char *initial, long ibytes, ov_callbacks callbacks);
extern int ov_test(FILE *f,OggVorbis_File *vf,const char *initial,long ibytes); extern int ov_test_callbacks(void *datasource, OggVorbis_File *vf, const char *initial, long ibytes, ov_callbacks callbacks); extern int ov_test_open(OggVorbis_File *vf);
extern long ov_bitrate(OggVorbis_File *vf,int i); extern long ov_bitrate_instant(OggVorbis_File *vf); extern long ov_streams(OggVorbis_File *vf); extern long ov_seekable(OggVorbis_File *vf); extern long ov_serialnumber(OggVorbis_File *vf,int i);
@Sinan There is very easy pattern to follow to fix all possible "undefined" errors on the linking stage.
You have your SDK directory in which we imagine you unpack all the stuff already (lots of 3d party libs, includes, etc from os4depot). Once you have any undefine , you do search in all your *.a files on that undefine. I.e. for search in all *.a files in whole SDK for "ov_clear". Find out then in which one : it will be or libogg.a, or libvorbis.a or libvorbisfile.a or something. Then, you need to know that linking order is matter : the *.a lib which ask for undefined symbold come first, then you add -l_lib_which_you_find. Usually that one will ALSO ask for some undefines, you search in which one, add it as well, etc, etc.
I.e. that just boring, routine work.
If you didn't find those undefined function names in your SDK, it then time to go on os4depot, and find out libs where they used. Offten can be understandable from the name of undefined functions. But if not, you then type in google "ov_read", and after few links will find out from where it comes => download/install to SDK => add on linking stage after library asking for undefs.
But most of us just use our strings workng everywhere most of time, like one Javier show.
What I mean, that the most important thing there to understand is that once you add linking with let's say SDL_Image, it will need image libs as well (libpng, libjpeg, libtiff,etc) and without will bring undefs. SDL_Mixer need sound/music libs as well: mikmod, flac, smpeg, and so on, and without will give undefs. Freetype library also needs few other libs. But basically, once you got that linking order is important and that its all "flat" (i.e. undefs in one library just fixed by adding necessary library after guilty one) everything will be easy.