今天下載了開源程序「貪吃蛇」 (github地址 : https://github.com/taylorconor/tinytetris.git) 在編譯時,出現以下錯linux
LDFLAGS的問題,將Makefile中LDFLAGS 替換爲LDLIBS, 問題獲得解決。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,得知是
DLIBS is for libraries, LDFLAGS should be used for flags/search paths (-L) LDFLAGS是用來制定動態Library調用的參數集