Allegro.cc - Online Community

Allegro.cc Forums » Allegro Development » Allegro Xcode Error Compiling

This thread is locked; no one can reply to it. rss feed Print
Allegro Xcode Error Compiling
motyas
Member #16,305
April 2016

Hello guys!
I have a question, someone can help me?
I recently download allegro for my mac (i programming with Xcode). But after expend two days for download it, when i've wanted to compile my code doesn't compiled! My code is okay, the problem appear when i type the allegro library. I read in liballeg.org a bit but i don't speak english very well, and i'm knew programming in Xcode. * In the site of allegro library i read something of "define ALLEGRO_UNSTABLE", i define it in my code, but anything *
Someone have the same problem? And solve it? How?
Thanks everybody ;D

Peter Hull
Member #1,136
March 2001

Hi motyas,

Try:
1. install allegro using homebrew (instructions)
2. start a new Xcode project (project type: command line tool)
3. Add /usr/local/include and /usr/local/lib to the search paths
{"name":"610317","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/e\/7\/e7fd5c10afca0f37b566a0fb48005635.png","w":1076,"h":502,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/e\/7\/e7fd5c10afca0f37b566a0fb48005635"}610317
4. Add /usr/local/lib/liballegro.dylib and liballegro_main.dylib to the project
5. Write code, e.g.

#include <allegro5/allegro.h>

int main(int argc, const char * argv[]) {
    al_init();
    ALLEGRO_DISPLAY* display = al_create_display(640, 480);
    al_clear_to_color(al_map_rgb(0x40, 0x40, 0x80));
    al_flip_display();
    al_rest(10.0);
    al_destroy_display(display);
    return 0;
}

Run it!

Hope that helps.

motyas
Member #16,305
April 2016

Thanks Peter,
I have installed Allegro with Homebrew, but i need to replace the directions in the Search Path? or add a new?
I tried to do it, but i have the same errors.. I want to cry :'c

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

motyas
Member #16,305
April 2016

Yes, i forgot it!
The two errors that i have are:

Undefined symbols for architecture x86_64:
"_main", referenced from: // Here is the first
implicit entry/start for main executable
(maybe you meant: __Z16_al_mangled_mainiPPKc)
ld: symbol(s) not found for architecture x86_64
clang: error:

linker command failed with exit code 1 (use -v to see invocation) // and this is the second

I guide me by this video (only the first part of the video) and the homebrew page:

https://www.youtube.com/watch?v=7miwnp8iDm8 // The tutorial

http://brew.sh/index.html // Homebrew

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Peter Hull
Member #1,136
March 2001

You need to link with allegro_main.

agreed.

Quote:

The linking order may be important too.

Don't think so in this case.

I've attached a 'simple' project I just made up to check the necessary steps. See if this works for you.

motyas
Member #16,305
April 2016

But where i need to put the .dylib files? ???
I put a file in this comment, are the images of my code/xcode
Yes, the project goes well, but have an breakpoint, i don't know. I put also an image of your simple project.

Also i find this in the NET:

http://stackoverflow.com/questions/32641673/undefined-symbols-for-architecture-x86-64-in-c

is in english and i didn't understand what says (a bit), and when mention something of the terminal my head did: "boom"! Someone speak english here? hahahah, the hope is the only thing that i will never miss c':

Peter Hull
Member #1,136
March 2001

In this one
{"name":"610326","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/7\/b\/7be37ec9a7849b9c883841b7bfbd951b.png","w":1280,"h":800,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/7\/b\/7be37ec9a7849b9c883841b7bfbd951b"}610326
You can see the names are in red. That means they can't be found.
If you have installed Allegro from homebrew they should be in /usr/local/lib.
Try

ls /usr/local/lib/liballegro*

from the terminal and

brew info allegro

Tell us what you see.

[edit] Also when it says 'library search paths' in XCode it means path to a directory, not a file. That's why you get the 'ld warning directory not found for option -L' message.

motyas
Member #16,305
April 2016

I can see this:

==> Dependencies
Build: cmake ✔
Recommended: libvorbis ✔, freetype ✔, flac ✔, physfs ✔, libogg ✔, theora ✔
Optional: dumb ✘
==> Options
--with-dumb
Build with dumb support
--without-flac
Build without flac support
--without-freetype
Build without freetype support
--without-libogg
Build without libogg support
--without-libvorbis
Build without libvorbis support
--without-physfs
Build without physfs support
--without-theora
Build without theora support
--HEAD
Install HEAD version

I put the ls /usr/local/lib/liballegro* and tells me that:

/usr/local/lib/liballegro-static.a
/usr/local/lib/liballegro_acodec-static.a
/usr/local/lib/liballegro_audio-static.a
/usr/local/lib/liballegro_color-static.a
/usr/local/lib/liballegro_dialog-static.a
/usr/local/lib/liballegro_font-static.a
/usr/local/lib/liballegro_image-static.a
/usr/local/lib/liballegro_main-static.a
/usr/local/lib/liballegro_memfile-static.a
/usr/local/lib/liballegro_physfs-static.a
/usr/local/lib/liballegro_primitives-static.a

Peter Hull
Member #1,136
March 2001

Looks like it may not be installed properly. I don't have any of those -static files. I am not sure where they have come from or what version.

You need to look a bit further up, do you see this (if it is installed)

$ brew info allegro
allegro: stable 5.2.0 (bottled), HEAD
C/C++ multimedia library for cross-platform game development
http://liballeg.org/
/usr/local/Cellar/allegro/5.2.0 (145 files, 2.0M) *
  Poured from bottle
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/allegro.rb
==> Dependencies

or (if it isn't)

$ brew info allegro
allegro: stable 5.2.0 (bottled), HEAD
C/C++ multimedia library for cross-platform game development
http://liballeg.org/
Not installed
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/allegro.rb
==> Dependencies

motyas
Member #16,305
April 2016

allegro: stable 5.2.0 (bottled), HEAD
C/C++ multimedia library for cross-platform game development
http://liballeg.org/
/usr/local/Cellar/allegro/5.2.0 (145 files, 2M)
Poured from bottle
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/allegro.rb
==> Dependencies

This is the thing that i see.

Maybe i need to uninstall everything and reinstall it again. Do you know how uninstall allegro and it's libraries? or do you know a tutorial in which tells how?

Thanks very much for your help :)

I reinstall everything but i got the same errors... I don't know what i need to do :/

Peter Hull
Member #1,136
March 2001

Try

brew remove allegro
brew update
brew install allegro

motyas
Member #16,305
April 2016

I go to try it,
i did it, but i got the same errors.
Can i do you an other question?
What specifically i need to do in Xcode?
(In the search paths...)

Peter Hull
Member #1,136
March 2001

I sent you a PM.

motyas
Member #16,305
April 2016

Nice!
Thanks a lot for help me! But i still have an error, its tell me that:
ld: library not found for -lallegro_main.5.2.1
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I tried with the SDL library and i succeeded installing it! I don't know whats could be the problem... ???

Go to: