Author Topic: Linker Error  (Read 2356 times)

Offline joneewheelock

  • Multiple posting newcomer
  • *
  • Posts: 11
Linker Error
« on: July 26, 2016, 07:20:56 am »
I have problem with linking when I use code::Blocks for AVR. I used Atrduino library and few arduino header files during compilation. Issue comes only in CB. There is no issue if I build with Atmel Studio. Could not find the exact problem.

Also attached log from Codeblocks and  both Atmel Studio (not complete log. Just linking related).

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 2930
Re: Linker Error
« Reply #1 on: July 26, 2016, 12:02:55 pm »
i am not quiet sure, but i think your linking commands are wrong...
Code
avr-g++.exe -LC:\WinAVR\avr\lib -o Debug\CPP_Project_With_Core.a_Library.elf Debug\ir_Aiwa.o Debug\ir_Denon.o Debug\ir_Dish.o Debug\ir_JVC.o Debug\ir_Lego_PF.o Debug\ir_LG.o Debug\ir_Mitsubishi.o Debug\ir_NEC.o Debug\ir_Panasonic.o Debug\ir_RC5_RC6.o Debug\ir_Samsung.o Debug\ir_Sanyo.o Debug\ir_Sharp.o Debug\ir_Sony.o Debug\ir_Template.o Debug\ir_Whynter.o Debug\irPronto.o Debug\irRecv.o Debug\IRremote.o Debug\irSend.o Debug\main.o  -mmcu=atmega328p -Wl, -lm -Map=Debug\CPP_Project_With_Core.a_Library.map,--cref  Library\libcore.a
c:/winavr-20100110/bin/../lib/gcc/avr/4.3.3/../../../../avr/bin/ld.exe: : No such file: Invalid argument
avr-g++.exe: unrecognized option '-Map=Debug\CPP_Project_With_Core.a_Library.map,--cref'

in your linker commands*) there should be this line:
Code
-Wl,-Map=$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).map,--cref
No white spaces there...

greetings

*) Project->Build Options->Select the top most in the tree view on the left->Linker settings->Other linker options

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 2930
Re: Linker Error
« Reply #2 on: July 26, 2016, 12:15:30 pm »
Yes, your linker commands are messed up...
Code
-Wl, -lm -Map=Debug\CPP_Project_With_Core.a_Library.map,--cref

Code
-Wl
says the compiler to pass the following commands to the linker. The commands are separated with ','
Code
-lm
tells the linker to use the library libm.a (don't think that this is necessary...
Code
-Map=Debug\CPP_Project_With_Core.a_Library.map
tells the linker to create a map file. This option has to be passed to the linker with '-Wl' but there is a missing ',' and the command gets interpreted ass a g++ command... And g++ does not know what this is...

Offline joneewheelock

  • Multiple posting newcomer
  • *
  • Posts: 11
Re: Linker Error
« Reply #3 on: July 27, 2016, 03:18:09 am »
Great, Thank You. Works now. I was not familiar with Make file or Linker arguments. Used defaults that I used with AVR-C programs. But started giving problem with CPP programs. My options are now:
-Wl,-Map=$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).map,--cref