Sign in to follow this  
Lempface

C++ and Headers/includes.

Recommended Posts

I'm having trouble understanding this, I have a header global.h which has all my global variables and constants, I want these to be available to some of my classes and functions (stored in their own cpp) but if I include the header in the .cpp containing said functions or constants my compiler says I've declared the variables/constants from the header file have been defined as many times as I've included them, even with #ifndef. [/run on] I'm sure I'm just doing something wrong here, any tips would be great.

Share this post


Link to post
Share on other sites
Hmm, I'm not sure if you read that entire article thoroughly. Here's a tested example(code::blocks with mingw)

globals.h

#ifndef GLOBALS_H_
#define GLOBALS_H_

extern int alpha;
extern int beta;

#endif


globals.cpp

#include "globals.h"

int alpha = 0;
int beta = 1;


main.cpp

#include <iostream>
#include "globals.h"

int main()
{
std::cout << alpha << " " << beta << std::endl;
return 0;
}

Share this post


Link to post
Share on other sites
Yea, that is precisely what I have.. let me post my code.

global.h

#ifndef GLOBAL_H_
#define GLOBAL_H_

#include <allegro.h>
#include <alpng.h>
#include <stdlib.h>

//#define MODE GFX_AUTODETECT_WINDOWED
#define MODE GFX_AUTODETECT_FULLSCREEN
#define SCREENW 640
#define SCREENH 480
#define BALLSPEED 3
#define PADDLESPEED 2

//Colors
#define RED makecol(235, 0 ,0)
#define BLUE makecol(0, 0, 225)
#define WHITE makecol(255, 255 ,255)

//Paddlesize
#define PADDLEW 29
#define PADDLEH 5

//Ballsize
#define BALLW 3
#define BALLH 3

/*
Gameload = 0
Gamepause = 1
Gameon = 10
Gamequit = 100
*/

extern int gamestate;

extern int random;

BITMAP *buffer;

extern struct paddleTag {
int x, y;
int dir;
int color, score;
} paddles[2];

extern struct ballTag {
int x, y;
int xspeed, yspeed;
int color;
int status; // 0 = dead, 1 = alive
} balls;

extern struct moveTag {
int x, y;
} move;

#endif




Draw.h

#ifndef DRAW_H_
#define DRAW_H_
#include "global.h"

class eraseClass;

class drawClass {
private:
void draw(int, int, int);
int x, y;
int objtype;
public:
void ball();
void paddle(int);
void screens();
friend class eraseClass;
} draw;

#endif




Draw.cpp

//Draw some fun stuff on the screen
#include "draw.h"

/* Main draw function.
This function will determine if it should
draw a ball, or a paddle and then do so. */

void drawClass::draw(int num, int objtype, int color) {
if(objtype == 1)
{
x = paddles[num].x;
y = paddles[num].y;
rectfill(buffer, x - PADDLEW, y - PADDLEH, x + PADDLEW, y + PADDLEH, color);
}
else if (objtype == 2)
{
if (balls.status == 1)
{
x = balls.x;
y = balls.y;
rectfill(buffer, x - BALLW, y + BALLH, x + BALLW, y - BALLH, color);
}
}
}

/* Passes the required variables
to draw.draw() to draw a paddle. */

void drawClass::paddle(int num) {
draw(num, 1, paddles[num].color);
}

/* Passes the required variables
to draw.draw() to draw a ball. */

void drawClass::ball() {
draw(1, 2, balls.color);
}

//Blits all the new drawings to the buffer.
void drawClass::screens() {
blit(buffer, screen, 0, 0, 0, 0, 640, 480);
}




Main.cpp

/* Ba-BOUNCE! */
////////////////

#include "global.h"
#include "ai.h"
#include "draw.h"
#include "erase.h"
#include "init.h"
#include "move.h"
#include "titlescreen.h"
#include "getinput.h"
#include "shutdown.h"


using namespace std;

int main(void) {
init.startup();

titlescreen();

init.game();

while (gamestate == 10) {
erase.paddle(0);
erase.paddle(1);

erase.ball();

motion.paddle(0);
motion.paddle(1);

motion.ball();

draw.paddle(0);
draw.paddle(1);

draw.ball();

getinput();
ai();

if(balls.status == 0) {
init.nextround();
}

draw.screens();

rest(10);

}
shutdown();
return 1;

}
END_OF_MAIN();

Share this post


Link to post
Share on other sites
init.o(.bss+0x0):init.cpp: multiple definition of `init'
main.o(.bss+0xd):main.cpp: first defined here
init.o(.bss+0x4):init.cpp: multiple definition of `draw'
main.o(.bss+0x0):main.cpp: first defined here
init.o(.bss+0x10):init.cpp: multiple definition of `erase'
main.o(.bss+0xc):main.cpp: first defined here
draw.o(.bss+0x0):draw.cpp: multiple definition of `draw'
main.o(.bss+0x0):main.cpp: first defined here

erase.o(.bss+0x0):erase.cpp: multiple definition of `erase'
main.o(.bss+0xc):main.cpp: first defined here
erase.o(.bss+0x4):erase.cpp: multiple definition of `draw'
main.o(.bss+0x0):main.cpp: first defined here
move.o(.bss+0x0):move.cpp: multiple definition of `motion'
main.o(.bss+0x10):main.cpp: first defined here
main.o(.text+0x25):main.cpp: undefined reference to `gamestate'
main.o(.text+0xd8):main.cpp: undefined reference to `balls'
init.o(.text+0x8e):init.cpp: undefined reference to `buffer'
init.o(.text+0x94):init.cpp: undefined reference to `gamestate'

init.o(.text+0x123):init.cpp: undefined reference to `paddles'

init.o(.text+0x129):init.cpp: undefined reference to `paddles'

init.o(.text+0x133):init.cpp: undefined reference to `paddles'

init.o(.text+0x13d):init.cpp: undefined reference to `paddles'

init.o(.text+0x147):init.cpp: undefined reference to `paddles'

init.o(.text+0x16c):init.cpp: more undefined references to `paddles' follow
init.o(.text+0x1b5):init.cpp: undefined reference to `balls'
init.o(.text+0x1bb):init.cpp: undefined reference to `balls'
init.o(.text+0x1c5):init.cpp: undefined reference to `balls'
init.o(.text+0x1cf):init.cpp: undefined reference to `balls'
init.o(.text+0x1d9):init.cpp: undefined reference to `balls'
init.o(.text+0x1e3):init.cpp: more undefined references to `balls' follow
init.o(.text+0x200):init.cpp: undefined reference to `random'
init.o(.text+0x205):init.cpp: undefined reference to `random'
init.o(.text+0x210):init.cpp: undefined reference to `random'
init.o(.text+0x216):init.cpp: undefined reference to `random'
init.o(.text+0x21f):init.cpp: undefined reference to `move'
init.o(.text+0x22b):init.cpp: undefined reference to `move'
init.o(.text+0x251):init.cpp: undefined reference to `random'
init.o(.text+0x256):init.cpp: undefined reference to `random'
init.o(.text+0x261):init.cpp: undefined reference to `random'
init.o(.text+0x267):init.cpp: undefined reference to `random'

init.o(.text+0x270):init.cpp: undefined reference to `move'
init.o(.text+0x27a):init.cpp: undefined reference to `move'
init.o(.text+0x286):init.cpp: undefined reference to `move'
init.o(.text+0x290):init.cpp: undefined reference to `move'
init.o(.text+0x2ca):init.cpp: undefined reference to `balls'
init.o(.text+0x2d4):init.cpp: undefined reference to `balls'

init.o(.text+0x2de):init.cpp: undefined reference to `balls'
init.o(.text+0x2e8):init.cpp: undefined reference to `paddles'
init.o(.text+0x2f2):init.cpp: undefined reference to `paddles'
init.o(.text+0x2fc):init.cpp: undefined reference to `paddles'
init.o(.text+0x306):init.cpp: undefined reference to `paddles'
init.o(.text+0x352):init.cpp: undefined reference to `buffer'
init.o(.text+0x37d):init.cpp: undefined reference to `paddles'
init.o(.text+0x386):init.cpp: undefined reference to `paddles'
init.o(.text+0x3b6):init.cpp: undefined reference to `buffer'
init.o(.text+0x412):init.cpp: undefined reference to `buffer'
draw.o(.text+0x1e):draw.cpp: undefined reference to `paddles'
draw.o(.text+0x36):draw.cpp: undefined reference to `paddles'
draw.o(.text+0x77):draw.cpp: undefined reference to `buffer'
draw.o(.text+0x8d):draw.cpp: undefined reference to `balls'
draw.o(.text+0x98):draw.cpp: undefined reference to `balls'
draw.o(.text+0xa2):draw.cpp: undefined reference to `balls'
draw.o(.text+0xe3):draw.cpp: undefined reference to `buffer'
draw.o(.text+0x143):draw.cpp: undefined reference to `paddles'
draw.o(.text+0x16f):draw.cpp: undefined reference to `balls'
draw.o(.text+0x1d6):draw.cpp: undefined reference to `buffer'
getinput.o(.text+0x12):getinput.cpp: undefined reference to `gamestate'
getinput.o(.text+0x2b):getinput.cpp: undefined reference to `paddles'
getinput.o(.text+0x44):getinput.cpp: undefined reference to `paddles'

getinput.o(.text+0x50):getinput.cpp: undefined reference to `paddles'
ai.o(.text+0x4):ai.cpp: undefined reference to `balls'
ai.o(.text+0xa):ai.cpp: undefined reference to `paddles'
ai.o(.text+0x12):ai.cpp: undefined reference to `paddles'
ai.o(.text+0x1d):ai.cpp: undefined reference to `balls'
ai.o(.text+0x23):ai.cpp: undefined reference to `paddles'
ai.o(.text+0x2b):ai.cpp: undefined reference to `paddles'
ai.o(.text+0x37):ai.cpp: undefined reference to `paddles'
move.o(.text+0x56):move.cpp: undefined reference to `move'
move.o(.text+0x5c):move.cpp: undefined reference to `move'
move.o(.text+0x68):move.cpp: undefined reference to `move'
move.o(.text+0x95):move.cpp: undefined reference to `move'
move.o(.text+0xb6):move.cpp: undefined reference to `paddles'
move.o(.text+0xdd):move.cpp: undefined reference to `paddles'
move.o(.text+0xe6):move.cpp: undefined reference to `paddles'
move.o(.text+0xff):move.cpp: undefined reference to `paddles'
move.o(.text+0x126):move.cpp: undefined reference to `paddles'
move.o(.text+0x12f):move.cpp: more undefined references to `paddles' follow
move.o(.text+0x1ba):move.cpp: undefined reference to `balls'
move.o(.text+0x1c6):move.cpp: undefined reference to `balls'
move.o(.text+0x1d1):move.cpp: undefined reference to `balls'
move.o(.text+0x1db):move.cpp: undefined reference to `balls'
move.o(.text+0x1e7):move.cpp: undefined reference to `paddles'
move.o(.text+0x1ed):move.cpp: undefined reference to `balls'
move.o(.text+0x1fa):move.cpp: undefined reference to `paddles'
move.o(.text+0x204):move.cpp: undefined reference to `paddles'
move.o(.text+0x20d):move.cpp: undefined reference to `balls'
move.o(.text+0x214):move.cpp: undefined reference to `paddles'
move.o(.text+0x21d):move.cpp: undefined reference to `balls'
move.o(.text+0x224):move.cpp: undefined reference to `paddles'
move.o(.text+0x22d):move.cpp: undefined reference to `balls'
move.o(.text+0x24e):move.cpp: undefined reference to `move'
move.o(.text+0x25c):move.cpp: undefined reference to `paddles'
move.o(.text+0x265):move.cpp: undefined reference to `balls'
move.o(.text+0x26c):move.cpp: undefined reference to `paddles'
move.o(.text+0x275):move.cpp: undefined reference to `balls'

move.o(.text+0x27c):move.cpp: undefined reference to `paddles'

move.o(.text+0x285):move.cpp: undefined reference to `balls'
move.o(.text+0x2a6):move.cpp: undefined reference to `move'
move.o(.text+0x2b3):move.cpp: undefined reference to `balls'
move.o(.text+0x2bf):move.cpp: undefined reference to `balls'
move.o(.text+0x2d8):move.cpp: undefined reference to `move'
move.o(.text+0x2e4):move.cpp: undefined reference to `move'
move.o(.text+0x2ea):move.cpp: undefined reference to `balls'
move.o(.text+0x2ef):move.cpp: undefined reference to `move'
move.o(.text+0x2f5):move.cpp: undefined reference to `balls'
titlescreen.o(.text+0x4e):titlescreen.cpp: undefined reference to `buffer'
titlescreen.o(.text+0x9d):titlescreen.cpp: undefined reference to `buffer'
titlescreen.o(.text+0xb0):titlescreen.cpp: undefined reference to `gamestate'
titlescreen.o(.text+0x10b):titlescreen.cpp: undefined reference to `buffer'
shutdown.o(.text+0x7):shutdown.cpp: undefined reference to `buffer'

Share this post


Link to post
Share on other sites
Quote:
Original post by Lempface
Yea, that is precisely what I have.. let me post my code.

global.h
*** Source Snippet Removed ***

Draw.h
*** Source Snippet Removed ***

Draw.cpp
*** Source Snippet Removed ***

Main.cpp
*** Source Snippet Removed ***


from the looks of it, you have all your globals externed in global.h, but they arent defined anywhere to begin with. you need a global.cpp or some such implementation file in which you actually declair your globals.

Share this post


Link to post
Share on other sites
They are defined in the functions that call them. For instance

extern struct paddleTag{
...
...
...
} paddles[2];

is defined in init.cpp


void initClass::game() {
//setup paddle0
paddles[0].color = RED;
paddles[0].x = SCREENW / 2;
paddles[0].y = SCREENH - 30;
paddles[0].score = 0;
paddles[0].dir = 0;

//setup paddle1
paddles[1].color = BLUE;
paddles[1].x = SCREENW / 2;
paddles[1].y = 30;
paddles[1].score = 0;
paddles[1].dir = 0;

//setup ball
balls.color = WHITE;
balls.status = 1;
balls.x = SCREENW / 2;
balls.y = SCREENH / 2;
balls.xspeed = 0;
balls.yspeed = 0;

/* This starts the ball moving at the start of the game.
Positive BALLSPEED will send the ball down
where -BALLSPEED will send the ball up */

random = rand() % 2;

if (random == 1)
{
move.y = BALLSPEED;
}
else
{
move.y = -BALLSPEED;
}
}




Full Source

[Edited by - Lempface on June 5, 2006 6:51:29 PM]

Share this post


Link to post
Share on other sites
Quote:
Original post by Lempface
They are defined in the functions that call them. For instance

..snip


that's not defining it, that's using it. You actually need to define it:

globals.h

extern struct paddleTag{
...
...
...
} paddles[2];




globals.cpp

struct paddleTag paddles[2];




-me

Share this post


Link to post
Share on other sites
init.cpp

//Initialization routines.

#include "init.h"
#include "draw.h"
#include "erase.h"
#include "global.h"


void initClass::startup() {
allegro_init(); // Load Allegro.
install_keyboard(); // Load Allegro support for keyboard.
install_timer(); // Load Allegro support for timers.
set_color_depth(16);// Set screen color depth.
set_gfx_mode(MODE, SCREENW, SCREENH, 0 ,0); // Set graphics mode.
srand(time(NULL)); // Inilialize a new random seed.

buffer = create_bitmap(SCREENW, SCREENH); // Create the double buffer as the size of the screen.
gamestate = 0;
}

void initClass::game() {
//setup paddle0
paddles[0].color = RED;
paddles[0].x = SCREENW / 2;
paddles[0].y = SCREENH - 30;
paddles[0].score = 0;
paddles[0].dir = 0;

//setup paddle1
paddles[1].color = BLUE;
paddles[1].x = SCREENW / 2;
paddles[1].y = 30;
paddles[1].score = 0;
paddles[1].dir = 0;

//setup ball
balls.color = WHITE;
balls.status = 1;
balls.x = SCREENW / 2;
balls.y = SCREENH / 2;
balls.xspeed = 0;
balls.yspeed = 0;

/* This starts the ball moving at the start of the game.
Positive BALLSPEED will send the ball down
where -BALLSPEED will send the ball up */

random = rand() % 2;

if (random == 1)
{
move.y = BALLSPEED;
}
else
{
move.y = -BALLSPEED;
}
}

void initClass::ball() {
/* This starts the ball moving at a new round.
Positive BALLSPEED will send the ball down
where -BALLSPEED will send the ball up */

random = rand() % 2;

if (random == 1)
{
move.y = BALLSPEED;
move.x = 0;
}
else
{
move.y = -BALLSPEED;
move.x = 0;
}
}

/* This function resets the ball
to the center of the screen, adjusts
players scores, displays players scores,
and finally chooses a new random direction
for the ball to start in */

void initClass::nextround()
{

erase.paddle(0);
erase.paddle(1);

balls.x = SCREENW / 2;
balls.y = SCREENW / 2;
balls.status = 1;

//setup paddle0
paddles[0].x = SCREENW / 2;
paddles[0].y = SCREENH - 30;

//setup paddle1
paddles[1].x = SCREENW / 2;
paddles[1].y = 30;

textprintf_centre(buffer, font, SCREENW / 2, SCREENH / 2,
WHITE, "PRESS ENTER FOR NEXT ROUND");

textprintf_centre(buffer, font, SCREENW / 2, SCREENH / 2 - 50,
WHITE, "REDPLAYER'S SCORE = %i - BLUEPLAYER'S SCORE = %i",
paddles[0].score, paddles[1].score);

draw.screens();

while(!key[KEY_ENTER])
{
rest(10);
}

rectfill(buffer, 0, SCREENH / 2 - 50, 640, SCREENH / 2 + 50, 0);

draw.screens();
init.ball();
}



Okay I created global.cpp and its like this

#include "global.h"

int gamestate;

int random;

BITMAP *buffer;

struct paddleTag {
int x, y;
int dir;
int color, score;
} paddles[2];

struct ballTag {
int x, y;
int xspeed, yspeed;
int color;
int status; // 0 = dead, 1 = alive
} balls;

struct moveTag {
int x, y;
} move;



And now I get a host of new errors.

init.cpp: In member function `void initClass::nextround()':
init.cpp:100: warning: `textprintf_centre' is deprecated (declared at D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/allegro/alcompat.h:176)
init.cpp:101: warning: `textprintf_centre' is deprecated (declared at D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/allegro/alcompat.h:176)
init.cpp:103: warning: `textprintf_centre' is deprecated (declared at D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/allegro/alcompat.h:176)
init.cpp:105: warning: `textprintf_centre' is deprecated (declared at D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/allegro/alcompat.h:176)

g++.exe -c draw.cpp -o draw.o -I"lib/gcc/mingw32/3.4.2/include" -I"include/c++/3.4.2/backward" -I"include/c++/3.4.2/mingw32" -I"include/c++/3.4.2" -I"include"

g++.exe -c erase.cpp -o erase.o -I"lib/gcc/mingw32/3.4.2/include" -I"include/c++/3.4.2/backward" -I"include/c++/3.4.2/mingw32" -I"include/c++/3.4.2" -I"include"

g++.exe -c getinput.cpp -o getinput.o -I"lib/gcc/mingw32/3.4.2/include" -I"include/c++/3.4.2/backward" -I"include/c++/3.4.2/mingw32" -I"include/c++/3.4.2" -I"include"

g++.exe -c ai.cpp -o ai.o -I"lib/gcc/mingw32/3.4.2/include" -I"include/c++/3.4.2/backward" -I"include/c++/3.4.2/mingw32" -I"include/c++/3.4.2" -I"include"

g++.exe -c move.cpp -o move.o -I"lib/gcc/mingw32/3.4.2/include" -I"include/c++/3.4.2/backward" -I"include/c++/3.4.2/mingw32" -I"include/c++/3.4.2" -I"include"

g++.exe -c titlescreen.cpp -o titlescreen.o -I"lib/gcc/mingw32/3.4.2/include" -I"include/c++/3.4.2/backward" -I"include/c++/3.4.2/mingw32" -I"include/c++/3.4.2" -I"include"

g++.exe -c shutdown.cpp -o shutdown.o -I"lib/gcc/mingw32/3.4.2/include" -I"include/c++/3.4.2/backward" -I"include/c++/3.4.2/mingw32" -I"include/c++/3.4.2" -I"include"

g++.exe -c global.cpp -o global.o -I"lib/gcc/mingw32/3.4.2/include" -I"include/c++/3.4.2/backward" -I"include/c++/3.4.2/mingw32" -I"include/c++/3.4.2" -I"include"

global.cpp:9: error: redefinition of `struct paddleTag'
global.h:40: error: previous definition of `struct paddleTag'
global.cpp:13: error: invalid type in declaration before ';' token
global.cpp:13: error: conflicting declaration 'int paddles[2]'
global.h:44: error: 'paddles' has a previous declaration as `paddleTag paddles[2]'

global.cpp:13: error: type mismatch with previous external decl of `int paddles[2]'
global.h:44: error: previous external decl of `paddleTag paddles[2]'
global.cpp:13: error: declaration of `int paddles[2]'
global.h:44: error: conflicts with previous declaration `paddleTag paddles[2]'
global.cpp:15: error: redefinition of `struct ballTag'
global.h:46: error: previous definition of `struct ballTag'
global.cpp:20: error: invalid type in declaration before ';' token
global.cpp:20: error: conflicting declaration 'int balls'
global.h:51: error: 'balls' has a previous declaration as `ballTag balls'
global.cpp:20: error: type mismatch with previous external decl of `int balls'
global.h:51: error: previous external decl of `ballTag balls'

global.cpp:20: error: declaration of `int balls'
global.h:51: error: conflicts with previous declaration `ballTag balls'
global.cpp:22: error: redefinition of `struct moveTag'
global.h:53: error: previous definition of `struct moveTag'

global.cpp:24: error: invalid type in declaration before ';' token
global.cpp:24: error: conflicting declaration 'int move'

global.h:55: error: 'move' has a previous declaration as `moveTag move'
global.cpp:24: error: type mismatch with previous external decl of `int move'
global.h:55: error: previous external decl of `moveTag move'
global.cpp:24: error: declaration of `int move'
global.h:55: error: conflicts with previous declaration `moveTag move'

make.exe: *** [global.o] Error 1

Share this post


Link to post
Share on other sites
ok..

you already defined the type "paddleTag" here:


struct paddleTag {
int x, y;
int dir;
int color, score;
} paddles[2];


the type paddle Tag is this part:

struct paddleTag {
int x, y;
int dir;
int color, score;
};


in fact, it's more clear if you define your variable this way in the .h file:

struct paddleTag {
int x, y;
int dir;
int color, score;
};

extern paddleTag paddles[2];


your .cpp side should look like this:


paddleTag paddles[2];


you make the same error with every struct/class type object you create in globals.h

-me

Share this post


Link to post
Share on other sites
also this:

global.cpp:20: error: declaration of `int balls'
global.h:51: error: conflicts with previous declaration `ballTag balls'

probably means that you have 2 variables with the same name declared with different types.

-me

Share this post


Link to post
Share on other sites
also, remember that those errors give you the exact line number where the compile error occurs. Go to that line and see if you can figure out what's wrong. Take the errors one at a time.

-me

Share this post


Link to post
Share on other sites
Right but some of them don't make much sense. After fixing global.cpp I seem to be in better shape but this


init.o(.bss+0x0):init.cpp: multiple definition of `init'
main.o(.bss+0xd):main.cpp: first defined here
init.o(.bss+0x4):init.cpp: multiple definition of `draw'
main.o(.bss+0x0):main.cpp: first defined here
init.o(.bss+0x10):init.cpp: multiple definition of `erase'
main.o(.bss+0xc):main.cpp: first defined here
draw.o(.bss+0x0):draw.cpp: multiple definition of `draw'
main.o(.bss+0x0):main.cpp: first defined here

erase.o(.bss+0x0):erase.cpp: multiple definition of `erase'
main.o(.bss+0xc):main.cpp: first defined here
erase.o(.bss+0x4):erase.cpp: multiple definition of `draw'
main.o(.bss+0x0):main.cpp: first defined here
move.o(.bss+0x0):move.cpp: multiple definition of `motion'
main.o(.bss+0x10):main.cpp: first defined here

shows up now and I don't understand why, main.cpp includes init.h which defines the class, so why does it say it is defining it in main.cpp first?

Share this post


Link to post
Share on other sites
can you post:

init.h

and repost:
main.cpp
and init.cpp if you've made significant changes to it

my hunch is that init.h has something like:

struct initclass
{
...
} init;

instead of:
extern struct initclass
{
} init;


but which I think is more clear like:
struct initClass
{
};

extern initClass init;

-me

Share this post


Link to post
Share on other sites
init.h

#ifndef INIT_H_
#define INIT_H_

#include "global.h"

class initClass {
public:
void startup();
void game();
void ball();
void nextround();
} init;

#endif




main.cpp

/* Ba-BOUNCE! */
////////////////

#include "global.h"
#include "ai.h"
#include "draw.h"
#include "erase.h"
#include "init.h"
#include "move.h"
#include "titlescreen.h"
#include "getinput.h"
#include "shutdown.h"


using namespace std;

int main(void) {
init.startup();

titlescreen();

init.game();

while (gamestate == 10) {
erase.paddle(0);
erase.paddle(1);

erase.ball();

motion.paddle(0);
motion.paddle(1);

motion.ball();

draw.paddle(0);
draw.paddle(1);

draw.ball();

getinput();
ai();

if(balls.status == 0) {
init.nextround();
}

draw.screens();

rest(10);

}
shutdown();
return 1;

}
END_OF_MAIN();




init.cpp

//Initialization routines.

#include "init.h"
#include "draw.h"
#include "erase.h"
#include "global.h"


void initClass::startup() {
allegro_init(); // Load Allegro.
install_keyboard(); // Load Allegro support for keyboard.
install_timer(); // Load Allegro support for timers.
set_color_depth(16);// Set screen color depth.
set_gfx_mode(MODE, SCREENW, SCREENH, 0 ,0); // Set graphics mode.
srand(time(NULL)); // Inilialize a new random seed.

buffer = create_bitmap(SCREENW, SCREENH); // Create the double buffer as the size of the screen.
gamestate = 0;
}

void initClass::game() {
//setup paddle0
paddles[0].color = RED;
paddles[0].x = SCREENW / 2;
paddles[0].y = SCREENH - 30;
paddles[0].score = 0;
paddles[0].dir = 0;

//setup paddle1
paddles[1].color = BLUE;
paddles[1].x = SCREENW / 2;
paddles[1].y = 30;
paddles[1].score = 0;
paddles[1].dir = 0;

//setup ball
balls.color = WHITE;
balls.status = 1;
balls.x = SCREENW / 2;
balls.y = SCREENH / 2;
balls.xspeed = 0;
balls.yspeed = 0;

/* This starts the ball moving at the start of the game.
Positive BALLSPEED will send the ball down
where -BALLSPEED will send the ball up */

random = rand() % 2;

if (random == 1)
{
move.y = BALLSPEED;
}
else
{
move.y = -BALLSPEED;
}
}

void initClass::ball() {
/* This starts the ball moving at a new round.
Positive BALLSPEED will send the ball down
where -BALLSPEED will send the ball up */

random = rand() % 2;

if (random == 1)
{
move.y = BALLSPEED;
move.x = 0;
}
else
{
move.y = -BALLSPEED;
move.x = 0;
}
}

/* This function resets the ball
to the center of the screen, adjusts
players scores, displays players scores,
and finally chooses a new random direction
for the ball to start in */

void initClass::nextround()
{

erase.paddle(0);
erase.paddle(1);

balls.x = SCREENW / 2;
balls.y = SCREENW / 2;
balls.status = 1;

//setup paddle0
paddles[0].x = SCREENW / 2;
paddles[0].y = SCREENH - 30;

//setup paddle1
paddles[1].x = SCREENW / 2;
paddles[1].y = 30;

textprintf_centre(buffer, font, SCREENW / 2, SCREENH / 2,
WHITE, "PRESS ENTER FOR NEXT ROUND");

textprintf_centre(buffer, font, SCREENW / 2, SCREENH / 2 - 50,
WHITE, "REDPLAYER'S SCORE = %i - BLUEPLAYER'S SCORE = %i",
paddles[0].score, paddles[1].score);

draw.screens();

while(!key[KEY_ENTER])
{
rest(10);
}

rectfill(buffer, 0, SCREENH / 2 - 50, 640, SCREENH / 2 + 50, 0);

draw.screens();
init.ball();
}


Share this post


Link to post
Share on other sites
yeah:


class initClass {
public:
void startup();
void game();
void ball();
void nextround();
} init;


should be:

class initClass {
public:
void startup();
void game();
void ball();
void nextround();
};

extern initClass init;


with a corresponding

initClass init;

in init.cpp


It's going to be exactly the same problem for draw, motion and whichever other one it also complained about.

-me

Share this post


Link to post
Share on other sites
you're not externing a class definition but a variable definition.

when you do something like:

struct MyStruct
{
};


you are defining a type which will act like: int, float, char, etc but with the extra functionality you define.

when you do this:

MyStruct foo;

you are declaring a variable (similar to typing: int foo;)

Variables can only be declared once. The compiler assumes that if you declare something twice you are actually desiring to have 2 different variables. As such it rightly decides that it cannot tell whether you want to use the first or the second variable when you say foo.doStuff(). So it barfs out and you have to fix it.

-me

Share this post


Link to post
Share on other sites
Here let me repost my most current source in a .rar.

After externing all those class objects I get a BUNCH of linker errors.

Compiler: Default compiler
Building Makefile: "C:\Documents and Settings\Stephen\My Documents\Programming\BaBounce\Makefile.win"
Executing make clean
rm -f main.o init.o draw.o erase.o getinput.o ai.o move.o titlescreen.o shutdown.o global.o Ba-Bounce.exe

g++.exe -c main.cpp -o main.o -I"lib/gcc/mingw32/3.4.2/include" -I"include/c++/3.4.2/backward" -I"include/c++/3.4.2/mingw32" -I"include/c++/3.4.2" -I"include"

g++.exe -c init.cpp -o init.o -I"lib/gcc/mingw32/3.4.2/include" -I"include/c++/3.4.2/backward" -I"include/c++/3.4.2/mingw32" -I"include/c++/3.4.2" -I"include"

init.cpp: In member function `void initClass::nextround()':
init.cpp:100: warning: `textprintf_centre' is deprecated (declared at D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/allegro/alcompat.h:176)
init.cpp:101: warning: `textprintf_centre' is deprecated (declared at D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/allegro/alcompat.h:176)
init.cpp:103: warning: `textprintf_centre' is deprecated (declared at D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/allegro/alcompat.h:176)
init.cpp:105: warning: `textprintf_centre' is deprecated (declared at D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/allegro/alcompat.h:176)

g++.exe -c draw.cpp -o draw.o -I"lib/gcc/mingw32/3.4.2/include" -I"include/c++/3.4.2/backward" -I"include/c++/3.4.2/mingw32" -I"include/c++/3.4.2" -I"include"

g++.exe -c erase.cpp -o erase.o -I"lib/gcc/mingw32/3.4.2/include" -I"include/c++/3.4.2/backward" -I"include/c++/3.4.2/mingw32" -I"include/c++/3.4.2" -I"include"

g++.exe -c getinput.cpp -o getinput.o -I"lib/gcc/mingw32/3.4.2/include" -I"include/c++/3.4.2/backward" -I"include/c++/3.4.2/mingw32" -I"include/c++/3.4.2" -I"include"

g++.exe -c ai.cpp -o ai.o -I"lib/gcc/mingw32/3.4.2/include" -I"include/c++/3.4.2/backward" -I"include/c++/3.4.2/mingw32" -I"include/c++/3.4.2" -I"include"

g++.exe -c move.cpp -o move.o -I"lib/gcc/mingw32/3.4.2/include" -I"include/c++/3.4.2/backward" -I"include/c++/3.4.2/mingw32" -I"include/c++/3.4.2" -I"include"

g++.exe -c titlescreen.cpp -o titlescreen.o -I"lib/gcc/mingw32/3.4.2/include" -I"include/c++/3.4.2/backward" -I"include/c++/3.4.2/mingw32" -I"include/c++/3.4.2" -I"include"

g++.exe -c shutdown.cpp -o shutdown.o -I"lib/gcc/mingw32/3.4.2/include" -I"include/c++/3.4.2/backward" -I"include/c++/3.4.2/mingw32" -I"include/c++/3.4.2" -I"include"

g++.exe -c global.cpp -o global.o -I"lib/gcc/mingw32/3.4.2/include" -I"include/c++/3.4.2/backward" -I"include/c++/3.4.2/mingw32" -I"include/c++/3.4.2" -I"include"

g++.exe main.o init.o draw.o erase.o getinput.o ai.o move.o titlescreen.o shutdown.o global.o -o "Ba-Bounce.exe" -L"lib" -lalleg -lalpng

main.o(.text+0x9):main.cpp: undefined reference to `init'
main.o(.text+0x1a):main.cpp: undefined reference to `init'
main.o(.text+0x3b):main.cpp: undefined reference to `erase'
main.o(.text+0x4f):main.cpp: undefined reference to `erase'
main.o(.text+0x5b):main.cpp: undefined reference to `erase'
main.o(.text+0x6f):main.cpp: undefined reference to `motion'
main.o(.text+0x83):main.cpp: undefined reference to `motion'
main.o(.text+0x8f):main.cpp: undefined reference to `motion'
main.o(.text+0xa3):main.cpp: undefined reference to `draw'
main.o(.text+0xb7):main.cpp: undefined reference to `draw'
main.o(.text+0xc3):main.cpp: undefined reference to `draw'
main.o(.text+0xe2):main.cpp: undefined reference to `init'
main.o(.text+0xee):main.cpp: undefined reference to `draw'
init.o(.text+0x2ab):init.cpp: undefined reference to `erase'
init.o(.text+0x2bf):init.cpp: undefined reference to `erase'
init.o(.text+0x3c5):init.cpp: undefined reference to `draw'
init.o(.text+0x421):init.cpp: undefined reference to `draw'
init.o(.text+0x42d):init.cpp: undefined reference to `init'
erase.o(.text+0x20):erase.cpp: undefined reference to `draw'
erase.o(.text+0x4d):erase.cpp: undefined reference to `draw'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_filereader.o)(.text+0xe7):alpng_filereader.c: undefined reference to `pack_fread'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_filereader.o)(.text+0x13d):alpng_filereader.c: undefined reference to `pack_feof'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_filereader.o)(.text+0x155):alpng_filereader.c: undefined reference to `pack_ferror'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_filereader.o)(.text+0x161):alpng_filereader.c: undefined reference to `pack_mgetl'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_filereader.o)(.text+0x16f):alpng_filereader.c: undefined reference to `pack_feof'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_filereader.o)(.text+0x1a3):alpng_filereader.c: undefined reference to `pack_ferror'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_filereader.o)(.text+0x1af):alpng_filereader.c: undefined reference to `pack_mgetl'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_filereader.o)(.text+0x1ed):alpng_filereader.c: undefined reference to `pack_feof'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_filereader.o)(.text+0x209):alpng_filereader.c: undefined reference to `pack_ferror'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_filereader.o)(.text+0x215):alpng_filereader.c: undefined reference to `pack_mgetl'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_filereader.o)(.text+0x234):alpng_filereader.c: undefined reference to `pack_feof'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_filereader.o)(.text+0x24a):alpng_filereader.c: undefined reference to `pack_ferror'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_filereader.o)(.text+0x256):alpng_filereader.c: undefined reference to `pack_mgetl'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_filereader.o)(.text+0x26f):alpng_filereader.c: undefined reference to `pack_getc'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_filereader.o)(.text+0x289):alpng_filereader.c: undefined reference to `pack_getc'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_filereader.o)(.text+0x301):alpng_filereader.c: undefined reference to `pack_getc'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_filereader.o)(.text+0x322):alpng_filereader.c: undefined reference to `pack_getc'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_filereader.o)(.text+0x347):alpng_filereader.c: undefined reference to `pack_getc'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_filereader.o)(.text+0x380):alpng_filereader.c: undefined reference to `pack_igetl'

D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_filereader.o)(.text+0x388):alpng_filereader.c: undefined reference to `pack_feof'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_filereader.o)(.text+0x398):alpng_filereader.c: undefined reference to `pack_ferror'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_filereader.o)(.text+0x3a8):alpng_filereader.c: undefined reference to `pack_mgetl'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_filereader.o)(.text+0x3b6):alpng_filereader.c: undefined reference to `pack_feof'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_filereader.o)(.text+0x3c6):alpng_filereader.c: undefined reference to `pack_ferror'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_filereader.o)(.text+0x3d6):alpng_filereader.c: undefined reference to `pack_mgetl'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_filereader.o)(.text+0x400):alpng_filereader.c: undefined reference to `pack_fseek'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_filereader.o)(.text+0x488):alpng_filereader.c: undefined reference to `pack_fread'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_filereader.o)(.text+0x49c):alpng_filereader.c: undefined reference to `pack_igetl'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_filereader.o)(.text+0x4a4):alpng_filereader.c: undefined reference to `pack_feof'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_filereader.o)(.text+0x4b4):alpng_filereader.c: undefined reference to `pack_ferror'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_filereader.o)(.text+0x4c4):alpng_filereader.c: undefined reference to `pack_mgetl'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_filereader.o)(.text+0x4d2):alpng_filereader.c: undefined reference to `pack_feof'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_filereader.o)(.text+0x4e2):alpng_filereader.c: undefined reference to `pack_ferror'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_filereader.o)(.text+0x4f2):alpng_filereader.c: undefined reference to `pack_mgetl'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_filereader.o)(.text+0x5a3):alpng_filereader.c: undefined reference to `pack_getc'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_filereader.o)(.text+0x5d0):alpng_filereader.c: undefined reference to `pack_getc'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_filereader.o)(.text+0x5fb):alpng_filereader.c: undefined reference to `pack_getc'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_filereader.o)(.text+0x7bc):alpng_filereader.c: undefined reference to `_color_load_depth'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_filereader.o)(.text+0x808):alpng_filereader.c: undefined reference to `_fixup_loaded_bitmap'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_filereader.o)(.text+0x830):alpng_filereader.c: undefined reference to `generate_332_palette'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_filereader.o)(.text+0x852):alpng_filereader.c: undefined reference to `pack_fseek'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_filereader.o)(.text+0x862):alpng_filereader.c: undefined reference to `pack_igetl'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_filereader.o)(.text+0x86a):alpng_filereader.c: undefined reference to `pack_feof'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_filereader.o)(.text+0x87a):alpng_filereader.c: undefined reference to `pack_ferror'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_filereader.o)(.text+0x88a):alpng_filereader.c: undefined reference to `pack_mgetl'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_filereader.o)(.text+0x898):alpng_filereader.c: undefined reference to `pack_feof'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_filereader.o)(.text+0x8a4):alpng_filereader.c: undefined reference to `pack_ferror'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_filereader.o)(.text+0x8b0):alpng_filereader.c: undefined reference to `pack_mgetl'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_filereader.o)(.text+0x96a):alpng_filereader.c: undefined reference to `select_palette'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_filereader.o)(.text+0x987):alpng_filereader.c: undefined reference to `_fixup_loaded_bitmap'

D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_filereader.o)(.text+0x992):alpng_filereader.c: undefined reference to `unselect_palette'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_filereader.o)(.text+0xacc):alpng_filereader.c: undefined reference to `pack_fopen'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_filereader.o)(.text+0xaeb):alpng_filereader.c: undefined reference to `pack_fclose'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_common.o)(.text+0x30):alpng_common.c: undefined reference to `register_bitmap_file_type'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_common.o)(.text+0x4e):alpng_common.c: undefined reference to `register_datafile_object'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(octree.o)(.text+0x137):octree.c: undefined reference to `_imp___rgb_r_shift_32'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(octree.o)(.text+0x173):octree.c: undefined reference to `_imp___rgb_g_shift_32'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(octree.o)(.text+0x199):octree.c: undefined reference to `_imp___rgb_b_shift_32'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(octree.o)(.text+0x2a7):octree.c: undefined reference to `_imp___rgb_r_shift_16'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(octree.o)(.text+0x2af):octree.c: undefined reference to `_imp___rgb_scale_5'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(octree.o)(.text+0x2d6):octree.c: undefined reference to `_imp___rgb_g_shift_16'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(octree.o)(.text+0x2de):octree.c: undefined reference to `_imp___rgb_scale_6'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(octree.o)(.text+0x300):octree.c: undefined reference to `_imp___rgb_b_shift_16'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(octree.o)(.text+0x659):octree.c: undefined reference to `create_bitmap_ex'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(octree.o)(.text+0x79c):octree.c: undefined reference to `_imp___rgb_r_shift_24'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(octree.o)(.text+0x7d3):octree.c: undefined reference to `_imp___rgb_g_shift_24'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(octree.o)(.text+0x7fd):octree.c: undefined reference to `_imp___rgb_b_shift_24'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(octree.o)(.text+0x99f):octree.c: undefined reference to `_imp___rgb_r_shift_15'

D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(octree.o)(.text+0x9a7):octree.c: undefined reference to `_imp___rgb_scale_5'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(octree.o)(.text+0x9cb):octree.c: undefined reference to `_imp___rgb_g_shift_15'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(octree.o)(.text+0x9ed):octree.c: undefined reference to `_imp___rgb_b_shift_15'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(octree.o)(.text+0xb58):octree.c: undefined reference to `_imp___rgb_r_shift_32'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(octree.o)(.text+0xb94):octree.c: undefined reference to `_imp___rgb_g_shift_32'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(octree.o)(.text+0xbba):octree.c: undefined reference to `_imp___rgb_b_shift_32'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(octree.o)(.text+0xcc0):octree.c: undefined reference to `_imp___rgb_r_shift_24'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(octree.o)(.text+0xcf5):octree.c: undefined reference to `_imp___rgb_g_shift_24'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(octree.o)(.text+0xd1c):octree.c: undefined reference to `_imp___rgb_b_shift_24'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(octree.o)(.text+0xe25):octree.c: undefined reference to `_imp___rgb_r_shift_15'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(octree.o)(.text+0xe2d):octree.c: undefined reference to `_imp___rgb_scale_5'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(octree.o)(.text+0xe54):octree.c: undefined reference to `_imp___rgb_g_shift_15'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(octree.o)(.text+0xe79):octree.c: undefined reference to `_imp___rgb_b_shift_15'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(octree.o)(.text+0xf85):octree.c: undefined reference to `_imp___rgb_b_shift_15'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(octree.o)(.text+0xfc9):octree.c: undefined reference to `_imp___rgb_b_shift_24'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(octree.o)(.text+0x107f):octree.c: undefined reference to `_imp___rgb_r_shift_16'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(octree.o)(.text+0x1087):octree.c: undefined reference to `_imp___rgb_scale_5'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(octree.o)(.text+0x10ae):octree.c: undefined reference to `_imp___rgb_g_shift_16'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(octree.o)(.text+0x10b6):octree.c: undefined reference to `_imp___rgb_scale_6'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(octree.o)(.text+0x10d9):octree.c: undefined reference to `_imp___rgb_b_shift_16'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(octree.o)(.text+0x118e):octree.c: undefined reference to `_imp___rgb_b_shift_16'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_drawer.o)(.text+0xa8):alpng_drawer.c: undefined reference to `create_bitmap_ex'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_drawer.o)(.text+0x118):alpng_drawer.c: undefined reference to `_imp___rgb_g_shift_32'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_drawer.o)(.text+0x14c):alpng_drawer.c: undefined reference to `_imp___rgb_b_shift_32'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_drawer.o)(.text+0x180):alpng_drawer.c: undefined reference to `_imp___rgb_a_shift_32'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_drawer.o)(.text+0x1bb):alpng_drawer.c: undefined reference to `_imp___rgb_r_shift_32'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_drawer.o)(.text+0x206):alpng_drawer.c: undefined reference to `create_bitmap_ex'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_drawer.o)(.text+0x26b):alpng_drawer.c: undefined reference to `_imp___rgb_g_shift_32'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_drawer.o)(.text+0x29f):alpng_drawer.c: undefined reference to `_imp___rgb_b_shift_32'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_drawer.o)(.text+0x2d3):alpng_drawer.c: undefined reference to `_imp___rgb_a_shift_32'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_drawer.o)(.text+0x312):alpng_drawer.c: undefined reference to `_imp___rgb_r_shift_32'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_drawer.o)(.text+0x3b5):alpng_drawer.c: undefined reference to `create_bitmap_ex'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_drawer.o)(.text+0x421):alpng_drawer.c: undefined reference to `_imp___rgb_g_shift_24'

D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_drawer.o)(.text+0x455):alpng_drawer.c: undefined reference to `_imp___rgb_b_shift_24'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_drawer.o)(.text+0x49d):alpng_drawer.c: undefined reference to `_imp___rgb_r_shift_24'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_drawer.o)(.text+0x52c):alpng_drawer.c: undefined reference to `create_bitmap_ex'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_drawer.o)(.text+0x650):alpng_drawer.c: undefined reference to `create_bitmap_ex'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_drawer.o)(.text+0x6bf):alpng_drawer.c: undefined reference to `_imp___rgb_g_shift_32'

D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_drawer.o)(.text+0x6f3):alpng_drawer.c: undefined reference to `_imp___rgb_b_shift_32'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_drawer.o)(.text+0x727):alpng_drawer.c: undefined reference to `_imp___rgb_a_shift_32'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_drawer.o)(.text+0x762):alpng_drawer.c: undefined reference to `_imp___rgb_r_shift_32'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_drawer.o)(.text+0x7a0):alpng_drawer.c: undefined reference to `create_bitmap_ex'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_drawer.o)(.text+0x806):alpng_drawer.c: undefined reference to `_imp___rgb_g_shift_32'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_drawer.o)(.text+0x83a):alpng_drawer.c: undefined reference to `_imp___rgb_b_shift_32'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_drawer.o)(.text+0x86e):alpng_drawer.c: undefined reference to `_imp___rgb_a_shift_32'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_drawer.o)(.text+0x8ad):alpng_drawer.c: undefined reference to `_imp___rgb_r_shift_32'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_drawer.o)(.text+0x8ee):alpng_drawer.c: undefined reference to `create_bitmap_ex'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_drawer.o)(.text+0x94f):alpng_drawer.c: undefined reference to `_imp___rgb_g_shift_24'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_drawer.o)(.text+0x983):alpng_drawer.c: undefined reference to `_imp___rgb_b_shift_24'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_drawer.o)(.text+0x9ce):alpng_drawer.c: undefined reference to `_imp___rgb_r_shift_24'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_drawer.o)(.text+0xa0b):alpng_drawer.c: undefined reference to `create_bitmap_ex'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_drawer.o)(.text+0xa7e):alpng_drawer.c: undefined reference to `_imp___rgb_g_shift_24'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_drawer.o)(.text+0xab2):alpng_drawer.c: undefined reference to `_imp___rgb_b_shift_24'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_drawer.o)(.text+0xafa):alpng_drawer.c: undefined reference to `_imp___rgb_r_shift_24'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_drawer.o)(.text+0xc74):alpng_drawer.c: undefined reference to `create_bitmap_ex'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_interlacing.o)(.text+0x249):alpng_interlacing.c: undefined reference to `create_bitmap_ex'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_save.o)(.text+0x9f):alpng_save.c: undefined reference to `pack_putc'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_save.o)(.text+0xc2):alpng_save.c: undefined reference to `pack_mputl'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_save.o)(.text+0xdc):alpng_save.c: undefined reference to `pack_mputl'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_save.o)(.text+0x166):alpng_save.c: undefined reference to `pack_mputl'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_save.o)(.text+0x1f1):alpng_save.c: undefined reference to `pack_mputl'

D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_save.o)(.text+0x27b):alpng_save.c: undefined reference to `pack_putc'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_save.o)(.text+0x2d0):alpng_save.c: undefined reference to `pack_putc'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_save.o)(.text+0x30c):alpng_save.c: undefined reference to `pack_putc'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_save.o)(.text+0x335):alpng_save.c: undefined reference to `pack_putc'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_save.o)(.text+0x35e):alpng_save.c: undefined reference to `pack_putc'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_save.o)(.text+0x385):alpng_save.c: undefined reference to `pack_mputl'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_save.o)(.text+0x47d):alpng_save.c: undefined reference to `pack_mputl'

D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_save.o)(.text+0x497):alpng_save.c: undefined reference to `pack_mputl'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_save.o)(.text+0x520):alpng_save.c: undefined reference to `pack_putc'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_save.o)(.text+0x551):alpng_save.c: undefined reference to `pack_putc'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_save.o)(.text+0x5d0):alpng_save.c: undefined reference to `pack_putc'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_save.o)(.text+0x615):alpng_save.c: undefined reference to `pack_iputw'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_save.o)(.text+0x677):alpng_save.c: undefined reference to `pack_iputw'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_save.o)(.text+0x6d7):alpng_save.c: undefined reference to `pack_fwrite'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_save.o)(.text+0x7c5):alpng_save.c: undefined reference to `pack_mputl'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_save.o)(.text+0x847):alpng_save.c: undefined reference to `pack_mputl'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_save.o)(.text+0x867):alpng_save.c: undefined reference to `pack_mputl'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_save.o)(.text+0x881):alpng_save.c: undefined reference to `pack_mputl'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_save.o)(.text+0x908):alpng_save.c: undefined reference to `pack_mputl'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_save.o)(.text+0x98f):alpng_save.c: undefined reference to `getr_depth'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_save.o)(.text+0x9aa):alpng_save.c: undefined reference to `getg_depth'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_save.o)(.text+0x9c9):alpng_save.c: undefined reference to `getb_depth'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_save.o)(.text+0xa25):alpng_save.c: undefined reference to `getr_depth'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_save.o)(.text+0xa40):alpng_save.c: undefined reference to `getg_depth'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_save.o)(.text+0xa5f):alpng_save.c: undefined reference to `getb_depth'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_save.o)(.text+0xa7e):alpng_save.c: undefined reference to `geta_depth'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_save.o)(.text+0xabd):alpng_save.c: undefined reference to `pack_putc'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_save.o)(.text+0xaf7):alpng_save.c: undefined reference to `pack_mputl'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_save.o)(.text+0xb11):alpng_save.c: undefined reference to `pack_mputl'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_save.o)(.text+0xbc0):alpng_save.c: undefined reference to `pack_putc'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_save.o)(.text+0xbf3):alpng_save.c: undefined reference to `pack_putc'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_save.o)(.text+0xc36):alpng_save.c: undefined reference to `pack_putc'

D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_save.o)(.text+0xca5):alpng_save.c: undefined reference to `_imp___rgb_a_shift_32'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_save.o)(.text+0xcc0):alpng_save.c: undefined reference to `pack_putc'

D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_save.o)(.text+0xd1b):alpng_save.c: undefined reference to `pack_mputl'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_save.o)(.text+0xd9c):alpng_save.c: undefined reference to `pack_fopen'
D:/Programs/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../libalpng.a(alpng_save.o)(.text+0xdc2):alpng_save.c: undefined reference to `pack_fclose'
collect2: ld returned 1 exit status

make.exe: *** [Ba-Bounce.exe] Error 1

Execution terminated

FULL SOURCE

Share this post


Link to post
Share on other sites
you don't need to extern the type definition, just the variable definition. That why I was saying you should get into the habit of doing things in this format:


struct MyStruct
{
...
};

extern MyStruct foo;


this is so that you can later do stuff like:

struct MyStruct
{
...
};

extern MyStruct foo;
extern MyStruct bar;


that's nice and clean.

If you were to use the pattern you are currently using it would end up looking like this:

extern struct MyStruct
{
...
} foo;
extern MyStruct bar;


which is confusing. =)

-me

Share this post


Link to post
Share on other sites
these are your code errors:
Quote:

main.o(.text+0x9):main.cpp: undefined reference to `init'
main.o(.text+0x1a):main.cpp: undefined reference to `init'
main.o(.text+0x3b):main.cpp: undefined reference to `erase'
main.o(.text+0x4f):main.cpp: undefined reference to `erase'
main.o(.text+0x5b):main.cpp: undefined reference to `erase'
main.o(.text+0x6f):main.cpp: undefined reference to `motion'
main.o(.text+0x83):main.cpp: undefined reference to `motion'
main.o(.text+0x8f):main.cpp: undefined reference to `motion'
main.o(.text+0xa3):main.cpp: undefined reference to `draw'
main.o(.text+0xb7):main.cpp: undefined reference to `draw'
main.o(.text+0xc3):main.cpp: undefined reference to `draw'
main.o(.text+0xe2):main.cpp: undefined reference to `init'
main.o(.text+0xee):main.cpp: undefined reference to `draw'
init.o(.text+0x2ab):init.cpp: undefined reference to `erase'
init.o(.text+0x2bf):init.cpp: undefined reference to `erase'
init.o(.text+0x3c5):init.cpp: undefined reference to `draw'
init.o(.text+0x421):init.cpp: undefined reference to `draw'
init.o(.text+0x42d):init.cpp: undefined reference to `init'
erase.o(.text+0x20):erase.cpp: undefined reference to `draw'
erase.o(.text+0x4d):erase.cpp: undefined reference to `draw'


the rest of the garbage means that you're not linking to the correct .lib files. Basically you're using some API so you need to fill in some box or other in DevC++ with the appropriate <fileName>.lib entry.

i'll take a look at your code in a sec to figure out your actual linker errors.

-me

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this