简体   繁体   中英

How do I treat linker warnings as errors with Clang?

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 )

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

-Wl,--fatal-warnings
-Wl means pass 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM