LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-21-2010, 04:59 AM   #1
hua
Member
 
Registered: Oct 2006
Location: Slovak Republic
Distribution: Slackware 14.2, current
Posts: 461

Rep: Reputation: 78
Kdevelop and allegro - undefined reference


Hi

I am trying to use allegro in my c++ graphic simulation program. I write the code in Dev-c++ in winXp, but I would like to use Kdevelop instead now. It seems that my OS supports allegro (slackware 13.1 86_64). I downloaded the allegro package from the slackbuilds and installed the package. It seems to me that it works now, because when I include the header files into my application and put the mouse on the included header it shows me the content of it. I use there a function create_bitmap() for example. This function is also in the header files but when I try to compile it (in Kdevelop) it shows me that it is undefined.

I found in the allegro documentation that when I try to build the application I should use this:
Code:
g++ main.cpp -o hist `allegro-config --libs`
It seems work because when I try to build the application without the allegro-config (on command line), it shows the same undefined reference errors which it shows in Kdevelop - development platform.
The problem is that I cannot do this from Kdevelop. I don't know where I can tell the kdevelop to use this allegro-config --libs configuration.

I don't know exactly the role of each file in the project folder, there are lots of cmake files. I guess that I should edit one of this files but I don't have any idea which one. Can anybody give me some useful information or some good links for Kdevelop + allegro configuration?

Last edited by hua; 11-21-2010 at 06:01 AM.
 
Old 11-21-2010, 06:08 AM   #2
JohnGraham
Member
 
Registered: Oct 2009
Posts: 467

Rep: Reputation: 139Reputation: 139
Quote:
Originally Posted by hua View Post
when I try to compile it (in Kdevelop) it shows me that it is undefined.
...
it shows the same undefined reference errors
It's helpful if you can post specific errors, so everyone is clear as to what the problem is. By "undefined reference", I assume you mean something like the following:

Code:
/tmp/tmp.8Y1401Iqzg/test.c:4: undefined reference to XXX
If you also get this same error when compiling on the command-line, the --libs option to allegro-config might not be configured properly. Could you post the output of just running:

Code:
allegro-config --libs
on your shell?
 
Old 11-21-2010, 07:46 AM   #3
hua
Member
 
Registered: Oct 2006
Location: Slovak Republic
Distribution: Slackware 14.2, current
Posts: 461

Original Poster
Rep: Reputation: 78
The code is long so I will just show the main graphics init, what doesn't work.

Code:
#include <allegro.h>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <./allegro/gfx.h>

using namespace std;


void setupGraphics(){
 
buffer = create_bitmap( 1024, 768);       
draw_sprite( buffer, sBottom_bar, 0, 678);
draw_sprite( buffer, sBarInfo, 180, 678);                        
draw_sprite( buffer, sTopBar, 0, 0);
       
show_mouse(buffer);                                           
          
draw_sprite( screen, buffer, 0, 0); 
}

int main(){
    
    
           allegro_init();                                                         
           install_keyboard();
           install_mouse();
           set_color_depth(16);
           set_gfx_mode( GFX_AUTODETECT, 1024, 768, 0, 0);

                         setupGraphics();
    
                         while( !key[KEY_ESC]){

           	                    timeLine();
           	                    getMouseKlick();
		
                                updateScreen();
                                }


    return 0;
}
END_OF_MAIN();
This is the output of the allegro-config --libs:
Code:
-L/usr/lib -L/usr/lib64 -Wl,--export-dynamic -lalleg-4.2.2 -lalleg_unsharable
But the above example compilation on commandline did actually work with the allegro-config --libs. It compiled the code (although I can see only black screen).
The problem is that I cannot do the same within the Kdevelop.
the errors are reported for each function within the allegro as undefined reference to the function. (create_bitmap(), draw_sprite())

I need to somehow tell the same configuration option to the Kdevelop. I cannot find anything in the settings within Kdevelop where I can set this.
What does this actually mean - I tell the g++ compiler where to find the allegro libraries?
What command is executed when I start within the kdevelop the "Build Project" - g++ main.cpp -o main??
Within the root project directory there is a build directory which contains the file "CMakeCache.txt" - there are lots of "path to a library" definitions. Should I define here the path to the alegro library??

Last edited by hua; 11-21-2010 at 07:59 AM.
 
Old 11-21-2010, 08:37 AM   #4
JohnGraham
Member
 
Registered: Oct 2009
Posts: 467

Rep: Reputation: 139Reputation: 139
Quote:
Originally Posted by hua View Post
But the above example compilation on commandline did actually work with the allegro-config --libs.
Ah, OK - I misunderstood your first post.

Try right-clicking on your target binary in the Automake Manager and selecting Options, then add `allegro-config --libs` to the "Other:" field. I think this should work, but if it doesn't then try adding "-L/usr/lib -L/usr/lib64 -Wl,--export-dynamic -lalleg-4.2.2 -lalleg_unsharable".
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Undefined reference, why? george_mercury Programming 4 05-07-2009 12:15 AM
KDevelop: Undefined Reference to...? suliman_shah Programming 0 08-10-2007 12:31 PM
undefined reference to... dimah Programming 3 12-27-2006 09:57 AM
KDevelop: undefined reference bastl Programming 2 09-05-2005 09:52 AM
Undefined Reference ChemicalBurn Programming 2 02-14-2005 03:01 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:16 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration