PDA

View Full Version : C++ compilation Problems



Lukeson
September 21st, 2006, 16:25
Hi

when I try to compile my main.cpp, I get this:


main.o: In function `main':
main.cpp:(.text+0xf0): undefined reference to `initGraphics()'
main.cpp:(.text+0xfc): undefined reference to `loadImage(char const*)'
main.cpp:(.text+0x108): undefined reference to `loadImage(char const*)'
main.cpp:(.text+0x114): undefined reference to `loadImage(char const*)'
main.cpp:(.text+0x120): undefined reference to `loadImage(char const*)'
main.cpp:(.text+0x12c): undefined reference to `loadImage(char const*)'
main.cpp:(.text+0x230): undefined reference to `clearScreen(unsigned int)'
main.cpp:(.text+0x27c): undefined reference to `printTextScreen(int, int, char c
onst*, unsigned int)'
main.cpp:(.text+0x2d0): undefined reference to `printTextScreen(int, int, char c
onst*, unsigned int)'
main.cpp:(.text+0x32c): undefined reference to `printTextScreen(int, int, char c
onst*, unsigned int)'
main.cpp:(.text+0x394): undefined reference to `printTextScreen(int, int, char c
onst*, unsigned int)'
main.cpp:(.text+0x3e8): undefined reference to `printTextScreen(int, int, char c
onst*, unsigned int)'
main.cpp:(.text+0x3f0): undefined reference to `flipScreen()'
main.cpp:(.text+0x4a4): undefined reference to `clearScreen(unsigned int)'
main.cpp:(.text+0x4ec): undefined reference to `printTextScreen(int, int, char c
onst*, unsigned int)'
main.cpp:(.text+0x534): undefined reference to `printTextScreen(int, int, char c
onst*, unsigned int)'
main.cpp:(.text+0x580): undefined reference to `printTextScreen(int, int, char c
onst*, unsigned int)'
main.cpp:(.text+0x5d8): undefined reference to `printTextScreen(int, int, char c
onst*, unsigned int)'
main.cpp:(.text+0x630): undefined reference to `printTextScreen(int, int, char c
onst*, unsigned int)'
main.cpp:(.text+0x638): undefined reference to `flipScreen()'
collect2: ld returned 1 exit status
make: *** [pspwAMPxmb.elf] Error 1

I do have #included "graphics.h" and the makefile contains OBJS = main.o graphics.o framebuffer.o

What do I do wrong?

yaustar
September 21st, 2006, 17:44
Looks like you haven't linked in the libraries need for the graphics functions that you are using. Are you linking with gcc or g++?

Lukeson
September 21st, 2006, 18:57
gcc. The wierd thing is I defninitely have linked and included everything correctly. It seems that you can't use the C graphics.h libraries in C++... :(

yaustar
September 21st, 2006, 20:49
Yes you can. Again, are you linking with gcc or g++?

Lukeson
September 22nd, 2006, 16:30
gcc

yaustar
September 22nd, 2006, 17:34
If you are using C++ you MUST compile AND link with g++ NOT gcc.

yaustar
September 22nd, 2006, 23:27
Beyond the above error, your code/file structure is at fault. Host up ALL your code on to a server somewhere so people can download it.