Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411482 Posts in 69370 Topics- by 58426 Members - Latest Member: shelton786

April 23, 2024, 11:36:53 PM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)Couple of Allegro questions..
Pages: [1]
Print
Author Topic: Couple of Allegro questions..  (Read 3569 times)
Massena
Level 4
****


Satisfied.


View Profile
« on: December 05, 2007, 01:56:24 PM »

First of all, hi! :D I'm beginning to program in c++ using allegro and I ran into some early trouble. Sad You see, these two questions don't actually stop me from programming but they're just frustrating annoyances. First of all I'm running Mac OS 10.4 and these are my problems: How do you compile a small program with allegro on the command line, I mean, I've been using xCode but I like the command-line better for now Tongue so I tried "gcc example.cpp -framework Allegro" and it returns the oddest of bugs:
Code:
/usr/bin/ld: Undefined symbols:
_main
collect2: ld returned 1 exit status
(What the hell?)
Note that I can use the command line to compile pure c++ programs and xCode to compile allegro applications.
Secondly when I have to put a path in an allegro application I see many examples that just use "example.bmp" but the only way I can get it to work is by putting the full path even thought the file is in the same directory as the code. How could I make it so that I don't have to go around looking for full paths?
Anyways thanks very much in advance, congratulations for the great site!

Logged

Redwire
Level 0
*



View Profile
« Reply #1 on: December 05, 2007, 02:06:28 PM »

For the pathname did you use "example.bmp" or "./example.bmp"
and for the command-line problem I don't know about mac but you should try
gcc example.cpp -o example -lallegro

oh and welcome aboard
« Last Edit: December 05, 2007, 02:53:03 PM by Redwire » Logged

Programming for the mass
Ruby | Python | Lua
ravuya
Level 7
**


Yip yip yip yip yip


View Profile WWW
« Reply #2 on: December 05, 2007, 11:02:38 PM »

-framework will take care of the library linkage and include paths.

I think Allegro does something funky to the main function in your code; check the documentation for it or ask on the mailing list. IIRC, there's a macro you need to define.
Logged

Massena
Level 4
****


Satisfied.


View Profile
« Reply #3 on: December 06, 2007, 09:59:58 AM »

For the pathname did you use "example.bmp" or "./example.bmp"
and for the command-line problem I don't know about mac but you should try
gcc example.cpp -o example -lallegro

oh and welcome aboard

Thanks Smiley
I tried both, none worked and -lallegro doesn't seem to work Sad
-framework will take care of the library linkage and include paths.

I think Allegro does something funky to the main function in your code; check the documentation for it or ask on the mailing list. IIRC, there's a macro you need to define.

Hm.. I have no idea what could it could be doing since the same code works on xcode, using the same framework. As for macros, I have no clue on what are macros or how to define one.   Sad
Anyways thanks for the speedy response!

Logged

Zaphos
Guest
« Reply #4 on: December 06, 2007, 12:46:35 PM »

I think Allegro does something funky to the main function in your code; check the documentation for it or ask on the mailing list. IIRC, there's a macro you need to define.
I assume you're referring to END_OF_MAIN() which should appear after the body of the main() function.
Like:
Code:
int main()
{
 // etc
 return 0;
} END_OF_MAIN() // <-here
Logged
Massena
Level 4
****


Satisfied.


View Profile
« Reply #5 on: December 06, 2007, 02:27:28 PM »

I think Allegro does something funky to the main function in your code; check the documentation for it or ask on the mailing list. IIRC, there's a macro you need to define.
I assume you're referring to END_OF_MAIN() which should appear after the body of the main() function.

Why should END_OF_MAIN () be undefined, doesn't the library define it? I'll try alegro.cc's forums and I'll post back if I can solve this problem Smiley
Logged

Zaphos
Guest
« Reply #6 on: December 06, 2007, 02:55:11 PM »

I think Allegro does something funky to the main function in your code; check the documentation for it or ask on the mailing list. IIRC, there's a macro you need to define.
I assume you're referring to END_OF_MAIN() which should appear after the body of the main() function.

Why should END_OF_MAIN () be undefined, doesn't the library define it? I'll try alegro.cc's forums and I'll post back if I can solve this problem Smiley
Er, I never said it should be undefined.  The library does define it.  You just have to use it.

Allegro.cc would be an excellent place to also ask your question, though.

edit: ah, right, ravuya said you needed to define it.  I assumed he might have been just mis-remembering, though.
Logged
ravuya
Level 7
**


Yip yip yip yip yip


View Profile WWW
« Reply #7 on: December 06, 2007, 07:07:28 PM »

I mistyped, sorry. It was a pretty hectic day when I made that post. Smiley

You might want to look at the project file in Xcode; it should tell you inside one of the Target properties which additional command line arguments are being used. I seem to remember there was more than one framework that got used with Allegro under OS X, but that was years ago.
Logged

Massena
Level 4
****


Satisfied.


View Profile
« Reply #8 on: December 08, 2007, 08:00:20 AM »

I did it! Grin It seems that linking allegro is quite complicated so the library provides a script, allegro-config, that does that for the user so after I put /usr/local/bin in my path and made sure END_OF_MAIN() was there all it took was a simple
Code:
g++ example.cpp `allegro-config --libs`
command to compile the program.
Thanks! Smiley
Logged

Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic