Glue.cpp

BlitzMax Forums/Brucey's Modules/Glue.cpp

Tazzy(Posted 2011) [#1]
Hi,

I've tried downloading all modules and compiling them.
However, as soon as the folder contains an glue.cpp, the compilation fails. I don't get any specific error message when I use the latest version (4.5.0) of MinGW :

Compiling:glue.cpp
ar: creating C:/Blitz/BlitzMax/mod/bah.mod/base64.mod/base64.debug.win32.x86.a
Build Error: failed to compile C:/Blitz/BlitzMax/mod/bah.mod/box2d.mod/glue.cpp
Process complete

When I use an older version (3.4.5) in box2d it says something abouyt a clash of declarations between InterlockedExchange in a MinGW header file and this file.

Hope you can help...
Thanks in advance


xlsior(Posted 2011) [#2]
Did you copy ar.exe and ld.exe from your MinGW folder into the blitzmax/bin folder?

If not, you may be running into a version conflict.

You may also need to copy some additional library files from your MinGW install into blitzmax/lib -- check the forums for instructions on using different MinGW versions...


Brucey(Posted 2011) [#3]
Yep, you need to ensure that all the binaries for MinGW are also the same ones that are in the BlitzMax bin and lib dirs.
You may need to search for some of the libs in the MinGW dir structure, as they are spread out in several areas.

Once all the local files are up-to-date, it should build fine.


Tazzy(Posted 2011) [#4]
I still must be doing something wrong. I copied ar.exe and ld.exe to the bin folder, and copied every *.a and *.o file i could find to the Blitz lib folder, but I still get a build error on glue.cpp

I've installed the older version, so I could at least see a more informative error message (see below)

Any thoughts ?

ar: creating c:/Blitz/BlitzMax/mod/bah.mod/base64.mod/base64.debug.win32.x86.a
Compiling:glue.cpp
g++ -I"c:/Blitz/BlitzMax/mod/bah.mod/box2d.mod" -I"c:/Blitz/BlitzMax/mod" -I"c:/
Blitz/BlitzMax/mod/brl.mod/blitz.mod" -I"c:/Blitz/BlitzMax/mod/bah.mod/box2d.mod
/include" -w -march=pentium -ffast-math -fno-exceptions -c -o "c:/Blitz/BlitzMa
x/mod/bah.mod/box2d.mod/.bmx/glue.cpp.debug.win32.x86.o" "c:/Blitz/BlitzMax/mod/
bah.mod/box2d.mod/glue.cpp"
In file included from c:/MINGW/include/c++/3.2.3/bits/stl_alloc.h:90,
from c:/MINGW/include/c++/3.2.3/memory:55,
from c:/Blitz/BlitzMax/mod/bah.mod/box2d.mod/Source/Dynamics/b2
Body.h:27,
from c:/Blitz/BlitzMax/mod/bah.mod/box2d.mod/include/Box2D.h:42
,
from c:/Blitz/BlitzMax/mod/bah.mod/box2d.mod/glue.cpp:24:
c:/MINGW/include/c++/3.2.3/bits/stl_threads.h:57: declaration of C function `
long int InterlockedExchange(long int*, long int)' conflicts with
c:/MINGW/include/winbase.h:1686: previous declaration `LONG
InterlockedExchange(volatile LONG*, long int)' here
Build Error: failed to compile c:/Blitz/BlitzMax/mod/bah.mod/box2d.mod/glue.cpp


Brucey(Posted 2011) [#5]
From that output, you may have a bad installation of MinGW - usually you do not see MinGW conflicting with itself.
I would try either removing or moving your MINGW folder and installing the new version fresh - remember that exes and libs for different versions of MINGW are probably not compatible - as is shown by the files that ship with BlitzMax (which is based on a slightly older version of MINGW)


Tazzy(Posted 2011) [#6]
Hi,

Ik tried this again. This time checking all the options of MinGW, including the ada and fortran compiler. (Is used to only include the c compiler).
Now the glue.cpp seems to be passed, but later on I get the following errors
-----------------------------------------------------------------------
In file included from C:/Blitz/BlitzMax/mod/bah.mod/graphviz.mod/src/lib/common/arith.h:36:0,
from C:/Blitz/BlitzMax/mod/bah.mod/graphviz.mod/src/lib/common/geom.h:20,
from C:/Blitz/BlitzMax/mod/bah.mod/graphviz.mod/src/lib/common/types.h:25,
from C:/Blitz/BlitzMax/mod/bah.mod/graphviz.mod/src/lib/gvc/gvplugin_render.h:20,
from C:/Blitz/BlitzMax/mod/bah.mod/graphviz.mod/src/lib/gvc/gvrender.c:31:
C:/Blitz/BlitzMax/mod/bah.mod/graphviz.mod/src/lib/common/logic.h:32:23: error: two or more data types in declaration specifiers
Build Error: failed to compile C:/Blitz/BlitzMax/mod/bah.mod/graphviz.mod/src/lib/gvc/gvrender.c
Process complete
---------------------------------------------------
When I delete both graphviz.mod and graphvizmax.mod, libcurl.mod gives the same error etc, so it's no use removing those modules, since I will lose half of the functionality.

Any help would be appreciated.

Thanks in advance


Brucey(Posted 2011) [#7]
Believe it or not, it really isn't meant to be this difficult to set up MinGW to compile successfully.

Are you using the download versions of the modules or directly from the SVN repository?

I can try a clean install of everything and take notes of what I did to get everything set up. (if it doesn't work, then I'll probably be apologising much!)


xlsior(Posted 2011) [#8]
Believe it or not, it really isn't meant to be this difficult to set up MinGW to compile successfully.


That's what I thought too, until I tried to re-install it the other day. the older version were pretty straightforward, but it appears that the newer ones jumbled around a bunch of the include directories and such that are causing problems.

Got everything straightened out in the end, but it's definitely more complicated than it used to be.

(Maybe I should zip up my finally-working install + necessary environment variables to safe others the headache...)


Tazzy(Posted 2011) [#9]
Yes please... It's also not possible to get older versions from the MinGW site, so any help to get a working version is very much appreciated.

Thanks,

Serge


Brucey(Posted 2011) [#10]
This is the sequence I just used to do a clean install and build on Windows XP :


Download :

mingw-get-inst-20101030.exe  (gcc 4.50-1)

---------------------------------------

Run and Choose : C & C++ options.
Install to C:\MinGW

---------------------------------------

Download latest BlitzMax 1.41
Install to C:\BlitzMax

---------------------------------------

Set environment variables :
MINGW = C:\MinGW
PATH += C:\MinGW\bin

---------------------------------------

Copy files :

To C:\BlitzMax\bin

C:\MinGW\bin\ar.exe
C:\MinGW\bin\ld.exe


To C:\BlitzMax\lib

C:\MinGW\lib\gcc\mingw32\4.5.0\crtbegin.o
C:\MinGW\lib\gcc\mingw32\4.5.0\crtend.o
C:\MinGW\lib\gcc\mingw32\4.5.0\libgcc.a
C:\MinGW\lib\gcc\mingw32\4.5.0\libstdc++.a
C:\MinGW\lib\crt1.o
C:\MinGW\lib\crt2.o
C:\MinGW\lib\dllcrt1.o
C:\MinGW\lib\dllcrt2.o
C:\MinGW\lib\libadvapi32.a
C:\MinGW\lib\libcomctl32.a
C:\MinGW\lib\libcomdlg32.a
C:\MinGW\lib\libgdi32.a
C:\MinGW\lib\libglu32.a
C:\MinGW\lib\libkernel32.a
C:\MinGW\lib\libmingw32.a
C:\MinGW\lib\libmingwex.a
C:\MinGW\lib\libmoldname.a
C:\MinGW\lib\libmsimg32.a
C:\MinGW\lib\libmsvcrt.a
C:\MinGW\lib\libole32.a
C:\MinGW\lib\liboleaut32.a
C:\MinGW\lib\libopengl32.a
C:\MinGW\lib\libshell32.a
C:\MinGW\lib\libuser32.a
C:\MinGW\lib\libuuid.a
C:\MinGW\lib\libwinmm.a
C:\MinGW\lib\libws2_32.a
C:\MinGW\lib\libwsock32.a

---------------------------------------

Open CMD and cd to C:\BlitzMax\bin

Run :

bmk makemods



The last part you can do from the GUI through the option Build Modules.
I prefer the command-line.

I then copied BaH.Graphviz and build that in the same way...
... only to be told :
C:/BlitzMax/mod/bah.mod/graphviz.mod/src/lib/common/htmllex.c:25:19: fatal error: expat.h: No such file or directory

So I added BaH.expat and built again. (haw haw)

This time it went through cleanly and finished building graphviz.

...

To prove it is working, I also added BaH.graphvizmax2d, so that I could see something on the screen, then built and ran the example_01 demo from the graphviz module.
Success!

...

I hope this helps.


Brucey(Posted 2011) [#11]
I built with both the default "bmk" and my custom one. Interestingly, oggvorbis does not compile with -Os option (size), but builds fine without, or with -O3 (speed!) :-)


Brucey(Posted 2011) [#12]
I have to say, the file copying thing is a bit of a pain...

I've uploaded the specific files from the above-mentioned release and put them on my website :

bmx_mingwfiles_450.rar (1.2 meg)

This should hopefully save some time when it comes to finding the right files...
Simply unrar and drop the files into the relevant folders. (you may wish to backup the old ones first..)


xlsior(Posted 2011) [#13]
I made a batch script that uses grep and awk (Unix command line tools for windows) that automatically overwrite the existing files with the ones from mingw.

Now it's just a doubleclick to fix it.


Brucey(Posted 2011) [#14]
When I was learning AWK on unix (way back when), I wrote a curs-based network chess game in it, called chawk... it allowed different pts/tty sessions to play against each other... fun fun :-p

Last edited 2011


Tazzy(Posted 2011) [#15]
I start to feel really stupid :(
I did everything Brucey said, but I still get the compile error. The only difference I see is that the lib\gcc\mingw32\4.5.0 is 4.5.2 on my system even though the filename is exactly the same.

In my blitzmax folders are the following modules

brl.mod
pub.mod
maxgui.mod
blitz3d.mod
bah.mod
expat.mod
graphviz.mod
graphvizmax2d.mod

And I still get the following compile error:

In file included from C:/Blitz/BlitzMax/mod/bah.mod/graphviz.mod/src/lib/common/
arith.h:36:0,
from C:/Blitz/BlitzMax/mod/bah.mod/graphviz.mod/src/lib/common/
geom.h:20,
from C:/Blitz/BlitzMax/mod/bah.mod/graphviz.mod/src/lib/common/
types.h:25,
from C:/Blitz/BlitzMax/mod/bah.mod/graphviz.mod/src/lib/gvc/gvp
lugin_render.h:20,
from C:/Blitz/BlitzMax/mod/bah.mod/graphviz.mod/src/lib/gvc/gvr
ender.c:31:
C:/Blitz/BlitzMax/mod/bah.mod/graphviz.mod/src/lib/common/logic.h:32:23: error:
two or more data types in declaration specifiers
Build Error: failed to compile C:/Blitz/BlitzMax/mod/bah.mod/graphviz.mod/src/li
b/gvc/gvrender.c

Help ... :(


Tazzy(Posted 2011) [#16]
Also tried not pre-packaged and got version 4.5.0 that way, but still got the error :(


Brucey(Posted 2011) [#17]
You could try editing the src/lib/config.h file, and change this :
#ifndef WIN32
#define HAVE_BOOL 1
#endif

to this
//#ifndef WIN32
#define HAVE_BOOL 1
//#endif

and see what fate befalls you....

Last edited 2011


Tazzy(Posted 2011) [#18]
Yup... that's it... Finally... Thank you :)

Does this mean the Win32 directive isn't set in my compiler?
It's a 64 bit system with Windows 7, but this is hardly an exception nowadays if you ask me.


Tazzy(Posted 2011) [#19]
Finally found the cause of all of this.
I downloaded the source code from google code, but I noticed I missed some modules (like persistence.mod) so I found another mirror.

https://github.com/Htbaa/bah.mod

This code compiles almost without any problem.

Until now only raknetrooms.mod and xmlwriter.mod give compiletime errors. Everything else compiles :)


Tazzy(Posted 2011) [#20]
I spoke too soon... :( compiling now works.
However I did all of this to compile an example and now I when I run the example, I get the following errors during linking:

C:/Blitz/BlitzMax/mod/bah.mod/mathtoolkit.mod/mathtoolkit.debug.win32.x86.a(glue.cpp.debug.win32.x86.o):glue.cpp:(.text+0x9b85): undefined reference to `_Unwind_Resume'

C:/Blitz/BlitzMax/mod/bah.mod/mathtoolkit.mod/mathtoolkit.debug.win32.x86.a(glue.cpp.debug.win32.x86.o):glue.cpp:(.text$_ZNKSt5ctypeIcE5widenEc[__ZNKSt5ctypeIcE5widenEc]+0x2e): undefined reference to `std::ctype<char>::_M_widen_init() const'

C:/Blitz/BlitzMax/mod/bah.mod/mathtoolkit.mod/mathtoolkit.debug.win32.x86.a(glue.cpp.debug.win32.x86.o):glue.cpp:(.text+0x56d2): undefined reference to `__cxa_get_exception_ptr'

And a lot more of these. :(

Any idea anyone ?


Brucey(Posted 2011) [#21]
_Unwind_Resume

This is a problem with your MinGW installation :-)

The second one.. appears to be a lib conflict somewhere in your MinGW installation.
Check that ld.exe etc in BlitzMax/bin are the matching ones for your MinGW version.


Brucey(Posted 2011) [#22]
The three mathtoolkit examples are building and linking fine here - using TDM 4.4 and my bmk...


xlsior(Posted 2011) [#23]
Brucey: Does raknetrooms rebuild without error for you on your PC as well?

its glue.cpp is giving me a 'conflicting declaration' error...


Tazzy(Posted 2011) [#24]
Still not working unfortunately :(

Tried the latest version of MinGW again and now loaded everything from the net. Copied ar.exe and ld.exe to the BlitzMax/bin folder and copied all libraries as instructed. Still builds, so the new sources are probably better.

Howerver still problems with references to Unwind_Resume.

C:/Blitz/BlitzMax/mod/bah.mod/mathtoolkit.mod/mathtoolkit.debug.win32.x86.a(glue.cpp.debug.win32.x86.o):glue.cpp:(.text+0x21b): undefined reference to `_Unwind_Resume'

etc...

Can anyone explain what this means

Because this page : http://refspecs.freestandards.org/LSB_1.3.0/gLSB/gLSB/baselib--unwind-resume.html

isn't really hellpfull.

I have no knowledge of gcc whatsoever. I'm a c# programmer in my day job. Never any c or c++.


Ole JR(Posted 2011) [#25]
GCC currently supports two methods of stack frame unwinding: 
Dwarf-2 (DW2) or SJLJ (setjmp/longjmp). 

Until recently, only SJLJ has been available for the Windows platform. 

This affects you, the end user, primarily in programs that 
throw and catch exceptions. 
Programs which utilize the DW2 unwind method generally execute more quickly
than programs which utilize the SJLJ method, because the DW2 method incurs
no runtime overhead until an exception is thrown.


http://www.blitzbasic.com/Community/posts.php?topic=93692#1072696
Downloading that installer instead did the trick for me.

Follow Brucey's instructions some posts up, but also add:
import "-lstdc++"
import "-lgcc"
to brl.mod/blitz.mod/blitz.bmx before you rebuild all modules.


xlsior(Posted 2011) [#26]
Perhaps those imports should be added to the blitzmax modules in the next update. :-?


Ole JR(Posted 2011) [#27]
Well, it fixed the error I was getting, until I used Framework.
Then I had to add those two line in the top of my own source instead.

So what I ended up doing instead was editing the bmk source,
and moved those two '-lstdc++' and '-lgcc' first in line when linking.
Seem to do the trick, although not very well tested.

For those interested, it's around line 310 in bmk_util.bmx..


Brucey(Posted 2011) [#28]
I'm pretty sure my bmk_ng changes the link order too - because of problems I found with mingw builds on Linux and Mac.


Ole JR(Posted 2011) [#29]
If only I could get bmk_ng to work..

For some strange, unknown reason it fails to build modules here on my machine :-P

If I'm not mistaken it should be done like this?
* compile bmk.bmx (release, with/without threads, no-gui)
* copy/rename to bmk.exe
* also copy core.bmk and build.bmk to Blitzmax/bin

If I do like that all I get is this when trying to rebuild all modules:

'Build Error: failed to compile (2) C:/Program Files (x86)/BlitzMax/mod/brl.mod/blitz.mod/blitz_app.c'

Update:
if I try to build bmk through the cmd with -v added I get:
Compiling:bmk_config.bmx

/usr/bin/wine "C:/Program Files (x86)/BlitzMax/bin/bcc.exe" -g x86 -v -r -f brl.basic -o "C:/Program Files (x86)/BlitzMax/src/bmk_ng/.bmx/bmk_config.bmx.release.win32.x86.s"

But eh, why on earth do it add /usr/bin/wine? I'm on win7 x64..

Last edited 2011


Brucey(Posted 2011) [#30]
That sounds about right...

make.bmk
- contains lua implementations of some of the max bmk.

core.bmk
- just some helper functions

custom.bmk
- you can add this to override various build options, like compiling specifically for sse processors, etc.

There's not much to it really.

The thread version just builds multiple c/c++ files in parallel, which saves a LOT of time with some of the larger modules.

I find the custom build options of most use. Where you get some people hand-copying stuff into app bundles all the time, I'm afraid I just don't have the patience, and rather have the build do everything for me (including setting icons etc).

Not sure why it wouldn't build anything for you though...


Brucey(Posted 2011) [#31]
Oh, don't use config.bmk... it's for cross-compiling only.


Ole JR(Posted 2011) [#32]
Well, I didn't copy the config.bmk,
but when building with cmd inside the bmk_ng source folder
bmk_ng used the one inside that folder..

And guess where I was when trying to build modules too :-)

After cd'ing out of the sourcefolder/removing config.bmk things are working.
Except I still can't build bmk_ng with cmd,
permision denied when trying to open outputfile bmk.exe.
Oh well, can't have it all. Builds fine through the ide.

Last edited 2011