ryanmjacobs/c

多文件问题

niuyuling opened this issue · 1 comments

root@niuyuling:/mnt/c/Users/niuyuling/Desktop/libini# ../c/c test.c -L./ -lini -static
/usr/bin/ld: /tmp/cc3AcSun.o: in function main': test.c:(.text.startup+0x21): undefined reference to getinikeystring'
/usr/bin/ld: test.c:(.text.startup+0x5f): undefined reference to getinikeystring' /usr/bin/ld: test.c:(.text.startup+0x9a): undefined reference to getinikeyint'
/usr/bin/ld: test.c:(.text.startup+0xdd): undefined reference to getinikeylong' /usr/bin/ld: test.c:(.text.startup+0x121): undefined reference to getinikeyfloat'
/usr/bin/ld: test.c:(.text.startup+0x170): undefined reference to putinikeystring' /usr/bin/ld: test.c:(.text.startup+0x18d): undefined reference to getinikeystring'
/usr/bin/ld: test.c:(.text.startup+0x1cd): undefined reference to `getinikeystring'
collect2: error: ld returned 1 exit status
root@niuyuling:/mnt/c/Users/niuyuling/Desktop/libini#

root@niuyuling:/mnt/c/Users/niuyuling/Desktop/libini# ../c/c 'test.c -L./ -lini -static'
/usr/bin/ld: 找不到 -lini
collect2: error: ld returned 1 exit status
root@niuyuling:/mnt/c/Users/niuyuling/Desktop/libini#

可不可以支持多文件或者链接库文件
Can I support multiple files or link library files?

Try

$ c 'test.c -L./ -lini -static'

The problem is that c can't tell which of those are flags and which ones are arguments. Wrapping the entire thing in quotes tells it that it's compile flags.


Look at the last two examples here:

$ c --help
Usage: c <file.c ... | compiler_options ...> [program_arguments]
Execute C programs from the command line.

  Ex: c main.c
  Ex: c main.c arg1 arg2
  Ex: c 'main.c other.c' arg1 arg2
  Ex: c 'main.c -lncurses' arg1 arg2