Linking of application failed with: can’t link soft-float modules with single-float modules

When building an application for RISC-V you may get following linking error:

can't link soft-float modules with single-float modules

The problem is that ABI of the library does not match the application. You can use following command to check flags:

readelf -h path_to_library
...
  Class:                             ELF32
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              REL (Relocatable file)
  Machine:                           RISC-V
  Version:                           0x1
  Entry point address:               0x0
  Start of program headers:          0 (bytes into file)
  Start of section headers:          736 (bytes into file)
  Flags:                             0x1, RVC, soft-float ABI

The solution is to build the library with the same flags like the rest of application. This can be achieved by using following flags for CMake.

-DCMAKE_C_FLAGS=-march=rv32imafc -mabi=ilp32f
-DCMAKE_CXX_FLAGS=-march=rv32imafc -mabi=ilp32f

If your target has different support for float, you might need to change suggested march and mabi.