MaxMod2 breaking again

BlitzMax Forums/BlitzMax Programming/MaxMod2 breaking again

Ben Hurr(Posted 2013) [#1]
Does MaxMod2 break with every iteration of MinGW, or what?

I just updated to the lastest version of BlitzMax, update to latest MinGW with c++ compiler + dev toolkit, added environment variables etc

and now I'm getting 'NOT DEFINED IN SCOPE (fopen)' etc whenever I try to compile the module.

Has anyone got this working? Any tips?


GfK(Posted 2013) [#2]
Its a pain in the ass for sure. Im using mingw distro 8.2 from nuwen.net and its fine with that.


Ben Hurr(Posted 2013) [#3]
Are you sure? There doesn't seem to be a distro 8.2 there, just 8.0.

Edit: Tried 8.0, module compiles, but now I get 'can't find -ldsound' linker errors.
This is silly already.

Edit edit: I just noticed there is no ldsound library in BMax's lib folder; didn't there used to be one?


GfK(Posted 2013) [#4]
Do a forum search for ldsound. I always get that error too so I know theres a fix here somewhere.

[edit] Read from post #4 onwards.


Ben Hurr(Posted 2013) [#5]
I'll do that.

It's starting to make me wish I was knowledgable enough in C++ to just fix the module myself already though.

Edit: After searching around it seems the various linker errors are from using one set of object files compiled with one compiler with ones from another into the same program.
ie. mixing blitzmax's basic modules with the old maxmod2 module to make your game.

Maybe rebuilding everything from scratch, as in removing all the old compiler junk maxmod2 comes with, and recreating it all straight from the source files would work.

ps - I also noticed the latest version of BMax and the minGW version I was using both don't have ldsound in their libs folders, so that's not helping.


GfK(Posted 2013) [#6]
I too wish somebody would take up the gauntlet and whip MaxMod into shape. It's great, when it works.


Henri(Posted 2013) [#7]
Hello,

The "not defined in scope error" derives from not having "#include <stdio.h>" -statement in start of file "file.cpp". after that it should build ok. I tried running the given examples, but I get exception access violation. I then backtraced the cause to
"If t.Startup()" -statement t being object type TAudioDriver. Maybe missing something ?

-Henri


Ben Hurr(Posted 2013) [#8]
Thank you Henri, that's very helpful. Since the "#include <stdio.h>" problem is so common, perhaps someone should submit a minor revision to Maxmod2's code page? idk


Anyway, now I just get;

'Building PlayFolder
Compiling:PlayFolder.bmx
flat assembler version 1.69.14 (1005397 kilobytes memory)
3 passes, 8953 bytes.
Linking:PlayFolder.debug.exe
C:/BlitzMax/bin/ld.exe: cannot find -ldsound
Build Error: Failed to link C:/BlitzMax/mod/maxmod2.mod/examples/PlayFolder.debug.exe
Process complete'

Latest version of BlitzMax (1.48), latest GCC (4.7.2), libdsound.a is exactly where it should be in MinGW's installation. Perhaps I didn't set something up correctly?


edit:
I just checked MaxMod2's source in file.cpp, it does have the #include line where it should be. Weird.


Henri(Posted 2013) [#9]
I could recommend this to remedy MinGW-issues which I think this problem comes from.

-Henri


Ben Hurr(Posted 2013) [#10]
I'm going to try this.

But I have always wondered why you had to replace certain files in BMax's lib/bin folders with minGW's versions; shouldn't BMax just use them in place? (especially when it knows where that installation is)


Henri(Posted 2013) [#11]
Blitzmax uses it's own folders to search libraries and linker and such when compiling, but modules are build with ones in MinGW folder. So if they are from different distribution versions mismatch problems arise.

-Henri


*(Posted 2013) [#12]
Sometimes the way to get over that is to copy the files like ld.exe over the blitzmax ones, this doesnt always work though


Ben Hurr(Posted 2013) [#13]
Yeah it didn't work; now I'm getting a bazillion 'unreferenced _unwind' type errors.

From what I understand abount minGw, that is from trying to mix object files from different compiler types... but I rebuilt all the modules after doing the above steps all with the same compiler. So wha?


edit: I think I'm onto something here, all of my modules that aren't part of the 'normal' blitzmax module list don't work and spew out _unwind_resume errors when linking, while the basic modules don't. It's like they're being compiled with two different compilers when they really shouldn't. Perhaps there's things that need to be replaced in blitzmax\bin?


Ben Hurr(Posted 2013) [#14]
SOLUTION FOUND.

Use any minGW sjlj version, replace ar.exe/ld.exe and libs, all problems solved.

Which is confusing, because you're replacing all the linker/lib stuff that comes with BlitzMax from your minGW installation and rebuilding everything from sourcefiles... so it really shouldn't be possible to mix sjlj and DW2 stuff together here.

Although, the one file I haven't been able to replace is libunicows.a, because it isn't included with any newer minGW distribution that I've seen. What do you bet BMax's version is sjlj? :p


Zeke(Posted 2013) [#15]
i just deleted all libs from bmax/lib folder except libunicows.a.
then i deleted ar.exe and ld.exe from bmax/bin. (mingw/bin is in my PATH environment variable)
and im using bruceys bmk_ng and configured mingw/libs/include/ar/ld folders.

i'm not sure if this is a wise move. but it's working.
{i meant, this is working like before.. maxmod2 is not working.. :/ )


Henri(Posted 2013) [#16]
I can confirm that maxmod2 works with older version gcc (like nuwen 8.0 distro). Perhaps something to do with calling conventions ? I did get some ERROR_INSUFFICIENT_BUFFER (0000007A) debug information.


-Henri


Ben Hurr(Posted 2013) [#17]
Maybe.

I got my MaxMod2 stuff to compile and link properly, but trying to set a streaming driver causes it to spit out 'EXCEPTION_ACCESS_VIOLATION'.
I peeked into the debugger and found that the _succ field that should have a TAudioDriver in it is null, even though that driver is confirmed to exist by the program.
Of course, I've only tried this with the 'MaxMod RtAudio' driver so far.

This would be so much easier if REDi were still around. ):


Edit:
About Nuwen distro 8.0, does it use sjlj or DW2? It's pretty difficult to find out until stuff goes wrong.


Henri(Posted 2013) [#18]
It is from dwarf branch.

-Henri


Ben Hurr(Posted 2013) [#19]
sighhhhhh, Fuck.
Well, I'll try getting a TDM version of GCC 6.4.3 (same version as nuwen 8.0). Hopefully that works.

If it doesn't, perhaps I'll try brucey's modified BMK and hunting down a DW2 version of libunicows.a.

Edit:
SOLUTION!
For real this time.

>> Use nuwen.net minGW distribution 8.0 (gcc 6.4.3)
>> Get one of the newer versions of libunicows.a off sourceforge.net
>> Slap libunicows.a into your minGW lib folder
>> Copy ar.exe and ld.exe from 'minGW\bin' to your 'BlitzMax\bin' folder
>> Copy files from 'minGW\lib' and 'MinGW\lib\gcc\i686-pc-mingw32\4.6.3\' to 'BlitzMax\lib' (or just the ones that match the blitzmax libs, if you're picky)
>> Rebuild all modules
>> Suddenly, everything works properly!

Apparently it works because newer versions of GCC break MaxMod2 for reasons I haven't discovered yet, and because we're replacing all the static libs that come with BMax with versions that are compatible with the compiler.
(thus avoiding all that sjlj-doesn't-mix-with-DW2 bullshit)


Henri(Posted 2013) [#20]
You are persistant my friend, keep at it :-) . Just for clarity, Dwarf exception handling is the new way and silj is the old way.

-Henri


Zeke(Posted 2013) [#21]
^^ What Henri said.
Nuwen distro all the way


GfK(Posted 2013) [#22]
Just gone through a reinstall and hit ALL of these problems as per usual. :/

What I did:

1. Install MinGW distro 8 from nuwen.net.
2. Set up environment variables:

User variable:
MinGW = C:\MinGW

System variable:
existing Path var - add ;C:\MinGW\bin

Then copy ar.exe and ld.exe from C:\MinGW\bin to C:\Blitzmax\bin

Finally, copy libdsound.a from C:\MinGW\lib to C:\Blitzmax\lib

Rebuild all modules, bish bash bosh, job's a good 'un.

(Bet you anything this process doesn't work next time, though).


GfK(Posted 2013) [#23]
(Bet you anything this process doesn't work next time, though).

Well bugger me - it worked again!


xlsior(Posted 2013) [#24]
which MinGW are you using?

I noticed that the latest nuwen.net one now lists 'x64 native' in the functions.

I tried running it, but BMK kept throwing errors like these:

c:/Code/Blitzmax/mod/maxmod2.mod/dumb.mod/dumb/src/core/makeduh.c:1:0: error: CPU you selected does
not support x86-64 instruction set


(I'm not explicitly trying to do x64, but it appears that it's still defaulting to that or something?)


GfK(Posted 2013) [#25]
I'm using distro 8. Even though it's ancient, it works.


Kippykip(Posted 2016) [#26]
Sorry for bumping a really old thread, but the link for mingw-8.0 is dead.
Anybody still have a copy?


Kippykip(Posted 2016) [#27]
Got it working and found a much simpler way.
This will be the main link:
https://code.google.com/archive/p/maxmod/downloads

First get what ever version of maxmod (I got maxmod2_1.07.zip).

On the same page, download "MinGW.rar" extract it anywhere (C:\MinGW for myself). Set the paths if you have to.

Now use a text editor and open "C:\BlitzMax\mod\maxmod2.mod\maxmod2.mod\code\file.cpp" add
#include <stdio.h>
to the first line without the quotes, hit save.

Copy ar.exe and ld.exe from "C:\MinGW\bin" to "C:\BlitzMax\bin" and override.

Now copy "C:\MinGW\lib\libdsound.a" to "C:\BlitzMax\lib"
Rebuild all modules and hopefully it's all good!

Thanks everyone!


Derron(Posted 2016) [#28]
You could also use my lite variant - works with TDM 4.6. Or you use the one Brucey provides in its bmx-ng-repo (he made my lite-variant work with NG).


bye
Ron


xlsior(Posted 2016) [#29]
You could also use my lite variant - works with TDM 4.6. Or you use the one Brucey provides in its bmx-ng-repo (he made my lite-variant work with NG).


do you have a URL for both of those by any chance?


Derron(Posted 2016) [#30]
For NG: https://github.com/bmx-ng/maxmod2.mod

Mine: https://github.com/GWRon/Dig/blob/master/external/maxmod2_lite.mod.zip
(which is basically the one you already are using minus some modules I did not need - dumb and flac support).


bye
Ron


xlsior(Posted 2016) [#31]
Thanks!

Looks like I actually missed a few of the new NG mods (zeke, axe, mky), added them to my sync list.


Kippykip(Posted 2016) [#32]
Sweet as! I'll check them out when I get home!