Search code examples
cgccmakefilecygwingnu-make

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


I run the command "make test" in this source code:

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

This is the list of the files:

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

This is the complete "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!


Solution

  • There is another branch of the code that deals with Cygwin and has a different Makefile.

    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.