2011-08-20 76 views
1

当我尝试编译我的程序,我得到如下:Makefile的问题

**** Build of configuration Debug for project SpaceInvaders **** 

make all 
Building target: SpaceInvaders 
Invoking: GCC C++ Linker 
g++ -o "SpaceInvaders" ./src/SpaceInvaders.o -lSDLmain -lSDL 
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 0 has invalid symbol index 12 
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 1 has invalid symbol index 13 
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 2 has invalid symbol index 2 
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 3 has invalid symbol index 2 
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 4 has invalid symbol index 12 
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 5 has invalid symbol index 14 
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 6 has invalid symbol index 14 
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 7 has invalid symbol index 14 
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 8 has invalid symbol index 2 
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 9 has invalid symbol index 2 
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 10 has invalid symbol index 13 
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 11 has invalid symbol index 14 
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 12 has invalid symbol index 14 
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 13 has invalid symbol index 14 
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 14 has invalid symbol index 14 
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 15 has invalid symbol index 14 
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 16 has invalid symbol index 14 
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 17 has invalid symbol index 14 
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 18 has invalid symbol index 14 
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 19 has invalid symbol index 14 
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 20 has invalid symbol index 14 
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 21 has invalid symbol index 14 
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 22 has invalid symbol index 22 
/usr/lib/gcc/i486-linux-gnu/4.4.3/../../../../lib/crt1.o: In function `_start': 
(.text+0x18): undefined reference to `main' 
collect2: ld returned 1 exit status 
make: *** [SpaceInvaders] Error 1 

**** Build Finished **** 

我认为主要问题是建立在重定位符其中指出,搬迁1 - 20具有索引14,2,22,12和13处的无效符号。

该怎么办?我知道几乎没有任何关于makefile的知识。我看到一个潜在的重复问了相同的问题,但是调用的答案假定用户确实知道如何使用makefile。如果任何人都能指引我走向正确的方向,那将是非常宏伟的。

回答

1

这里的底层错误实际上是最后一个错误:'未定义的对'main'的引用。 G ++的报告方式并不完全是最好的......

您需要有一个名为'main'的函数来启动大多数类型的应用程序(类型不能以这种方式工作,如嵌入式或智能型,电话应用程序,将有他们自己的指示如何做相应的地方)。包含该函数的文件需要在makefile中列出。如果Eclipse正在管理makefile,那么包含该函数的文件需要被Eclipse知道。

在这种情况下,我看到您正在使用SDL(Simple DirectMedia Layer,适用于Space Invaders等游戏)。这是我认为没有简单的用户编写的主应用程序的应用程序类型之一。相反,幕后会有一些低级魔法来设置一切。这个错误意味着魔法失败了,然而,无论您如何配置它,它都无法组成一个完整的系统。

如果您不是Eclipse和C++的专家,您需要的是关于如何在特定环境中正确设置的教程。尝试,例如: http://davw.nfshost.com/c/sdl_eclipse.html

我怀疑相关位是'在编译器 - >预处理器部分,添加定义的符号“main = SDL_main”'。

+0

谢谢您的回复。我看到你在说什么 - 我会直接进入Eclipse创建和改变的makefile吗?这是在C/C++中,我已经有一个主要的方法,它返回0。 – zeboidlund