LinuxQuestions.org
Help answer threads with 0 replies.
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 03-27-2018, 03:17 PM   #1
Ace Blackwell
Member
 
Registered: Mar 2004
Location: Kentucky, USA
Distribution: SlamD 12.1 / Slack 12.0 ~ 14.2_64
Posts: 325

Rep: Reputation: 52
Works in IDE not from command line July 2011 Posted on 03/26/2018 8:45 PM View Profile I'm using Allegro 4.4.2 in eclipse on Linux Slack


Member #13,038
July 2011

Posted on 03/26/2018 8:45 PM View Profile
I'm using Allegro 4.4.2 in eclipse on Linux Slackware 14.2

The issue I'm having is in order to static link my program, I'm compiling / linking from the prompt as I can't get eclipse to do it. When I enter...

g++ -Wall -o Dragons allegro.cpp board.cpp keys.cpp main.cpp map.cpp rand.cpp sound.cpp target.cpp title.cpp `allegro-config --static --libs`

I get an error.
main.cpp.text+0x158): undefined reference to `gameplay(BITMAP**, bchar*, char (*) [15], char (*) [15], int, DATAFILE*)' collect2: error: ld returned 1 exit status

At first I thought it was my definition (or declaration, I get the two confused in terminology) before main. So I commented out the actual call to the function within main. It compiled and linked fine. Obviously the program didn't work right but the executable worked on it's own. Now I believe it's with the call. I'm guessing g++ isn't considering the definition and call as the same function. So I'm including both the definition and call, along with declaring of the variables that go with it. Maybe someone can see something I'm not. Again, keep in mind it compiles (dynamically) fine in eclipse and I was able to static link in Windows 10 from
DevCpp with no change to the code itself. Don't get bogged down with the actual working of the code below. I weeded out the stuff that had nothing to do with the function call or it's definition.

Thanks in advance to looking this over.

void gameplay(BITMAP *[],bchar [] ,char[][15], char[][15],int,DATAFILE *);

int main(int argc, char *argv[]) {
/************Setup / Configurations ***********/
bchar token[4]; // Array for board pieces
BITMAP *GameBitmaps[3]; //BITMAPs for Game graphics
DATAFILE *GameDat = NULL; // DAT file with all screen - Fonts - Sounds
char board[15][15]; // Playing Board
char walls[15][15]; // Allows walls to stay hidden until ran into
int sound_clip = 69; // Random Number Init

GameDat = load_datafile("Dragons.dat"); // Load Data file and create bitmaps
GameBitmaps[BUFFER]= create_bitmap(640,480);
GameBitmaps[BUF_HOLD]= create_bitmap(640,480);
GameBitmaps[2]= create_bitmap(640,480);

/*********** Start Program ****************/
while(resp != KEY_Q){
if (resp == KEY_P){ // Game Play Start
gameplay(GameBitmaps,token,board,walls,sound_clip,GameDat);
} // End Gameplay IF

} // While Quit loop

return EXIT_SUCCESS;

} // End of main();

END_OF_MAIN();
 
Old 03-27-2018, 03:44 PM   #2
norobro
Member
 
Registered: Feb 2006
Distribution: Debian Sid
Posts: 792

Rep: Reputation: 329Reputation: 329Reputation: 329Reputation: 329
You declare gameplay() in main.cpp, in what file do you define it?
 
Old 03-27-2018, 03:59 PM   #3
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 3,624

Rep: Reputation: 1111Reputation: 1111Reputation: 1111Reputation: 1111Reputation: 1111Reputation: 1111Reputation: 1111Reputation: 1111Reputation: 1111
@OP: Kindly read this: https://www.linuxquestions.org/quest...gs-4175464257/
http://www.catb.org/esr/faqs/smart-questions.html
 
Old 03-27-2018, 04:01 PM   #4
Ace Blackwell
Member
 
Registered: Mar 2004
Location: Kentucky, USA
Distribution: SlamD 12.1 / Slack 12.0 ~ 14.2_64
Posts: 325

Original Poster
Rep: Reputation: 52
Sorry for the weird title. Working from phone and had a copy paste mishap. Didn’t notice until posted

I think you asked the magic question. I don’t see play.cpp in my command line text. I assumed the issues was a perceived mismatch with in main by g++, but it may have been as simple as not seeing the function because play.cpp wasn’t included.

I’ll keep you posted Thanks again.
 
Old 03-27-2018, 07:47 PM   #5
Ace Blackwell
Member
 
Registered: Mar 2004
Location: Kentucky, USA
Distribution: SlamD 12.1 / Slack 12.0 ~ 14.2_64
Posts: 325

Original Poster
Rep: Reputation: 52
Update, Adding play.cpp to the command line, solved my compiling/linking issue. It didn't however make my program Static. I've tried it on a second machine without Allegro installed. It won't run. I was afraid of this when the file was only 66K bites. In Windows the static program was between 15-20meg.

In any case, this issue was solved. I'll mark it accordingly
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
LXer: How to view or edit pdf and image metadata from command line on Linux LXer Syndicated Linux News 0 08-29-2013 10:30 AM
Eclipse (WTP): How to hide the Line Break symbol in Web Design view Larry James Programming 4 06-05-2013 05:00 AM
Allegro and Eclipse Ace Blackwell Programming 2 07-21-2011 10:53 AM
Eclipse and Allegro Ace Blackwell Programming 2 02-03-2009 09:36 AM
eclipse from command line resego Linux - Newbie 6 04-16-2005 04:56 PM

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

All times are GMT -5. The time now is 08:40 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration