Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用外部库引用编译C代码_C_Linux_Join_Compiler Errors - Fatal编程技术网

使用外部库引用编译C代码

使用外部库引用编译C代码,c,linux,join,compiler-errors,C,Linux,Join,Compiler Errors,我在RHEL6.0上,获得了join命令的源代码(希望来自正确的源代码!!)。我很少编写C代码,因此觉得这很困难。我试图编译并运行join的C代码,但遇到编译时错误 g++ join.c join.c:19:20: error: config.h: No such file or directory join.c:25:20: error: system.h: No such file or directory join.c:27:25: error: hard-locale.h: No suc

我在RHEL6.0上,获得了
join
命令的源代码(希望来自正确的源代码!!)。我很少编写C代码,因此觉得这很困难。我试图编译并运行
join
的C代码,但遇到编译时错误

g++ join.c
join.c:19:20: error: config.h: No such file or directory
join.c:25:20: error: system.h: No such file or directory
join.c:27:25: error: hard-locale.h: No such file or directory
join.c:28:24: error: linebuffer.h: No such file or directory
join.c:29:24: error: memcasecmp.h: No such file or directory
join.c:30:19: error: quote.h: No such file or directory
join.c:31:21: error: stdio--.h: No such file or directory
join.c:32:22: error: xmemcoll.h: No such file or directory
join.c:33:21: error: xstrtol.h: No such file or directory
join.c:34:22: error: argmatch.h: No such file or directory

由于我不知道在哪里可以找到这些库(我用谷歌搜索了每一个库,它们分布在不同的网站上),谁能告诉我如何将这些库链接在一起并编译
join
命令的源代码?

也许你还没有准备好编译代码的一切。尝试安装
build-essential
软件包

sudo yum install build-essential

与此相关的是,我不知道脚本join.c,但是如果您正在寻找一种将一组文件连接在一起的方法,您可以执行
cat FILE1 FILE2 FILE3>BIG_FILE
,其中
FILE1
FILE2
FILE3
是您想要连接它们的文件。在RHEL6.0下,如果有模式,也可以使用星号。例如,
cat FILE.00*>BIG_FILE

这不是您建议的链接问题。相反,您得到这些错误是因为
g++
找不到这些文件:
config.h
system.h
,…,它们是
,通过
join.c
间接包含
d

您可以做的是
在系统中查找这些文件,然后在
g++
后面添加与找到这些文件的目录相同数量的
-I
选项。有关更多信息,请执行
mang++

您还需要找到需要链接的库的位置。因此,您需要指定多个
-I

另一方面,没有“配置”或其他包文件吗?通常,您不必手动指定编译器标志(如
-I
)。相反,通常从这样的配置文件生成Makefile,之后只需键入
make


我建议你找一个以前做过的人,因为你似乎不了解C程序编译的基础知识。这可能会花费你很多宝贵的时间而没有结果。但是祝你好运

这与问题完全无关。请花时间了解更多如何使用GCC和
g++
命令。另外,养成使用
g++-Wall-g
编译的习惯(其他选项,例如
-I
包括所需的目录)。了解如何使用
gdb
调试器。
join
源代码可能有一个
README
INSTALL
文件,并使用
configure
。。。。