gcc linking order
g++ -o 1 1.cpp -lpng16 # correct g++ 1.cpp -lpng16 -o 1 # correct g++ -lpng16 1.cpp -o 1 # wrong g++ -o 1 -lpng16 1.cpp # wrong
GNU make's manual. 10.3 Variables Used by Implicit Rules
- CC - Program for compiling C programs; default ‘cc’.
- CFLAGS - Extra flags to give to the C compiler.
- CXX - Program for compiling C++ programs; default ‘g++’.
- CXXFLAGS - Extra flags to give to the C++ compiler.
- CPP - Program for running the C preprocessor.
- CPPFLAGS - Extra flags to give to the C preprocessor and programs that use it (the C and Fortran compilers).
- LDFLAGS - Extra flags to give to compilers when they are supposed to invoke the linker, ‘ld’. [实测好像是cc,不是ld]
- LDLIBS - Library flags or names given to compilers when they are supposed to invoke the linker.
- 没有LD. 所有还是得会会$@, $<, $^之流。
myprog: myprog.o file1.o file2.o $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LDLIBS)
- $< The name of the first prerequisite.
- $^ The names of all the prerequisites.
- $+ is like ‘$^’, but prerequisites listed more than once are duplicated in the order they were listed in the makefile. This is primarily useful for use in linking commands where it is meaningful to repeat library file names in a particular order.
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· 三行代码完成国际化适配,妙~啊~
· .NET Core 中如何实现缓存的预热?
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
2022-01-08 A Child's History of England.105
2022-01-08 ambulance
2022-01-08 A Child's History of England.104
2022-01-08 蜂鸟E203开源RISC-V开发板
2022-01-08 ambassador
2022-01-08 amateur
2022-01-08 Basic Computer Games