|
|
| Setting up allegro 5 with codeblocks on fedora 13? |
|
verthex
Member #11,340
September 2009
|
So I posted this in some other thread already but maybe no one even saw it so I'll just start a thread on it. These were the exact steps I took thus far to get to the end which is at the bottom of this post, cookies for solving this mess, thanks, I got it to install using this for fedora 13: tar xvfz allegro-4.9.21.tar.gz Not sure how this was a problem before, I did the same exact thing previously. Now how do I setup the linker in codeblocks. What name.a do I use to link with? I also noticed several of these messages with different names with .so extension. Removed runtime path from "/usr/local/lib/liballegro_main.so.4.9.21" Is that ok? So I tried to compile this code after commenting out some statements related to common.c: 1#include <allegro5/allegro5.h>
2#include "allegro5/allegro_image.h"
3#include <allegro5/allegro_primitives.h>
4
5//#include "common.c"
6
7#define NUM_BUTTONS 3
8
9static void draw_mouse_button(int but, bool down)
10{
11 const int offset[NUM_BUTTONS] = {0, 70, 35};
12 ALLEGRO_COLOR grey;
13 ALLEGRO_COLOR black;
14 int x;
15 int y;
16
17 x = 400 + offset[but-1];
18 y = 130;
19
20 grey = al_map_rgb(0xe0, 0xe0, 0xe0);
21 black = al_map_rgb(0, 0, 0);
22
23 al_draw_filled_rectangle(x, y, x + 26.5, y + 41.5, grey);
24 al_draw_rectangle(x, y, x + 26.5, y + 41.5, black, 0);
25 if (down) {
26 al_draw_filled_rectangle(x + 2, y + 2, x + 24.5, y + 39.5, black);
27 }
28}
29
30int main(void)
31{
32 ALLEGRO_DISPLAY *display;
33 ALLEGRO_BITMAP *cursor;
34 ALLEGRO_MOUSE_STATE msestate;
35 ALLEGRO_KEYBOARD_STATE kbdstate;
36 int i;
37
38 if (!al_init()) {
39 //abort_example("Could not init Allegro.\n");
40 return 1;
41 }
42
43 al_init_primitives_addon();
44 al_install_mouse();
45 al_install_keyboard();
46 al_init_image_addon();
47
48 display = al_create_display(640, 480);
49 if (!display) {
50 // abort_example("Error creating display\n");
51 return 1;
52 }
53
54 al_hide_mouse_cursor(display);
55
56 cursor = al_load_bitmap("data/cursor.tga");
57 if (!cursor) {
58 // abort_example("Error loading cursor.tga\n");
59 return 1;
60 }
61
62 do {
63 al_get_mouse_state(&msestate);
64 al_get_keyboard_state(&kbdstate);
65
66 al_clear_to_color(al_map_rgb(0xff, 0xff, 0xc0));
67 for (i = 1; i <= NUM_BUTTONS; i++) {
68 draw_mouse_button(i, al_mouse_button_down(&msestate, i));
69 }
70 al_draw_bitmap(cursor, msestate.x, msestate.y, 0);
71 al_flip_display();
72
73 al_rest(0.005);
74 } while (!al_key_down(&kbdstate, ALLEGRO_KEY_ESCAPE));
75
76 return 0;
77}
I added liballeg.a in the link libraries but then I got this error: ld||cannot find -lalleg| This was in codeblocks. I tried to put -lalleg in the box next to the libraries box under the "other linker options" heading with no luck, do I need to specify a directory? If so where? EDIT I tried this page where on the bottom it says to change the project build options. I added the directory under usr/local/lib but adding liballegro.so didn't work? I did remove the liballeg.a option in the link libraries section as well. EDIT: I just had to import every .so file from usr/local/lib and it compiled fine. But then I got this error running the program in xterm, {"name":"602127","src":"http:\/\/static.allegro.cc\/image\/cache\/4\/d\/4d8f2ea044bc275e5d7dd23211e142b2.png","w":513,"h":168,"tn":"http:\/\/static.allegro.cc\/image\/cache\/4\/d\/4d8f2ea044bc275e5d7dd23211e142b2"} I did find these 2 pages (allegro thread and fedora thread) but Im not sure how to modify the sudo command to fix the above error. Example:
|
|
Thomas Fjellstrom
Member #476
June 2000
|
Well first things first, -lalleg is for a4. And arguably you don't want to use -lalleg on linux at all, even for a4. rather you find the right box to put `allegro-config --libs` (note the backticks, they be important). And a5 supports pkg-config, which Code::Blocks also supports so there should be a list in Code::Blocks letting you select from a bunch of libs to link to, select the allegro libs you find in there. Though things tend to work better if you tell cmake to install a5 to /usr rather than /usr/local (its just easier to deal with). -- |
|
verthex
Member #11,340
September 2009
|
So I have the files in this directory {"name":"602134","src":"http:\/\/static.allegro.cc\/image\/cache\/0\/d\/0da5f3a25fde342b1aae625f315c8c88.png","w":756,"h":422,"tn":"http:\/\/static.allegro.cc\/image\/cache\/0\/d\/0da5f3a25fde342b1aae625f315c8c88"} But I cannot click on anything in the "build options..." pop-up under the project tree to add them, tried the library tab as well (shown in photo below). {"name":"602133","src":"http:\/\/static.allegro.cc\/image\/cache\/8\/f\/8f0c723ca96c6e7b8b0dd93ba4306c5d.png","w":1016,"h":678,"tn":"http:\/\/static.allegro.cc\/image\/cache\/8\/f\/8f0c723ca96c6e7b8b0dd93ba4306c5d"}
|
|
Thomas Fjellstrom
Member #476
June 2000
|
You need to set some environment variable to get pkg-config to see files in /usr/local. Or you can install allegro to /usr.. Your choice. -- |
|
verthex
Member #11,340
September 2009
|
Thomas Fjellstrom said: You need to set some environment variable to get pkg-config to see files in /usr/local Would that be found in the system itself or under codeblocks. I know about this in windows and even that doesn't work right sometimes. Quote: Or you can install allegro to /usr.. Your choice. How would I uninstall the copy in usr/local and tell make install to put it in the /usr directory? I'm considering going both ways just to see what happens, would there be a compiler conflict with two copies of allegro on one system?
|
|
Peter Wang
Member #23
April 2000
|
The environment variable to set is PKG_CONFIG_PATH, e.g. PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/lib/pkgconfig I don't know if that helps with codeblocks but I assume it would.
|
|
verthex
Member #11,340
September 2009
|
Peter Wang said: The environment variable to set is PKG_CONFIG_PATH, e.g. PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/lib/pkgconfig
But I still dont know where to set that in fedora. Is it a .conf file in /etc directory or I found this under settings->environment in codeblocks but I'm not sure how to use it {"name":"602135","src":"http:\/\/static.allegro.cc\/image\/cache\/c\/e\/ce7f6c3a7317212f1acb708d55356943.png","w":962,"h":710,"tn":"http:\/\/static.allegro.cc\/image\/cache\/c\/e\/ce7f6c3a7317212f1acb708d55356943"} EDIT: I tried to run make uninstall in the Build directory but there was no target. I also tried to see if I have a configure file anywhere so I can install to a specific directory but there isn't one. I tried to follow these two threads: 1. For make uninstall.
|
|
Elias
Member #358
May 2000
|
That env var dialog in CB looks like the right place. So basically put this as env variable: PKG_CONFIG_PATH=/usr/local/lib/pkgconfig Then to add a library, do it like this: `pkg-config allegro-4.9 --libs` You will need one line like this for each addons as well. You can also try it on the command line first, outside of CB, in case CB can't set the environment variable or can't parse pkg-config. -- |
|
verthex
Member #11,340
September 2009
|
I did this and I'm not sure if its correct because I'm still not able to run the program. I chose k as a random variable name, is that ok? {"name":"602136","src":"http:\/\/static.allegro.cc\/image\/cache\/4\/8\/48dd601d11065880063fe80db8fb6596.png","w":1018,"h":707,"tn":"http:\/\/static.allegro.cc\/image\/cache\/4\/8\/48dd601d11065880063fe80db8fb6596"} Elias said: You will need one line like this for each addons as well. Not sure what you mean by addons?
|
|
Elias
Member #358
May 2000
|
The variable name is PKG_CONFIG_PATH. The value is /usr/local/lib/pkgconfig. The `pkg-config --libs` lines go to the linker/library settings instead. Addons are things like allegro_primitives or allegro_audio. -- |
|
verthex
Member #11,340
September 2009
|
After setting the variables like I did in my picture (last post) codeblocks would not start up again. I reinstalled codeblocks using yumex and still the program starts and then exits. Is there a file I configure for the environment paths?
|
|
Elias
Member #358
May 2000
|
I don't have Codeblocks myself, but it probably stores its settings in ~/.codeblocks or ~/.config/codeblocks - so if it doesn't start again it should be enough to rename that folder temporarily. -- |
|
verthex
Member #11,340
September 2009
|
I cant find it, tried searching the drive for codeblocks and I deleted all those files which were the start menu junk, that didn't work. Then I search for .config but none of the files were related to codeblocks. EDIT: I typed "env" into bash and it showed the environment variables but none for codeblocks so those werent set I guess. I'm not sure how codeblocks sets the path in a file actually, like where its located.
|
|
Thomas Fjellstrom
Member #476
June 2000
|
verthex said: I typed "env" into bash and it showed the environment variables but none for codeblocks so those werent set I guess. Of course not. A single program can only modify the environment inside its own process. At no time can an app set an env var and see it "escape". If you want it to be permanent set it in ~/.bashrc or something. export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig -- |
|
verthex
Member #11,340
September 2009
|
I think I found the problem, although Im not sure how to fix it. Heres a picture: {"name":"602138","src":"http:\/\/static.allegro.cc\/image\/cache\/d\/5\/d595b57e636fa123beeaa992d6a41bfd.png","w":1005,"h":624,"tn":"http:\/\/static.allegro.cc\/image\/cache\/d\/5\/d595b57e636fa123beeaa992d6a41bfd"} This is what it contains: 1<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
2<CodeBlocks_project_file>
3 <FileVersion major="1" minor="6" />
4 <Project>
5 <Option title="parentinherit" />
6 <Option pch_mode="2" />
7 <Option compiler="gcc" />
8 <Build>
9 <Target title="Debug">
10 <Option output="bin/Debug/parentinherit" prefix_auto="1" extension_auto="1" />
11 <Option object_output="obj/Debug/" />
12 <Option type="1" />
13 <Option compiler="gcc" />
14 <Compiler>
15 <Add option="-g" />
16 </Compiler>
17 </Target>
18 <Target title="Release">
19 <Option output="bin/Release/parentinherit" prefix_auto="1" extension_auto="1" />
20 <Option object_output="obj/Release/" />
21 <Option type="1" />
22 <Option compiler="gcc" />
23 <Compiler>
24 <Add option="-O2" />
25 </Compiler>
26 <Linker>
27 <Add option="-s" />
28 </Linker>
29 </Target>
30 </Build>
31 <Compiler>
32 <Add option="-Wall" />
33 </Compiler>
34 <Extensions>
35 <code_completion />
36 <envvars />
37 <debugger />
38 </Extensions>
39 </Project>
40</CodeBlocks_project_file>
Should I delete it or... Thomas Fjellstrom said: If you want it to be permanent set it in ~/.bashrc or something. Do I need to go into that folder with bash and then use that command. Is there a dependency in codeblocks that I need to set to see that folder?
|
|
Arthur Kalliokoski
Member #5,540
February 2005
|
We'll tell you how to Google for setting environment variables in Linux as soon as we confirm you're a human. {"name":"captcha.jpg","src":"http:\/\/static.allegro.cc\/image\/cache\/9\/d\/9d2c92038a63d65da2ae531d4ec65ee1.jpg","w":420,"h":252,"tn":"http:\/\/static.allegro.cc\/image\/cache\/9\/d\/9d2c92038a63d65da2ae531d4ec65ee1"} I really admire the U.S. Constitution. It's so much better than what we have now. |
|
verthex
Member #11,340
September 2009
|
Well, I guess this thread is solved (stalemated). I've decided to start using netbeans instead and when I upgrade to fedora 14 I'll try this again. EDIT: I fixed the problem with codeblocks crashing by unhiding the file .codeblocks in the home directory and deleting it. A new folder will be created once codeblocks is restarted. System->
|
|
|