gpt4 book ai didi

编译带有依赖项的 .c 文件

转载 作者:太空宇宙 更新时间:2023-11-04 03:40:18 25 4
gpt4 key购买 nike

我从我的教授那里“继承”了一堆文件,她让我看看我是否能理解整个项目。它是一堆文件(python、c、java)的混合体,这些文件将在特定数据集上一个接一个地运行。据我所知,代码写得非常糟糕,README 是一个笑话。

第一步涉及使用数据集和另外 2 个参数运行 python 脚本。这个文件的最后一行是

os.system("./blar " + str(raw_datafile) + " " + str(combos) + " " + str(mine1) + " " + str(mine2))

转化为 -

./blar RareDiseaseDataSet.xlsx 57 1 84

我知道 os.system 在子 shell 中执行命令。但是,当执行上述命令时,结果是 ./blar: No such file or directory。该文件夹有一个名为 blar.c 的文件。我的 c 知识非常基础,为了生成可执行文件,我尝试了 make blar.cgcc blar.c -o blar 但是徒劳无功。我如何让它运行?

编辑尝试了这些命令 -

$ make blar.c
make: Nothing to be done for `blar.c'.

$ gcc blar.c -o blar
/tmp/ccblMR3s.o: In function `nonsingles':
blar.c:(.text+0x359): undefined reference to `checknull'
blar.c:(.text+0x3e3): undefined reference to `checknull'
blar.c:(.text+0x759): undefined reference to `next_comb'
/tmp/ccblMR3s.o: In function `main':
blar.c:(.text+0xa20): undefined reference to `readfile'
blar.c:(.text+0xa2d): undefined reference to `checknull'
blar.c:(.text+0xb44): undefined reference to `destroy_file_array'
collect2: ld returned 1 exit status

长话短说如何从 .c 文件创建可执行文件。

附言- 在史前的学校服务器上运行它,使用 python 2.4.x

最佳答案

您使用 gcc blar.c -o blar 走在正确的轨道上。大概它失败了,所以你必须找出原因(检查错误消息)并修复它。如果目录中有一个 Makefile,它将包含构建所有内容的方法(如果你幸运的话)。

附言。看起来您的 blar 程序必须能够读取 Excel 电子表格;几乎可以肯定它依赖于其他源文件或库,因此您需要在构建 blar 的命令中编译和/或链接其他文件。我真的希望你有一个 Makefile

关于编译带有依赖项的 .c 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29222625/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com