[英]gcc: error: unrecognized command line option '-Wl' in Makfile
我在此源代碼中運行命令“ make test ”:
https://github.com/sanandrea/CSecretKey
但是它給了我這個錯誤 :
gcc: error: unrecognized command line option '-Wl'
Makefile:18: recipe for target 'lib_plain' failed
make: *** [lib_plain] Error 1
這是makefile gcc -shared -Wl -o libhmacenc.so hmac_256_plain.o sha2.o -lc中的第18行
這是文件列表:
這是完整的“ 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
有人會知道我該如何解決這個錯誤?
謝謝!
如@missimer所建議,在您的makefile中沒有為鏈接器選項“ -Wl”指定選項字段。
通常,對於創建共享庫,以下語法與'-Wl'一起使用:
gcc -shared -Wl,-export-dynamic
希望這對您有所幫助。
該代碼的另一個分支處理Cygwin,並具有一個不同的Makefile。
https://github.com/sanandrea/CSecretKey/tree/cygwin
始終嘗試使用GNU-Linux環境在純C語言中編譯程序。避免使用Cygwin,因為它們的行為在Makefile中有所不同。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.