开发者

Makefile Issue in Eclipse CDT

开发者 https://www.devze.com 2023-03-29 07:11 出处:网络
When I try to compile my program, I get the following: **** Build of configuration Debug for project SpaceInvaders ****

When I try to compile my program, I get the following:

**** 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 ****

I believe the main issue is founded on that of the relocation specifier which states that relocation 1 - 20 has an invalid symbol at indexes 14, 2, 22, 12, and 13.

What do I do about this? I know virtually next to nothing about a makefile. I saw a potential duplicate which asked the same questions, but the answers invoked assumed that the user actually knew how to use a makefile. If anyone could point me in the right direction, that would be very grand.


The underlying error here is actually the last one: 'undefined reference to `main'. G++'s way of reporting that isn't exactly the best...

You need to have a function called 'main' to start up most types of application (types that don't work that way, like embedded or smart-phone applications, will have their own instructions on how to do the equivalent somewhere). The file that contains that function needs to be listed in the makefile. If Eclipse is managing the makefile, then the file containing that function needs to be known to Eclipse.

In this case, I see you are using SDL (Simple DirectMedia Layer, as appropriate for games like Space Invaders). This is one of the types of application that, I think, doesn't have a simple user-written main. Instead there is some kind of low-level magic going on behind the scenes to set everything up. The error means that magic is failing, and however you are configuring it, it's not working to come together to make a complete system.

If you are not an expert on Eclipse and C++, what you will need is a tutorial on how to set things up correctly in your specific environment. Try, for example: http://davw.nfshost.com/c/sdl_eclipse.html

I suspect the relevant bit is 'In the Compiler->Preprocessor section, add the defined symbol "main=SDL_main"'.

0

精彩评论

暂无评论...
验证码 换一张
取 消