raysan5 / raylib

A simple and easy-to-use library to enjoy videogames programming
http://www.raylib.com
zlib License
23.05k stars 2.3k forks source link

[raudio miniaudio] Unable to build raylib and miniaudio with tiny c compiler #3210

Closed Lucas-Marcel closed 1 year ago

Lucas-Marcel commented 1 year ago

I was trying to implement miniaudio and libxmp with raylib, after a while i was able to build with gcc. I tried to do the same, but now using tiny c and i ran into many issues: the first ones was getting those errors: tcc: error:

undefined symbol 'ma_get_bytes_per_sample' tcc: error: undefined symbol 'ma_offset_pcm_frames_ptr' tcc: error: undefined symbol 'ma_offset_pcm_frames_const_ptr' tcc: error: undefined symbol 'ma_device_config_init' tcc: error: undefined symbol 'ma_device_init' tcc: error: undefined symbol 'ma_device_start' tcc: error: undefined symbol 'ma_device_uninit'

It appears that libraylib.def doesn't have those functions and etc in it, so tiny c can't locate them and throw these errors And if i enable #define MINIAUDIO_IMPLEMENTATION that would generate other errors, causing conflicts, cause it's already in raylib and there's no need to add it.

So i was reading raudio header file and i found these lines of code :

if defined(_WIN32)

// To avoid conflicting windows.h symbols with raylib, some flags are defined // WARNING: Those flags avoid inclusion of some Win32 headers that could be required // by user at some point and won't be included... //------------------------------------------------- There are a few #defines (flags) so i enabled all the flags and could finally build with tiny c and even add: #define MINIAUDIO_IMPLEMENTATION to my code and it would still build my project, so after a lot of trials and errors i realized that the only flag that i should Enable was: #define NOGDI. So i could finally run my app, but it had a lot of bugs, like: my up and down keys wouldn't work, i use them to increase and decrease volume in my app. also i was using my cmd to debug a few things like volume intensity, but it would generate an infinite loop that would print my volume on my console whindow while my app was running. So i decided to look into miniaudio's project and there was a split folder which contains: miniaudio .c and .h header file, i decided to build a miniaudio lib out of it, so i could have a miniaudio.dll file, after doing that i did set up everything and could build my project with tiny c with no issues, but it would have the same bugs, even removing #define NOGDI from my code. I'm sure the issue is with raylib, cause i was able to build the same project without raylib with no issues. So after trying many things, even disable raylib's audio when configuring my project in cmake, but it would still give me the same issues. In the end i was able to build my project with mingw gcc and it works perfectly, but i can't do the same with tiny c without having bugs in my app.

raysan5 commented 1 year ago

@Lucas-Marcel I'm afraid TinyC compiler is not a supported compiler anymore for raylib. Feel free to investigate the issue.

Peter0x44 commented 1 year ago

I'm not using windows, however, I am able to compile raylib using tcc without issues, using the command: make CC=tcc AR="tcc -ar" I could then link and use this libraylib.a without issues

Peter0x44 commented 1 year ago

I would also note, that it is a very good idea to build tcc yourself the last release is several years old and has numerous bugs

Lucas-Marcel commented 1 year ago

@Peter0x44 i'm able to compile raylib with tcc. The issue is: i cant do that if i add miniaudio to my project. In fact i can do that after work arounds, but with bugs i told about earlier. I had issues trying to do that with miniaudio alone. But i fixed adding win32 libraries to tiny c. So my only issue is trying to make miniaudio and raylib to work together.

Peter0x44 commented 1 year ago

But raylib uses miniaudio? I don't get why you think it's something that you need to make work?

Lucas-Marcel commented 1 year ago

@Peter0x44 miniaudio is one of raylib's external libs, so it was supposed to work with. I think tiny c is the issue, cause i'm able to do that using gcc, it compiles flawlessly.

r124c41 commented 1 year ago

I'm thinking the point is that raylib uses miniaudio inraudio. So including it separately doesn't seem to make sense. If you want to use miniaudio standalone, it is better to get it from the miniaudio project and then report any issues there. Externals are not maintained on raylib. They are not touched, although each raylib release may use a latest version of miniaudio available at the time of release.

Lucas-Marcel commented 1 year ago

@r124c41 indeed it does, but it seems to be a pretty basic implementation. I was told to use miniaudio.h for multi-channel mix controll, and this is the only way my code will compile. i tried to build raylib in many ways, like disabling Raudio, but i'm still getting the same bugs. The fact is i can make miniaudio work stand alone, the issue is whenever i add raylib. So for now im using gcc to compile my project instead of tiny c

Lucas-Marcel commented 1 year ago

I think i'm being dumb, i think there's a way to do that using raudio, but i'm confused now.

Lucas-Marcel commented 1 year ago

ok, there's no way to make it work with raudio, so i decided to drop miniaudio and use portaudio, plus get rid of rayaudio, Now i can take care of the audio stuff using portaudio.

Lucas-Marcel commented 1 year ago

Ok. I fixed my issue by: removing raudio from my raylib build and using portaudio as my audio library. Now i can build with tiny c with no issue. But will only work with no bugs if i remove raudio (miniaudio backend). So that makes tiny c still viable for raylib in most cases. We have to take in consideration that my case is very specific. I was trying to use miniaudio libxmp and raylib in the same code. This doesnt mean you cant use raylib or even raylibs raudio with tiny c.