View previous topic - View next topic |
Author |
Message |
DrunkenCoder Demon Hunter
Joined: 29 May 2002 Posts: 559
|
Posted: Fri May 30, 2003 8:44 am Post subject: Allegro Mingw32 and STL |
[quote] |
|
I found this really annoying thing with allegro using mingw32
if I try to use any STL header I croaks because in some long winded
way they somehow manage to include windows.h
anyone know how to get around this (in a non intrusive way)? _________________ If there's life after death there is no death, if there's no death we never live. | ENTP
|
|
Back to top |
|
|
Bjorn Demon Hunter
Joined: 29 May 2002 Posts: 1425 Location: Germany
|
Posted: Fri May 30, 2003 7:46 pm Post subject: |
[quote] |
|
I might be having the same problem, when I decide to try to compile with MingW I get lots of errors about something BITMAP pointer redefinition related. But I'm using MSVC anyway, so it's not really a problem for me.
|
|
Back to top |
|
|
DrunkenCoder Demon Hunter
Joined: 29 May 2002 Posts: 559
|
Posted: Fri May 30, 2003 7:50 pm Post subject: |
[quote] |
|
Bjørn wrote: | I might be having the same problem, when I decide to try to compile with MingW I get lots of errors about something BITMAP pointer redefinition related. But I'm using MSVC anyway, so it's not really a problem for me. |
Right, thats precisly what I get and I figoured out that it's because
the STL headers in some weird way includes windows.h thereby
gettint the BITMAP redefinition...
I solved it by putting allegro in its own namespace. _________________ If there's life after death there is no death, if there's no death we never live. | ENTP
|
|
Back to top |
|
|
Jihgfed Pumpkinhead Stephen Hawking
Joined: 21 Jan 2003 Posts: 259 Location: Toronto, Canada
|
Posted: Fri May 30, 2003 10:02 pm Post subject: Winalleg to the Rescue |
[quote] |
|
Another way to solve it is to include winalleg right after allegro and before your stl include, like: Code: | #include <allegro.h>
#include <winalleg.h>
#include <vector>
using namespace std; |
At least, that works for me.
Does the namespace solution still work if you use a dll? Do you have to modify all the Allegro source files and recompile? I'd wanted to wrap allegro up before but I couldn't figure out just how to do it.
By the way, I've just started with MingGW after having used Borland's free compiler. Am I the only one who finds it slow as molasses? And does anyone know how to get rid of these damn "no new line at end of file" warnings?
|
|
Back to top |
|
|
DrunkenCoder Demon Hunter
Joined: 29 May 2002 Posts: 559
|
Posted: Fri May 30, 2003 10:18 pm Post subject: |
[quote] |
|
err, add a newline at the end of the file to get rid of the error ;)
and the way I did wrap allegro was
namespace allegro
{
#include
//some helpers and wrapper classes...
}
_________________ If there's life after death there is no death, if there's no death we never live. | ENTP
|
|
Back to top |
|
|
DrV Wandering Minstrel
Joined: 15 Apr 2003 Posts: 148 Location: Midwest US
|
Posted: Fri May 30, 2003 11:59 pm Post subject: |
[quote] |
|
Hmm... I've used #include <string> with Allegro without problems and without importing winalleg.h (that would be very bad for cross-platform compatability, methinks ;), but I haven't used any other STL stuff yet with Allegro... I hope I don't have to do annoying hacks later.
If you put allegro in its own namespace, do you have to say "allegro.load_bitmap()" or "allegro.create_bitmap()" etc. when you're using the Allegro functions? I haven't used namespaces except in VB.NET (n00b is me :( ) _________________ Don't ask no stupid questions and I won't send you away.
If you want to talk fishing, well, I guess that'll be okay.
|
|
Back to top |
|
|
Jihgfed Pumpkinhead Stephen Hawking
Joined: 21 Jan 2003 Posts: 259 Location: Toronto, Canada
|
Posted: Sat May 31, 2003 12:36 am Post subject: Ming and STL and namespaces and such. |
[quote] |
|
dandelion wrote: | err, add a newline at the end of the file to get rid of the error ;) |
Gee, thanks. Really, is there a command-line option to get rid of these warnings? It's such a bother, and I don't understand its purpose, either, which makes it all the worse.
Regarding wrapping a library in a namespace, looks like I was making the problem a lot more complex than it needed to be. Thanks.
DrV wrote: | I've used #include <string> with Allegro without problems... |
Well, the problem's just with MinGW. Or maybe string doesn't count as real STL? Try including vector or something like that, and if it still works, and you're using ming, the computer gods must favour you. Congrats!
DrV wrote: | If you put allegro in its own namespace, do you have to say "allegro.load_bitmap()"... |
You access a namespace the same way you get into a class, with "::". So it's "allegro::load_bitmap" etc. If that's annoying, you can add the line "using namespace allegro;" and thereafter you can just do "load_bitmap" like normal. Um, I think.
|
|
Back to top |
|
|
BigManJones Scholar
Joined: 22 Mar 2003 Posts: 196
|
Posted: Sat May 31, 2003 2:24 am Post subject: |
[quote] |
|
<string.h> is a C standard lib so wouldn't <string> be the C++ equivalent? I looked thru my mingw include file and I didn't see an stl string header; there is std/ba_string...... hmmm
|
|
Back to top |
|
|
DrunkenCoder Demon Hunter
Joined: 29 May 2002 Posts: 559
|
Posted: Sat May 31, 2003 7:47 am Post subject: |
[quote] |
|
well the problems seems to be with all the collection types list vector set map multiset && multimap but wrapping it in its own namespace
get's rid of it and the syntax would be:
allegro::BITMAP *p = allegro::load_bitmap("bitmap.bmp");
note that you can't use:
useing namespace std;
because that would still give you the conflicting BITMAP definitions
but you can import a function or variable from a namespace using
this syntax:
using <namespace name>::
so to start to use allegro_message without typing allegro::allegro_message
you can do:
using allgegro::alegro_message; _________________ If there's life after death there is no death, if there's no death we never live. | ENTP
|
|
Back to top |
|
|
DrunkenCoder Demon Hunter
Joined: 29 May 2002 Posts: 559
|
Posted: Tue Jun 03, 2003 7:37 pm Post subject: |
[quote] |
|
oh, just another note I finally figoured out how to almost solve
it properly, the problem is that the STL that ships with mingw32
have some thread support disabling this fixes the problem.
Right now I had to edit a header by hand but there should
be a preprocessor command to disable it I just can't find
the right define. _________________ If there's life after death there is no death, if there's no death we never live. | ENTP
|
|
Back to top |
|
|
Bjorn Demon Hunter
Joined: 29 May 2002 Posts: 1425 Location: Germany
|
Posted: Tue Jun 03, 2003 7:39 pm Post subject: |
[quote] |
|
I'm very curious to any decent solution, as I haven't been able to get it working with any of the above solutions.
|
|
Back to top |
|
|
DrunkenCoder Demon Hunter
Joined: 29 May 2002 Posts: 559
|
Posted: Tue Jun 03, 2003 7:45 pm Post subject: |
[quote] |
|
hm... that sounds odd... I've got at least the namespace one working (obviously) and the headerhack is easy todo... just find the file called gthr.h or something like that you'll find it in the error message and identify the threading part and replace it with the path for single threaded stuff.. _________________ If there's life after death there is no death, if there's no death we never live. | ENTP
|
|
Back to top |
|
|
DrunkenCoder Demon Hunter
Joined: 29 May 2002 Posts: 559
|
Posted: Tue Jun 03, 2003 8:28 pm Post subject: |
[quote] |
|
a really temporary fix is to open the file c++config.h
find the line:
#define _GLIBCPP_HAVE_GTHR_DEFAULT 1
it's line #96 for me
and just comment it out...
the c++config.h file is supposedly automaticly generated but I have
no idea on how to override this :( argh!!!! _________________ If there's life after death there is no death, if there's no death we never live. | ENTP
|
|
Back to top |
|
|
DrunkenCoder Demon Hunter
Joined: 29 May 2002 Posts: 559
|
Posted: Tue Jun 03, 2003 9:17 pm Post subject: |
[quote] |
|
w00t! phear my leet header reading skillz!!!
add:
-D__GTHREAD_HIDE_WIN32API
to your C++ Compiler Options uner Project Settings
*phew*
that should make up for all my other brainfarts today =) _________________ If there's life after death there is no death, if there's no death we never live. | ENTP
|
|
Back to top |
|
|
Jihgfed Pumpkinhead Stephen Hawking
Joined: 21 Jan 2003 Posts: 259 Location: Toronto, Canada
|
Posted: Fri Jun 06, 2003 8:04 pm Post subject: Thanks for Ming/Allegro Solution |
[quote] |
|
Hey, thanks dandelion, that actually worked. I do indeed phear your leet header reading skillz. Henceforth, your name shall be forever enshrined within my all my Ming/Allegro makefiles.
Any idea about any problems this solution might incur in the future? I mean, if that define is best in all situations, it would be default, right?
|
|
Back to top |
|
|