ld returned 1 exit status

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

Hi,

   

      I have a project with a number of files in subdirectories and a main holding it all together.  I have added a new c & h file in a new directory and when I try to build I get the above error on link.  There are no errors in any of the compiles. This is the output of the link line and the only error is the ld error.

   

Why is the main.o in there twice and is that the problem ?  How would I fix that ?

   

Thanks for the help

   

--jim schimpf

   

arm-none-eabi-gcc.exe -Wl,--start-group -o
.\CortexM0\ARM_GCC_493\Debug\PneuTool.elf
.\CortexM0\ARM_GCC_493\Debug\gCorder.o
.\CortexM0\ARM_GCC_493\Debug\mma8451.o
.\CortexM0\ARM_GCC_493\Debug\Sound.o
.\CortexM0\ARM_GCC_493\Debug\EnvBoard.o
.\CortexM0\ARM_GCC_493\Debug\main.o .\CortexM0\ARM_GCC_493\Debug\main.o
.\CortexM0\ARM_GCC_493\Debug\cymetadata.o
.\CortexM0\ARM_GCC_493\Debug\Cm0Start.o
.\CortexM0\ARM_GCC_493\Debug\PneuTool.a "C:\Program Files
(x86)\Cypress\PSoC Creator\3.3\PSoC
Creator\psoc\content\cycomponentlibraryupdates\CyComponentLibraryUpdates
.cylib\BLE_v3_10\Library\gccCyBLEStack_BLE_SOC_PERIPHERAL.a" "C:\Program
Files (x86)\Cypress\PSoC Creator\3.3\PSoC
Creator\psoc\content\cycomponentlibrary\CyComponentLibrary.cylib\
CortexM0\ARM_GCC_493\Debug\CyComponentLibrary.a" -mcpu=cortex-m0 -mthumb
-g -ffunction-sections -O0 -L Generated_Source\PSoC4
-Wl,-Map,.\CortexM0\ARM_GCC_493\Debug/PneuTool.map -T
Generated_Source\PSoC4\cm0gcc.ld -specs=nano.specs -Wl,--gc-sections
-Wl,--end-group

   


.\CortexM0\ARM_GCC_493\Debug\main.o: file not recognized: File format not recognized
collect2.exe: error: ld returned 1 exit status

0 Likes
1 Solution
Anonymous
Not applicable

Fixed it !!

   

main.c was getting compiled twice (see above) and the build was failing. To fix it. (1) Removed main.c/main.h from the project (2) Cleaned and re-built the project (this would fail). (3) Put main.c and main.h back into the project.  Then it built fine.

   

Thanks for the help

View solution in original post

0 Likes
3 Replies
HeLi_263931
Level 8
Level 8
100 solutions authored 50 solutions authored 25 solutions authored

Can you try a clean build? When the file format of  main.o is not regocnized it might just be corrupted somehow...

0 Likes
Anonymous
Not applicable

Thanks but the same thing happened ld 1 error again on main.o

   

--jim schimpf

0 Likes
Anonymous
Not applicable

Fixed it !!

   

main.c was getting compiled twice (see above) and the build was failing. To fix it. (1) Removed main.c/main.h from the project (2) Cleaned and re-built the project (this would fail). (3) Put main.c and main.h back into the project.  Then it built fine.

   

Thanks for the help

0 Likes