![]() |
|
[A5] Will not compile; warning C4627 '#include <allegro.h>': skipped when lookin |
Molleby
Member #12,558
February 2011
|
As the topic says... I've followed the installation instructions for Allegro 5 and Visual C++ 2010 and tried to compile this code, as instructed: Quote: #define USE_CONSOLE however, I get this warning: warning C4627: '#include <allegro.h>': skipped when looking for precompiled header So, what could I have done wrong? |
Elias
Member #358
May 2000
|
Allegro 5 and Allegro 4 are two completely different libraries. To compile that code you want the latest Allegro 4, not Allegro 5. -- |
Molleby
Member #12,558
February 2011
|
Damn, you are of course right... Ok, I then tried with this... Quote: #include <allegro5/allegro.h> if(!al_init()) { display = al_create_display(640, 480); al_clear_to_color(al_map_rgb(0,0,0)); return 0; }
Now I get a bunch of errors: I just know I'm making some obviously stupid mistake |
X-G
Member #856
December 2000
![]() |
Quote: #include <stdAfx.h> //because the compiler asked me if I had remembered it Why are you using precompiled headers if you don't know how they work? Hint: The PCH must always be included first. But really, you're better off not using them if you don't know how they work. -- |
Molleby
Member #12,558
February 2011
|
I was in a hurry and didn't want to burden my brain with additional weight, so I just did what the compiler hinted at. And yes, I am a noob, or whatever its called Edit: do the error messages have something to do with an inability to link to the proper allegro library? |
X-G
Member #856
December 2000
![]() |
Nope, those are compiler errors. Linking is a later step. -- |
Molleby
Member #12,558
February 2011
|
I see. Will try and install it all again and see if something changes. |
Edgar Reynaldo
Major Reynaldo
May 2007
![]() |
All of the functions and symbols that were named in your errors belong to allegro5/allegro.h. So either your compiler didn't find allegro5/allegro.h due to it being in a different directory (not in your compiler's include directory) or you got a bad header somehow. It's most likely the first explanation. When you download the binaries, you need to : You can skip the first two steps if you set your project settings to use allegro/include as a search directory for your compiler, and to use allegro/lib as a linker search directory. You will also need to link to the appropriate link libraries. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
X-G
Member #856
December 2000
![]() |
Edgar Reynaldo said: It's most likely the first explanation. No, I already explained why. He put the PCH too late in the include chain. Everything before the PCH is ignored by the compiler. Allegro.h was never included. -- |
Edgar Reynaldo
Major Reynaldo
May 2007
![]() |
Oh, sorry about that. What's the reasoning behind that though? I mean, why do precompiled headers go first, and how would the compiler know they're precompiled if they still have a .h extension? My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
Thomas Fjellstrom
Member #476
June 2000
![]() |
Since the PCH comes first, it can ignore other headers that were part of the PCH? -- |
X-G
Member #856
December 2000
![]() |
Edgar Reynaldo said: I mean, why do precompiled headers go first, and how would the compiler know they're precompiled if they still have a .h extension? The compiler knows beforehand from the flags passed to it what the name of the PCH is (and there can only ever be at most one PCH). It expects it first because of how PCHs work by definition: the contents of the PCH is always available, in every compilation unit, before anything else in that compilation unit is looked at. The question you should be asking is "Why do I have to include the PCH at all if it's always present?" The answer is 1) explicit is better than implicit, and 2) it allows you disable use of the PCH and still have your program compile equivalently. -- |
Molleby
Member #12,558
February 2011
|
Ok, I reinstalled everything and put the monolith-static-mt-debug.lib (read that it would be easier) into Additional Dependencies. And I dropped the precompiled header. My codes now looks like this Quote: #include <allegro5/allegro.h> int main(int argc, char **argv) if(!al_init()) { display = al_create_display(640, 480); al_clear_to_color(al_map_rgb(0,0,0)); return 0; } I compile it and now I get these errors: Quote: LINK : error LNK2001: unresolved external symbol _mainCRTStartup Edit: I also tried to insert #define ALLEGRO_STATICLINK in the beginning of the code, but got the same errors |
LennyLen
Member #5,313
December 2004
![]() |
Try switching to a GUI (Win32) application instead of a Console application.
|
Molleby
Member #12,558
February 2011
|
Tried to switch to Win32 instead of Console Now the error message says: Quote: LINK : error LNK2001: unresolved external symbol _WinMainCRTStartup
|
torhu
Member #2,727
September 2002
![]() |
Almost looks like you've created a DLL or library project. Make sure it's a console project. |
Molleby
Member #12,558
February 2011
|
I'm 99% sure that I've created a proper console project. I've googled this problem A LOT (spent hours on this Maybe I should just give up on Visual 2010... what's a good substitute? |
Elias
Member #358
May 2000
|
Not sure, but maybe wrong libraries could cause this. Double check you downloaded the right file on http://www.allegro.cc/files/ (use MSVC 10 and not any of the others) and make sure you only added the allegro-5.0.0-monolith-mt-debug.lib (or allegro-5.0.0-monolith-mt.lib) to your linker settings and none of the other libraries. -- |
torhu
Member #2,727
September 2002
![]() |
I haven't got msvc 10 (still on 9), but if someone uploads a project config that you could use, that might fix the problem. Might be something funny with your msvc default project settings or something. EDIT: You could check that there's no UNICODE or _UNICODE #defines in the project settings (C/C++ -> Preprocessor). |
Molleby
Member #12,558
February 2011
|
I gave up on Visual 2010 and installed Code::Blocks. Works perfectly with Allegro 5. |
Elias
Member #358
May 2000
|
MSVC 10 definitely works as well. I downloaded A5 at work, selected 2010 project in cmake. Then opened the project with VC 2010 express and compiled. And had working examples. -- |
X-G
Member #856
December 2000
![]() |
It definitely works, my current home projects are all A5+MSVC10. -- |
|