-2

我试图在 Ubuntu linux ( ) 上编译gcc ./src/shallot.c,但我得到了这个错误:

/tmp/ccwsRxaV.o: In function `main':
shallot.c:(.text+0x3d): undefined reference to `usage'
shallot.c:(.text+0x1ea): undefined reference to `parse_cpuinfo'
shallot.c:(.text+0x2a3): undefined reference to `pattern'
shallot.c:(.text+0x2eb): undefined reference to `usage'
shallot.c:(.text+0x3ba): undefined reference to `usage'
shallot.c:(.text+0x440): undefined reference to `usage'
shallot.c:(.text+0x4de): undefined reference to `usage'
shallot.c:(.text+0x57a): undefined reference to `usage'
/tmp/ccwsRxaV.o:shallot.c:(.text+0x5f4): more undefined references to `usage' follow
/tmp/ccwsRxaV.o: In function `main':
shallot.c:(.text+0x92d): undefined reference to `worker'
shallot.c:(.text+0x941): undefined reference to `pthread_create'
shallot.c:(.text+0x984): undefined reference to `monitor_proc'
shallot.c:(.text+0x998): undefined reference to `pthread_create'
shallot.c:(.text+0x9b7): undefined reference to `worker'
shallot.c:(.text+0x9db): undefined reference to `pthread_join'

对不起,我不是程序员。我真的不知道这应该如何工作。

4

1 回答 1

2

好吧,我去了现场,记下了说明并试了一下。看起来很简单:

首先将源代码克隆到“葱”目录中:

git clone https://github.com/katmagic/Shallot.git Shallot

然后我们运行配置:

mike@linux-4puc:~/C/Shallot> ./configure
检测到Liunx。您是否考虑过切换到 BSD?
配置成功。 这并不意味着它会建立。
如果您缺少 gcc 或所需的库/头文件,则需要先安装它们。

最后运行 Makefile:

mike@linux-4puc:~/C/Shallot> make
cc  -O3 -I/usr/include -I/usr/local/include -L/usr/lib -L/usr/local/lib  -Wall -o src/math.o -c src/math.c
cc  -O3 -I/usr/include -I/usr/local/include -L/usr/lib -L/usr/local/lib  -Wall -o src/error.o -c src/error.c
cc  -O3 -I/usr/include -I/usr/local/include -L/usr/lib -L/usr/local/lib  -Wall -o src/linux.o -c src/linux.c
cc  -O3 -I/usr/include -I/usr/local/include -L/usr/lib -L/usr/local/lib  -Wall -o src/print.o -c src/print.c
cc  -O3 -I/usr/include -I/usr/local/include -L/usr/lib -L/usr/local/lib  -Wall -o src/thread.o -c src/thread.c
cc  -O3 -I/usr/include -I/usr/local/include -L/usr/lib -L/usr/local/lib  -Wall -o src/shallot.o -c src/shallot.c
cc  -O3 -I/usr/include -I/usr/local/include -L/usr/lib -L/usr/local/lib -pthread src/math.o src/error.o src/linux.o src/print.o src/thread.o src/shallot.o -o shallot -lm -lpthread -lssl -lcrypto

shallot现在可以在目录中看到可执行文件:

mike@linux-4puc:~/C/Shallot> ls
CHANGELOG  configure  LICENSE  Makefile  README.asciidoc  shallot  src

因此,如果您完全按照我所做的所有步骤操作,我怀疑您遇到问题的地方是我在上面突出显示的文本块。你有构建葱所需的所有库/标题吗?

于 2013-02-05T20:47:23.523 回答