Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Compiler starts linking after first source file(which results in an error because other source files not compiled yet)
icon5.gif  Compiler starts linking after first source file [message #1726748] Wed, 16 March 2016 07:29 Go to next message
Gerard van den Bosch is currently offline Gerard van den BoschFriend
Messages: 2
Registered: March 2016
Junior Member
Hello,

I am trying to compile a project with a crosscompiler.
I have created a new C project with crosscompiler option and configured the location of my crosscompiler.
The make file is generated by eclipse.

I have added several subfolders with C source files.

When I start compiling it seems that after compiling the first source file it directly tries to link it and then tells me that it can't find "main" function which is in another source file that isn't compiled yet.

Following is my output:
make all 
Building file: ../Setup/BSP.c
Invoking: Cross GCC Compiler
arm-none-eabi-gcc -DDEBUG=1 -DCORE_M4=1 -I"/home/gerard/workspaceluna/segger_testing/Inc" -I"/home/gerard/workspaceluna/segger_testing/DeviceSupport" -I"/home/gerard/workspaceluna/segger_testing/CoreSupport" -O0 -g -Wall -mthumb -ffunction-sections -fdata-sections -mcpu=cortex-m4 -mno-thumb-interwork --specs=nosys.specs -MMD -MP -MF"Setup/BSP.d" -MT"Setup/BSP.d" -o "Setup/BSP.o" "../Setup/BSP.c"
/home/gerard/gcc-arm-none-eabi-4_8-2014q3/bin/../lib/gcc/arm-none-eabi/4.8.4/../../../../arm-none-eabi/lib/armv7e-m/crt0.o: In function `_start':
(.text+0x4a): undefined reference to `main'
collect2: error: ld returned 1 exit status
Setup/subdir.mk:64: recipe for target 'Setup/BSP.o' failed
make: *** [Setup/BSP.o] Error 1


How can I get my project in a way that it first compiles all C files before it starts linking them?

Cheers,
Gerard
Re: Compiler starts linking after first source file [message #1726808 is a reply to message #1726748] Wed, 16 March 2016 16:00 Go to previous message
David Vavra is currently offline David VavraFriend
Messages: 619
Registered: October 2012
Senior Member
The way to create only an object file from a source file with GCC is to use the -c flag;.
https://gcc.gnu.org/onlinedocs/gcc/Overall-Options.html#Overall-Options

This flag is missing from your compile command so it will compile AND link.
I suppose you are letting Eclipse create the makefile so go to the tool chain settings and add the -c flag.
If for some reason you can't then you'll have to resort to using a custom makefile.

Previous Topic:Issue with Standalone debugger and runtime directory
Next Topic:[dsf-gdb] service which requires multiple commands
Goto Forum:
  


Current Time: Thu Nov 23 16:40:07 GMT 2017

Powered by FUDForum. Page generated in 0.01991 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software