LDFLAGS += -Wl -Wall -lpthread -lc -ldl
LDFLAGS += -Wl -lpthread
在编译链接的时候出现了如下的错误:
gcc: error: unrecognized command line option ‘-Wl’
gcc: error: unrecognized command line option ‘-Wl’
通过gcc -v查看gcc版本如下:
root:~# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.8/lto-wrapper
Target: x86_64-linux-gnu
gcc version 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04)
求大神帮助!
6 个解决方案
#1
自顶一把
#2
#3
-fsyntax-only -pedantic -pedantic-errors -w -Wextra -Wall -Waddress -Waggregate-return
-Warray-bounds -Wno-attributes -Wno-builtin-macro-redefined -Wc++-compat -Wc++0x-compat -Wcast-align
-Wcast-qual -Wchar-subscripts -Wclobbered -Wcomment -Wconversion -Wcoverage-mismatch -Wno-deprecated
-Wno-deprecated-declarations -Wdisabled-optimization -Wno-div-by-zero -Wempty-body -Wenum-compare
-Wno-endif-labels -Werror -Werror=* -Wfatal-errors -Wfloat-equal -Wformat -Wformat=2
-Wno-format-contains-nul -Wno-format-extra-args -Wformat-nonliteral -Wformat-security -Wformat-y2k
-Wframe-larger-than=len -Wignored-qualifiers -Wimplicit -Wimplicit-function-declaration -Wimplicit-int
-Winit-self -Winline -Wno-int-to-pointer-cast -Wno-invalid-offsetof -Winvalid-pch -Wlarger-than=len
-Wunsafe-loop-optimizations -Wlogical-op -Wlong-long -Wmain -Wmissing-braces
-Wmissing-field-initializers -Wmissing-format-attribute -Wmissing-include-dirs -Wmissing-noreturn
-Wno-mudflap -Wno-multichar -Wnonnull -Wno-overflow -Woverlength-strings -Wpacked
-Wpacked-bitfield-compat -Wpadded -Wparentheses -Wpedantic-ms-format -Wno-pedantic-ms-format
-Wpointer-arith -Wno-pointer-to-int-cast -Wredundant-decls -Wreturn-type -Wsequence-point -Wshadow
-Wsign-compare -Wsign-conversion -Wstack-protector -Wstrict-aliasing -Wstrict-aliasing=n
-Wstrict-overflow -Wstrict-overflow=n -Wswitch -Wswitch-default -Wswitch-enum -Wsync-nand
-Wsystem-headers -Wtrigraphs -Wtype-limits -Wundef -Wuninitialized -Wunknown-pragmas -Wno-pragmas
-Wunreachable-code -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value
-Wunused-variable -Wunused-but-set-parameter -Wunused-but-set-variable -Wvariadic-macros -Wvla
-Wvolatile-register-var -Wwrite-strings
#4
哪来的 Wl,什么意思?
#5
4L ,-Wl选项告诉编译器将后面的参数传递给链接器,如果连接器通过被编译器驱动来间接引用(比如gcc), 那所有的连接器命令行选项前必须加上前缀'-Wl'
#6
应该是 -Wl, 后面一个 逗号 吧
#1
自顶一把
#2
#3
-fsyntax-only -pedantic -pedantic-errors -w -Wextra -Wall -Waddress -Waggregate-return
-Warray-bounds -Wno-attributes -Wno-builtin-macro-redefined -Wc++-compat -Wc++0x-compat -Wcast-align
-Wcast-qual -Wchar-subscripts -Wclobbered -Wcomment -Wconversion -Wcoverage-mismatch -Wno-deprecated
-Wno-deprecated-declarations -Wdisabled-optimization -Wno-div-by-zero -Wempty-body -Wenum-compare
-Wno-endif-labels -Werror -Werror=* -Wfatal-errors -Wfloat-equal -Wformat -Wformat=2
-Wno-format-contains-nul -Wno-format-extra-args -Wformat-nonliteral -Wformat-security -Wformat-y2k
-Wframe-larger-than=len -Wignored-qualifiers -Wimplicit -Wimplicit-function-declaration -Wimplicit-int
-Winit-self -Winline -Wno-int-to-pointer-cast -Wno-invalid-offsetof -Winvalid-pch -Wlarger-than=len
-Wunsafe-loop-optimizations -Wlogical-op -Wlong-long -Wmain -Wmissing-braces
-Wmissing-field-initializers -Wmissing-format-attribute -Wmissing-include-dirs -Wmissing-noreturn
-Wno-mudflap -Wno-multichar -Wnonnull -Wno-overflow -Woverlength-strings -Wpacked
-Wpacked-bitfield-compat -Wpadded -Wparentheses -Wpedantic-ms-format -Wno-pedantic-ms-format
-Wpointer-arith -Wno-pointer-to-int-cast -Wredundant-decls -Wreturn-type -Wsequence-point -Wshadow
-Wsign-compare -Wsign-conversion -Wstack-protector -Wstrict-aliasing -Wstrict-aliasing=n
-Wstrict-overflow -Wstrict-overflow=n -Wswitch -Wswitch-default -Wswitch-enum -Wsync-nand
-Wsystem-headers -Wtrigraphs -Wtype-limits -Wundef -Wuninitialized -Wunknown-pragmas -Wno-pragmas
-Wunreachable-code -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value
-Wunused-variable -Wunused-but-set-parameter -Wunused-but-set-variable -Wvariadic-macros -Wvla
-Wvolatile-register-var -Wwrite-strings
#4
哪来的 Wl,什么意思?
#5
4L ,-Wl选项告诉编译器将后面的参数传递给链接器,如果连接器通过被编译器驱动来间接引用(比如gcc), 那所有的连接器命令行选项前必须加上前缀'-Wl'
#6
应该是 -Wl, 后面一个 逗号 吧