0

我正在尝试构建包含在源代码中的libvterm 的演示。

我有这个文件夹结构:

- libvterm/
  ... // all sources are here
  - libvterm.so
  - vterm.h
  - demo/
    - vshell.c

在演示目录中我做了:

$ gcc -o vshell `pkg-config --cflags --libs glib-2.0 ncurses` vshell.c -L.. -I.. -lvterm

undefined reference to即使在定义-I-L指向正确的目录之后,我也会遇到很多错误:

/tmp/ccAlNYtQ.o: In function `main':
vshell.c:(.text+0x24): undefined reference to `initscr'
vshell.c:(.text+0x29): undefined reference to `noecho'
vshell.c:(.text+0x2e): undefined reference to `start_color'
vshell.c:(.text+0x33): undefined reference to `raw'
vshell.c:(.text+0x38): undefined reference to `stdscr'
vshell.c:(.text+0x48): undefined reference to `nodelay'
vshell.c:(.text+0x4d): undefined reference to `stdscr'
vshell.c:(.text+0x5d): undefined reference to `keypad'
vshell.c:(.text+0x62): undefined reference to `stdscr'
vshell.c:(.text+0x6b): undefined reference to `stdscr'
vshell.c:(.text+0x84): undefined reference to `stdscr'
vshell.c:(.text+0x8d): undefined reference to `stdscr'
vshell.c:(.text+0xfb): undefined reference to `init_pair'
vshell.c:(.text+0x118): undefined reference to `stdscr'
vshell.c:(.text+0x121): undefined reference to `stdscr'
vshell.c:(.text+0x141): undefined reference to `stdscr'
vshell.c:(.text+0x151): undefined reference to `waddch'
vshell.c:(.text+0x176): undefined reference to `stdscr'
vshell.c:(.text+0x17e): undefined reference to `wrefresh'
vshell.c:(.text+0x1a2): undefined reference to `newwin'
vshell.c:(.text+0x1e1): undefined reference to `mvwprintw'
vshell.c:(.text+0x1ee): undefined reference to `wrefresh'
vshell.c:(.text+0x2ac): undefined reference to `wtouchln'
vshell.c:(.text+0x2b9): undefined reference to `wrefresh'
vshell.c:(.text+0x2be): undefined reference to `stdscr'
vshell.c:(.text+0x2c6): undefined reference to `wrefresh'
vshell.c:(.text+0x2d2): undefined reference to `stdscr'
vshell.c:(.text+0x2da): undefined reference to `wgetch'
vshell.c:(.text+0x308): undefined reference to `endwin'
../libvterm.so: undefined reference to `forkpty'
../libvterm.so: undefined reference to `g_free'
../libvterm.so: undefined reference to `has_colors'
../libvterm.so: undefined reference to `acs_map'
../libvterm.so: undefined reference to `wchgat'
../libvterm.so: undefined reference to `beep'
../libvterm.so: undefined reference to `pair_content'
../libvterm.so: undefined reference to `COLOR_PAIRS'
../libvterm.so: undefined reference to `g_realloc'
../libvterm.so: undefined reference to `g_malloc0'
../libvterm.so: undefined reference to `wmove'
collect2: ld returned 1 exit status

我错过了什么?

4

1 回答 1

4

尝试重新排序您的链接命令...

gcc -o vshell vshell.c -L.. -I.. -lvterm `pkg-config --cflags --libs glib-2.0 ncurses`

在某些时候,gnu 链接器更改为首先需要对象,最后/稍后需要库。

于 2013-02-14T20:16:09.353 回答