首页 > 其他分享 >gcc linking order

gcc linking order

时间:2023-01-08 16:46:37浏览次数:62  
标签:gcc give ++ Extra linking flags lpng16 cpp 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.

标签:gcc,give,++,Extra,linking,flags,lpng16,cpp,order
From: https://www.cnblogs.com/funwithwords/p/17034849.html

相关文章

  • [ABC255F] Pre-order and In-order 题解
    [ABC255F]Pre-orderandIn-orderSolution目录[ABC255F]Pre-orderandIn-orderSolution更好的阅读体验戳此进入题面SolutionCodeUPD更好的阅读体验戳此进入题面给......
  • StringCbCatW与StringCchCatW的区别
    仔细看官方文档里,区别主要在第二个参数:StringCchCatW的cbDest:以字节为单位StringCchCatW的cchDest:以字符为单位大家根据实际情况选择合适的函数。附:StringCbCat、Stri......
  • CF865B Ordering Pizza 题解
    简要题意:有\(n\)个人去披萨店吃披萨,有两种披萨,每个披萨有\(m\)片。现在第\(i\)个人要吃\(c_i\)片披萨,如果吃一片第一种披萨会获得\(a_i\)的幸运值,如果吃一片第二......
  • STM32F103 Proteus 仿真 编译用GCC
    原理图只要一个MCU就可以了,双击MCU,编辑固件,选择GCCforARM,由模板创建默认工程。会遇到两个错误:  1.STM32GCCARM编译_STATIC_INLINE出错,     在第一个......
  • 使用嵌套的ScriptableObject及ReorderableList创建习题持久化数据
    使用嵌套的ScriptableObject及ReorderableList创建习题持久化数据效果展示题集持久化数据:存储题目,可以直接在inspector面板上创建对应的问题子项问题持久化数据:源码......
  • gcc内置原子操作__sync_系列函数解析
    gcc内置原子操作__sync_系列函数解析gcc4.1.2版本之后,对X86或X86_64支持内置原子操作。就是说,不需要引入第三方库(如pthread)的锁保护,即可对1、2、4、8字节的数值或指针类......
  • USB Keyboard Recorder
    USBKeyboardRecordercatalogue0.引言1.DeviceClassDefinitionforHumanInterfaceDevices(HID)2.USBHIDReportDescriptors3.arduino......
  • GCC链接库的一个坑:动态库存在却提示未定义动态库的函数
    背景在GCC中已经指定链接库,然而编译时却提示动态库函数未定义!测试出现的错误提示如下:  [GMPY@13:48tmp]$gcc-otest-L.-lmylibtest.c /tmp/ccys......
  • gcc 8.3.0 源码编译安装
    背景vpp高版本编译需要高版本的gcc支持,不然编译过程中很多编译参数都识别不了。但是服务器此时有没有连接互联网,故需要先将高版本的gcc源代码通过互联网下载下来,移动到服......
  • fix协议介绍11-修改订单(OrderCacelReplaceRequest)
    FIX.5.0SP2MessageOrderCancelReplaceRequest [type'G']<OrdCxlRplcReq>Theordercancel/replacerequestisusedtochangetheparametersofanexistingorder......