473,386 Members | 1,679 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Trying to compile a program that uses the allegro library

hi there,

as i said i'm trying to compile a simple program that uses allegro, it's a small thing, indeed my goal was just to start using allegro, but until now i'm unable even to compile my simple program.

that's the program (i named it alle.c):

Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. #include <allegro.h>
  5.  
  6. #define MAX_X        800
  7. #define MAX_Y        600
  8. #define V_MAX_X        0
  9. #define V_MAX_Y        0
  10. #define COLOR_BITS    8
  11.  
  12. int inicia(void);
  13. void principal(void);
  14. void finaliza(void);
  15.  
  16. int main (void)
  17. {
  18.     if (!inicia())
  19.     {
  20.         finaliza();
  21.         return -1;
  22.     }
  23.  
  24.     principal();
  25.  
  26.     finaliza();
  27.     return 0;
  28. }
  29. END_OF_MAIN();
  30.  
  31. int inicia (void)
  32. {
  33.     allegro_init();
  34.  
  35.     install_keyboard();
  36.  
  37.     set_color_depth(COLOR_BITS);
  38.     if (set_gfx_mode(GFX_AUTODETECT, MAX_X, MAX_Y, V_MAX_X, V_MAX_Y) < 0)
  39.     {
  40.         printf("Erro ao inicializar o modo grafico.\n");
  41.         return (FALSE);
  42.     }
  43.  
  44.     set_palette(desktop_palette);
  45.  
  46.     return (TRUE);
  47. }
  48.  
  49. void principal (void)
  50. {
  51. }
  52.  
  53. void finaliza (void)
  54. {
  55.     allegro_exit();
  56. }
  57.  
i tried to compile it using gcc:
gcc -I/usr/include/ -o jogo alle.c -Wall -lalleg

but i received that error message:
/usr/bin/ld: cannot find -lalleg

I suspect that the error concerns to a missing library, but i'm not sure.

Can you confirm me that it was in fact a missing library and, if that's the case, wich library should i install, because i have no idea about what it is?

thanks
Feb 8 '07 #1
1 3373
AdrianH
1,251 Expert 1GB
i tried to compile it using gcc:
gcc -I/usr/include/ -o jogo alle.c -Wall -lalleg

but i received that error message:
/usr/bin/ld: cannot find -lalleg

I suspect that the error concerns to a missing library, but i'm not sure.

Can you confirm me that it was in fact a missing library and, if that's the case, wich library should i install, because i have no idea about what it is?

thanks
Your suspicions are correct. Here is copy from the gcc info pages. I've wrapped it in a html tag to keep the message in preformatted form, otherwise I would have put html pre tags around it.
[html]
`-lLIBRARY'
`-l LIBRARY'
Search the library named LIBRARY when linking. (The second
alternative with the library as a separate argument is only for
POSIX compliance and is not recommended.)

It makes a difference where in the command you write this option;
the linker searches and processes libraries and object files in
the order they are specified. Thus, `foo.o -lz bar.o' searches
library `z' after file `foo.o' but before `bar.o'. If `bar.o'
refers to functions in `z', those functions may not be loaded.

The linker searches a standard list of directories for the library,
which is actually a file named `libLIBRARY.a'. The linker then
uses this file as if it had been specified precisely by name.

The directories searched include several standard system
directories plus any that you specify with `-L'.

Normally the files found this way are library files--archive files
whose members are object files. The linker handles an archive
file by scanning through it for members which define symbols that
have so far been referenced but not defined. But if the file that
is found is an ordinary object file, it is linked in the usual
fashion. The only difference between using an `-l' option and
specifying a file name is that `-l' surrounds LIBRARY with `lib'
and `.a' and searches several directories.

...

`-LDIR'
Add directory DIR to the list of directories to be searched for
`-l'.
[/html]

What this says is that you do not have a library named liballeg.a in the library path. If it is in the current directory use -L. to search the current directory. That is -L dot. Otherwise, specify where the library file is and make sure it is there.

Hope this helps.


Adrian
Feb 8 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: me | last post by:
I have been looking online for a year, and cant find one. I used to use the int86() command in dos command-line mode, but it can't work in linux. I am using Allegro to make my program work, but I...
8
by: Rich Grise | last post by:
I think I've finally found a tutorial that can get me started: http://www.zib.de/Visual/people/mueller/Course/Tutorial/tutorial.html and I've been lurking for awhile as well. What happened is,...
17
by: newbiecpp | last post by:
I have hard time to understand run-time environment. Let assume that I have a program that has a simple variable alpha. When this variable is statically allocated, the compiler can use the...
3
by: Abby | last post by:
I'm now using Cygwin as my compiler for C code. I use Dev-c++ as my editor. The reason why I chose Cygwin compiler instead of the compiler that came with Dev-C++ is that I believe it uses the same...
0
by: Taran | last post by:
I am having this issue with both Visual C++ 6.0 and Visual Studio 2005 Beta 2. I have the SDK and DDK installed. I am trying to write a program to retrieve the EDID for a specific monitor in a...
6
by: Arthur | last post by:
I had two Visual Studio .NET C++ solutions that I combined into one. These project solutions were very similar. In fact, the two solutions were sharing many files. Now that they are one...
11
by: Marco | last post by:
Is there a standard way using the preprocessor to detect if a given C compiler/library environment provides the C99 <math.h> floating point functions such as: float powf(float x, float y);...
6
by: pkochanek | last post by:
Hi, my program is using both allegro.h and windows.h, but during compilling it i'm getting a lot of errors like "conflicts with previous declaration typedef struct BITMAP BITMAP". Problem is...
2
by: jai | last post by:
I want a c++ program to convert an array of pixel values into a 8-bit BMP file.i want the detail of how to write a common color palette for creating a 8-bit BMP file.
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.