Linking static library with -l flag

前端 未结 2 1039
时光取名叫无心
时光取名叫无心 2021-01-07 08:36

How can I have my makefile compile with the -l flag?

I have a makefile that looks like

myLibrary:
    gcc -c myLibrary.c -o myLibrary.o
    ar cr lib         


        
2条回答
  •  醉酒成梦
    2021-01-07 09:00

    To link purely statically library, use -static, Like

    gcc -static main.c libmyLibrary.a
    

    And run executable file ./a.out GCC Linux.

提交回复
热议问题