Switching the selected C library
Recent versions of the Code Red IDE provide a simple way of switching the selected C library from Redlib <-> Newlib, and switching the library variant in use from Semihost <-> Nohost <-> None. To switch go to:
Quickstart -> Quick Settings -> Set library type
and select the required library and variant.
Alternatively, you can make the required changes to your project properties manually as follows...
The 2 libraries use different header files. When switching between Newlib and Redlib libraries you must also switch the headers. To do this:
- Select the project in Project Explorer
- Right-click and select Properties
- Expand C/C++ Build and select Settings
- In the Tools settings tab, select Target under MCU Compiler
- In Use header for C library, select Newlib or Redlib
Repeat the above sequence for all Build Configurations (typically Debug and Release).
To then change the libraries actually being linked with (assuming you are using Managed linker scripts):
- Select the project in Project Explorer
- Right-click and select Properties
- Expand C/C++ Build and select Settings
- In the Tools settings tab, select Target under MCU Linker
- In Use C library, select the Newlib or Redlib library variant that you require (None, Nohost, Semihost).
Again repeat the above sequence for all Build Configurations (typically Debug and Release).
Library variants
For an explanation of the library variants, please see the FAQ What are none, nohost and semihost libraries?.
Library selection if using your own linker scripts
If you are providing your own linker script (you are not using the "Manage linker script" option), you will need to add one of the following entries before the SECTION line in your linker script:
Redlib
- for None add
GROUP(libcr_c.a libcr_eabihelpers.a)
- for Nohost, add
GROUP(libcr_nohost.a libcr_c.a libcr_eabihelpers.a)
- for Semihost, add
GROUP(libcr_semihost.a libcr_c.a libcr_eabihelpers.a)
Newlib
- for None, add
GROUP(libgcc.a libc.a libm.a)
- for Nohost, add
GROUP(libgcc.a libc.a libm.a libcr_newlib_nohost.a)
- for Semihost, add
GROUP(libgcc.a libc.a libm.a libcr_newlib_semihost.a)
