IAR Compiler linking static libraries compiled with GCC

Go To Last Post
7 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I compiled an application with avr-gcc. Next, I archived it into a library, using avr-ar and output libmylib.a . Now I'd like to link that library to another application which will be compiled using IAR Workbench.

From the manual, I couldn't figure out how to do this. Under the XLink section, it says use

-C file

to load a program as library. I put this in the Linker options .. Doing so will output "identifier xyy is undefined" when compiling.

How would you work around this?
Thank you.

P.S.
Even if avr-ar output libraries were incompatible with IAR Workbench, I can still make a xar mylib.r90 *.o on the avr-gcc compiler output object files...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
How would you work around this?
Rebuild the libraries using IAR. It seems unlikely the object formats are compatible to the linker.

--greg
Still learning, don't shout at me, educate me.
Starting the fire is easy; the hardest part is learning how to keep the flame!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Do not even dream about linking incompatible compilers.

Maintain your source code in one flavour of C Compiler.

Add a rule to your Makefile that pre-processes your preferred dialect into the target dialect before compilation. Always use the tools supplied with each toolchain. Rebuild each library with each toolchain.

Any attempt to link 'foreign' objects is going to give you serious grief. It is not impossible, just unwise.

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

thank you for your ideas.
Object files are ELF-format, which makes no difference between GCC for PC , GCC for AVR or IAR.

I have a compilation/linkage error because of not being able to specify the shared library to IAR. In gcc you do this with

-llibname 
-LpathToLibrary 

How is this done in IAR?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Do you not have the help files installed with the IAR compiler? They must explain what each option does and how to set it?
I'm certain this is very simple, why not ask IAR support for help?

--greg
Still learning, don't shout at me, educate me.
Starting the fire is easy; the hardest part is learning how to keep the flame!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I think's it's a wiser ideea to go what you people said earlier, recompile with one toolchain. :D

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

while the elf file format is a standard, the binary that is contained is unique to each compiler [in terms of runtime implementation]. GCC and IAR use very different runtime models [one stack vs two stacks, different register allocations & calling conventions...], so even if you did manage to link the code, it is highly unlikely that the program will operate as desired.

Writing code is like having sex.... make one little mistake, and you're supporting it for life.