Post

Replies

Boosts

Views

Activity

Adapting old C++ Code to run on MacOS
First, I should mention that I am totally new to C++, so I apologize up front for my inexperience and improper use of terms, etc. I have some C++ code that a friend of mine wrote way back in the day (1998ish) that compiled and ran on Windows 98. It's a text based game that he did while in school. There is no urgency or purpose around me doing this other than I'm trying to learn. :-) I actually fired up a Windows 98 VM and ran the compiled executable that he had, and it ran fine. I would like to get this to compile and run on my Mac. I started by looking at the code and finding that some of the header files that are listed as includes aren't things that I have, or are Windows specific. So, I decided to take the approach of commenting out things in the code until I could get it to compile in Xcode and at least run at some level. Some of the things the code does is format the console text, and play wav files. After I commented out those specific things, it does seem to compile and run. Now I am taking the approach of trying to figure out how to reintegrate the things I commented out in a way that will run on MacOS. I'm tackling the playing of wav files first. I'm trying to implement SDL2 and SDL_mixer to do this. I've found some good tutorials that have shown me how to download the proper IMG file and copy things into /Library/Frameworks, and then how to set that up in Xcode. I've even been able to add the include directives (?) and the code will still compile without issue. Where I am running into issues now is trying to actually initialize SDL and play the file. I'm using code like this (this is from an example I found doing some searches): if (Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 2048) < 0) { // Handle error } Mix_Chunk* sound = Mix_LoadWAV("sounds/rm1.wav"); Mix_PlayChannel(-1, sound, 0); Mix_FreeChunk(sound); Mix_CloseAudio(); But when I compile the code, I'm getting these errors, even though it does actually compile and start running anyway: 2022-12-19 10:20:44.218888-0600 thecave[4476:94786] [plugin] AddInstanceForFactory: No factory registered for id <CFUUID 0x600000234020> F8BB1C28-BAE8-11D6-9C31-00039315CD46 2022-12-19 10:20:44.322404-0600 thecave[4476:95240] [aqsrv] AQServer.cpp:80 Exception caught in AudioQueueInternalNotifyRunning - error -66671 Does anyone have any idea why this is happening? Or maybe even a different way I should be trying to play wav files? Thanks so much!
2
0
643
Dec ’22