|
This thread is locked; no one can reply to it. |
1
2
|
Al_init is not defined |
Naugrim00
Member #16,829
March 2018
|
Hello everyone, I wanted to get into allegro for a project. So I installed allegro and put in the following code: 1#include "allegro5/allegro5.h"
2#include <iostream>
3#include "stdafx.h"
4
5int main(int argc, char** argv)
6{
7 al_init();
8
9 ALLEGRO_DISPLAY disp = al_create_display(100, 100);
10
11 return 0;
12}
But the problem is that I'm getting the following errors: 'al_init': identifier not found (r 7) Does anyone know how to fix this? |
Mark Oates
Member #1,146
March 2001
|
If you followed the typical pattern of installation, then your include line for allegro should use angled brackets <...>. -- |
Edgar Reynaldo
Major Reynaldo
May 2007
|
No, don't use angle brackets use quotes and it should be telling you the header was not found. It's allegro5/allegro.h . 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 |
Eric Johnson
Member #14,841
January 2013
|
Edgar Reynaldo said: No, don't use angle brackets use quotes What's wrong with using angle brackets?
|
Neil Roy
Member #2,229
April 2002
|
You have a couple problems: #include "allegro5/allegro5.h" should be: #include <allegro5/allegro5.h> The same is true for #include "stdafx.h", that should be #include <stdafx.h>. You should only use quotes for local files you are loading from the same folder your other game source code files are in. Also, your line; ALLEGRO_DISPLAY disp = al_create_display(100, 100); should be... `ALLEGRO_DISPLAY *disp = al_create_display(100, 100);` as al_create_display() returns a pointer. So in summary, this is what your code should look like... #include <allegro5/allegro5.h> #include <iostream> #include <stdafx.h> int main(int argc, char** argv) { al_init(); ALLEGRO_DISPLAY *disp = al_create_display(100, 100); return 0; }
--- |
Edgar Reynaldo
Major Reynaldo
May 2007
|
Nonono. Angle brackets are for system includes and you're all missing the point there's an extra 5 in his header include line. 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 |
Neil Roy
Member #2,229
April 2002
|
You're right about the extra 5, wrong about the angle brackets. The angle brackets indicate to load from the path in your setup. In my own setup in Code::Blocks I have added in a separate directory for library includes. So I use angle brackets for them. Quotes are used for local files which are not in your include path in your preferences etc. This is my includes for Allegro for my DP2 game; works just fine. #include <allegro5/allegro.h> #include <allegro5/allegro_font.h> #include <allegro5/allegro_ttf.h> #include <allegro5/allegro_native_dialog.h> #include <allegro5/allegro_image.h> #include <allegro5/allegro_primitives.h> #include <allegro5/allegro_physfs.h> #include <allegro5/allegro_audio.h> #include <allegro5/allegro_acodec.h> #include <allegro5/allegro_opengl.h> #include <physfs.h> So he just needs to remove the extra 5 and make certain the location of the library is in his include path. From MSDN... Quoted form Angle-bracket form --- |
Chris Katko
Member #1,881
January 2002
|
By your own post, it doesn't matter if he uses "" for system / allegro includes. But I've always been taught <> for sys libraries. "" For local. It just appears local, then searches system libs if it can't find it. -----sig: |
Neil Roy
Member #2,229
April 2002
|
You guys LOVE to argue and debate. LMFAO Hey, do what ever fucking works. Wow. --- |
Chris Katko
Member #1,881
January 2002
|
NO. ONLY DO IT MY WAY. EVERY ONE ELSE IS WRONG. -----sig: |
Mark Oates
Member #1,146
March 2001
|
Brackets <...> are what you should be using for your allegro includes. Your projects shouldn't be in your libs path and allegro (whatever version you're using) shouldn't be in your project's path. You're free to do it wrong if you want, of course. -- |
Edgar Reynaldo
Major Reynaldo
May 2007
|
No. Just no. Allegro should never be installed to your compiler or your system directories. Period. Which means it should be treated as a local file, with the include directory specified. 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 |
Neil Roy
Member #2,229
April 2002
|
Well sorry Edgar, but putting "PERIOD" in there doesn't make it final!!! My Allegro install is NOT IN MY COMPILER'S SYSTEM FOLDER! It is a totally separate folder! As should everyone else's if you want to avoid problems. In my own setup my compiler is in "C:\MINGW32", my libraries I add to my system like Allegro, SDL2 etc... are all in "C:\MINGW_DEV_LIBS". I use Code::Blocks as my IDE and on it,. I go to SETTINGS->COMPILER then select the "SEARCH DIRECTORIES" tab and add "C:\MinGW_Dev_Lib\include" to my "COMPILER" tab and "C:\MinGW_Dev_Lib\lib" to the "LINKER" tab which also contains the relavant "C:\MinGW32" folders. I then add Allegro 5 with: #include <allegro5/allegro.h> THAT is how you properly do it. You can also add in separate folders for your lib in a similar way for each project. There is a similar way to set this up with Visual Studio. I can't believe you don't know this. I think you just like to argue endlessly. --- |
Edgar Reynaldo
Major Reynaldo
May 2007
|
Okay Neil, answer this. How do you include cmath? Do you use quotes or brackets? I would hope your answer would be brackets, because it's a system library. How is Allegro a system library? So why should I use angle brackets? This is retarded but it works : Likewise this is retarded, but it works as well : #include <allegro5/allegro.h>
But the appropriate way to include a library in your code is to use quotes, unless it is a system library. 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 |
Dizzy Egg
Member #10,824
March 2009
|
I use square brackets, like: #include [allegro5/allegro]
which doesn't compile at all, but its my right to do what I want regardless of the correct way, so suck it.
---------------------------------------------------- |
GullRaDriel
Member #3,861
September 2003
|
Brackets are overrated. I just stares at my compilers until it reads in my mind the libs I want.
"Code is like shit - it only smells if it is not yours" |
Peter Hull
Member #1,136
March 2001
|
You could argue about this, or you could read the standard. Or you can do what Dizzy does, which at least is consistent across all known platforms.
|
LennyLen
Member #5,313
December 2004
|
Peter Hull said: You could argue about this, or you could read the standard. The standard says that there is no standard for what to do with either <> or "". It's implementation defined.
|
Edgar Reynaldo
Major Reynaldo
May 2007
|
Here's what gcc says... Quote: #include <file> This variant is used for system header files. It searches for a file named file in a standard list of system directories. You can prepend directories to this list with the -I option (see Invocation). #include "file" This variant is used for header files of your own program. It searches for a file named file first in the directory containing the current file, then in the quote directories and then the same directories used for <file>. You can prepend directories to the list of quote directories with the -iquote option. You can use whatever you want and it will work, but allegro is not a system header nor is it a system library, so it should not be treated as such. 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 |
Neil Roy
Member #2,229
April 2002
|
The reason why `#include ""` works, according to the standard is because when it fails (fails to find any local files), than it switches to the <> method. So the reason why quotes work for you is because according to the standard, it will use the angle brackets method when the quotes FAIL, which according to most of the standard implementation, it WILL fail every time as it will not find the file locally and so will switch to searching using the angle brackets method, which searches system folders where the compiler exists and any other you included in setup (which is what I do). But do it the way you wish, whatever, but don't sit there on your high horse saying "NO, JUST NO" every time someone is trying to HELP! --- |
Mark Oates
Member #1,146
March 2001
|
Dizzy Egg said: I use square brackets, like: which doesn't compile at all, but its my right to do what I want regardless of the correct way, so suck it. This is the correct answer -- |
Edgar Reynaldo
Major Reynaldo
May 2007
|
Now it looks like Obj-C ;P The point is, in the old days it was considered fine and fair practice to install everything into your compiler's bin,lib,and include directories. Today we know that's nonsense because that's how version mis-matches get created. Everything should be installed separately from your compiler. If it didn't come with your compiler, then chances are that it doesn't belong there. This also allows you to hot-swap versions of the libraries you use depending on a simple -I directive. The fact that both <> and "" search these folders doesn't matter. To be strict and fair, <> shouldn't search those folders. When you specify "" you are saying this file is NOT a system file, so categorically it shouldn't be searching in system directories! ;P 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 |
Chris Katko
Member #1,881
January 2002
|
I always use double white space to mean single quotes, and triple white space to mean double quotes, and then I have a pre-processor stage convert them at compile time. That way, I only have to use one key, space. It's way faster. -----sig: |
Eric Johnson
Member #14,841
January 2013
|
Chris Katko said: I always use double white space to mean single quotes, and triple white space to mean double quotes, and then I have a pre-processor stage convert them at compile time. That way, I only have to use one key, space. It's way faster. You might like the Whitespace programming language then.
|
Edgar Reynaldo
Major Reynaldo
May 2007
|
Okay smarty what does six spaces mean? 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 |
|
1
2
|