Author Topic: Including IAR-specific Library Function Definitions  (Read 2899 times)

Offline Elliott99

  • Single posting newcomer
  • *
  • Posts: 2
Including IAR-specific Library Function Definitions
« on: December 02, 2024, 11:28:14 pm »
I am building a generic CodeBlocks project using the IAR compiler.

When I attempt to build, I get the error message:

"Error[Li005]: no definition for "__write" [referenced from
          putchar.o(dl7M_tlf.a)]"

It seems that the linker cannot find a definition for the IAR library function __write. The IAR compiler includes a definition for this library function in the installation directory arm/src/lib/file, where there is a write.c file. Adding the write.c file directly to the project allows me to fully link and generate a project executable. The problem is, this is very clunky and as other people at my job will be using this CodeBlocks + IAR framework, I'd prefer to not have to include a long relative path dependent on the install location of the IAR compiler.

Is there some compiler-dependent flag I can use to avoid this? Perhaps I can redirect the __write library Or some better inclusion method that doesn;t involve including a very long relative path? Even just defining a dummy void write() function somewhere?

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7699
    • My Best Post
Re: Including IAR-specific Library Function Definitions
« Reply #1 on: December 03, 2024, 12:37:54 am »
« Last Edit: December 03, 2024, 12:41:50 am by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline Elliott99

  • Single posting newcomer
  • *
  • Posts: 2
Re: Including IAR-specific Library Function Definitions
« Reply #2 on: December 07, 2024, 04:40:18 pm »
Thanks for the reply, and apologies for the slow response.

Attached is the rebuild log. As I said before, directly including the write.c file as one of the compiler targets fixes this, but directly including a very long absolute path to the IAR library source files seems like a poor solution.

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7699
    • My Best Post
Re: Including IAR-specific Library Function Definitions
« Reply #3 on: December 07, 2024, 09:44:53 pm »
A wild guess from Google results is trying "-r" in other linker options.

You will likely need to figure out how to look at and understand the output of your Compiler and Linker.
This will likely result in your reading the manual for both of them.

Edit: If the "-r" option does not make a difference, I would remove the option.

Edit3: I really wish you read and followed the links! Because you did not you are going to get poor feedback. Goodbye!

Tim S.
« Last Edit: December 07, 2024, 11:04:21 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7699
    • My Best Post
Re: Including IAR-specific Library Function Definitions
« Reply #4 on: December 09, 2024, 12:14:48 am »
You have the folder "Trojan Battery Dropbox" implies a special folder. You might try not using a special folder.

Edit: If I was you, I would search for libraries in the compiler installation folder, likely with ".a" extension and try them in the CB project library list one at a time till I find the one to fix the first linking error you got.

Tim S.
« Last Edit: December 09, 2024, 03:16:23 am by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org