简体   繁体   English

gcc:错误:Makfile中无法识别的命令行选项“ -Wl”

[英]gcc: error: unrecognized command line option '-Wl' in Makfile

I run the command " make test " in this source code: 我在此源代码中运行命令“ make test ”:

https://github.com/sanandrea/CSecretKey https://github.com/sanandrea/CSecretKey

but it give me this error : 但是它给了我这个错误

gcc: error: unrecognized command line option '-Wl'
Makefile:18: recipe for target 'lib_plain' failed
make: *** [lib_plain] Error 1

This is the line 18 in the makefile gcc -shared -Wl -o libhmacenc.so hmac_256_plain.o sha2.o -lc 这是makefile gcc -shared -Wl -o libhmacenc.so hmac_256_plain.o sha2.o -lc中的第18行

This is the list of the files: 这是文件列表:

  • Android.mk Android.mk
  • hmac_sha256.c hmac_sha256.c
  • hmac_sha256.h hmac_sha256.h
  • reverse_test.py reverse_test.py
  • sha2.c sha2.c
  • sha2.h sha2.h
  • test.c 测试

This is the complete "makefile": 这是完整的“ makefile”:

all: lib test
test: clean lib_plain
    gcc -o test test.c -lhmacenc -L.

production: clean lib
    gcc -o test test.c -lhmacenc -L.

hmac_256.o: hmac_sha256.c hmac_sha256.h
    $(CC) -Wall -c hmac_sha256.c -o hmac_256.o

hmac_256_plain.o: hmac_sha256.c hmac_sha256.h
    $(CC) -Wall -DSHOW_PASS -c hmac_sha256.c -o hmac_256_plain.o

lib: hmac_256.o sha2.o
    gcc -shared -Wl -o libhmacenc.so hmac_256.o sha2.o -lc

lib_plain: hmac_256_plain.o sha2.o
    gcc -shared -Wl -o libhmacenc.so hmac_256_plain.o sha2.o -lc

sha2.o: sha2.c sha2.h
    $(CC) -c sha2.c -o sha2.o

clean:
    - rm -rf *.o hmac *.so

Someone would knows how I can fix this error? 有人会知道我该如何解决这个错误?

Thanks! 谢谢!

As suggested by @missimer, there is option field not specified in your makefile for linker option '-Wl'. 如@missimer所建议,在您的makefile中没有为链接器选项“ -Wl”指定选项字段。

Generally, for creating shared library, the following syntax is used with '-Wl': 通常,对于创建共享库,以下语法与'-Wl'一起使用:

gcc -shared -Wl,-export-dynamic 

Hope this helps you. 希望这对您有所帮助。

There is another branch of the code that deals with Cygwin and has a different Makefile. 该代码的另一个分支处理Cygwin,并具有一个不同的Makefile。

https://github.com/sanandrea/CSecretKey/tree/cygwin https://github.com/sanandrea/CSecretKey/tree/cygwin

Always try to use a GNU-Linux environment to compile programs in pure C. Avoid Cygwin because their behavior is different in the Makefile. 始终尝试使用GNU-Linux环境在纯C语言中编译程序。避免使用Cygwin,因为它们的行为在Makefile中有所不同。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 gcc:错误:无法识别的命令行选项“ -1m” - gcc: error: unrecognized command line option ‘-1m’ gcc使用pkg-config引发“无法识别的命令行选项”错误 - gcc raises “unrecognized command line option” error with pkg-config 从gcc取消选择“无法识别的命令行选项” - Eliciting an “unrecognized command line option” from gcc GCC v4.9.2上无法识别的命令行选项'-rdynamic' - unrecognized command line option ‘-rdynamic’ on GCC v4.9.2 无法识别的命令行选项“-framework” - unrecognized command line option ‘-framework’ 为什么gcc失败了“无法识别的命令行选项”-L / lusr / opt / mpfr-2.4.2 / lib“'? - Why is gcc failing with 'unrecognized command line option “-L/lusr/opt/mpfr-2.4.2/lib”'? Cygwin中无法识别的命令行选项'-pthread' - Unrecognized command line option ‘-pthread’ in Cygwin 如何解决“无法识别的命令行选项'-std = gnu11'”错误? - How to solve “unrecognized command line option '-std=gnu11'” error? GCC编译器错误:无法识别的选项'--export-dynamic' - GCC compiler error: unrecognized option '--export-dynamic' 构建C ++库时出现mno-cygwin无法识别的命令行选项错误 - mno-cygwin unrecognized command line option error when building c++ library
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM