• LDFLAGS 与 LDLIBS


    今天下载了开源程序“贪吃蛇” (github地址 : https://github.com/taylorconor/tinytetris.git) 在编译时,出现如下错

    linux:~/code/other/tinytetris$ make
    g++   -lcurses  tinytetris.cpp   -o tinytetris
    /tmp/ccNKijAL.o: In function `F()':
    tinytetris.cpp:(.text+0xf7): undefined reference to `move'
    tinytetris.cpp:(.text+0x161): undefined reference to `stdscr'
    tinytetris.cpp:(.text+0x171): undefined reference to `wattr_on'
    tinytetris.cpp:(.text+0x184): undefined reference to `printw'
    tinytetris.cpp:(.text+0x19c): undefined reference to `stdscr'
    tinytetris.cpp:(.text+0x1ac): undefined reference to `wattr_off'
    tinytetris.cpp:(.text+0x1ce): undefined reference to `move'
    tinytetris.cpp:(.text+0x1e7): undefined reference to `printw'
    tinytetris.cpp:(.text+0x1ec): undefined reference to `refresh'
    /tmp/ccNKijAL.o: In function `L()':
    tinytetris.cpp:(.text+0x634): undefined reference to `stdscr'
    tinytetris.cpp:(.text+0x63c): undefined reference to `wgetch'
    /tmp/ccNKijAL.o: In function `main':
    tinytetris.cpp:(.text+0x83f): undefined reference to `initscr'
    tinytetris.cpp:(.text+0x844): undefined reference to `start_color'
    tinytetris.cpp:(.text+0x877): undefined reference to `init_pair'
    tinytetris.cpp:(.text+0x89c): undefined reference to `resizeterm'
    tinytetris.cpp:(.text+0x8a1): undefined reference to `noecho'
    tinytetris.cpp:(.text+0x8a8): undefined reference to `stdscr'
    tinytetris.cpp:(.text+0x8b5): undefined reference to `wtimeout'
    tinytetris.cpp:(.text+0x8bf): undefined reference to `curs_set'
    tinytetris.cpp:(.text+0x8c6): undefined reference to `stdscr'
    tinytetris.cpp:(.text+0x8d8): undefined reference to `box'
    tinytetris.cpp:(.text+0x8e2): undefined reference to `endwin'
    collect2: error: ld returned 1 exit status
    <builtin>: recipe for target 'tinytetris' failed
    make: *** [tinytetris] Error 1

    找不到很多库文件中的函数。

    查看github上相关issuse,得知是
    LDFLAGS的问题,将Makefile中LDFLAGS 替换为LDLIBS, 问题得到解决。
    
    
    DLIBS is for libraries, LDFLAGS should be used for flags/search paths (-L) 

    LDFLAGS是用来制定动态Library调用的参数集
     
  • 相关阅读:
    Linux系统挂载点与分区的关系(转载)
    读书笔记深入linux内核架构Chapter 2 part2
    读书笔记深入linux内核架构Chapter 2 part1
    读书笔记深入linux内核架构Chapter9
    读书笔记深入linux内核架构Chapter8part2
    鞋匠的烦恼
    和最大的连续子数组
    wxLog 的使用
    suffix trie
    trie
  • 原文地址:https://www.cnblogs.com/rohens-hbg/p/11104231.html
Copyright © 2020-2023  润新知