How do I treat linker warnings as errors with Clang?

990 views Asked by At

I am using cmake.

I tried

-fatal-warnings (mentioned here)

-fatal_warnings (which is mentioned with man ld)

Are those supposed to be used with -W?

I would like all linker warnings across the whole project to be an error.

The warning I get is:

ld: warning: ignoring file libvst2sdk.a, building for macOS-arm64 but attempting to link with file built for unknown-unsupported file format ( 0x21 0x3C 0x61 0x72 0x63 0x68 0x3E 0x0A 0x23 0x31 0x2F 0x32 0x30 0x20 0x20 0x20 )

1

There are 1 answers

0
KAlO2 On

-Werror is a compiling flag that treat warnings as errors, and it's not a linker flag.

-Wl,--fatal-warnings
-Wl means passing options to linker.

and here is pass 3 options to linker seperated by space:
-Wl,--build-id -Wl,--warn-shared-textrel -Wl,--fatal-warnings
or seperated by comma:
-Wl,--build-id,--warn-shared-textrel,--fatal-warnings