gpt4 book ai didi

编译带有依赖项、h 和 h0 文件的 c 程序

转载 作者:行者123 更新时间:2023-11-30 19:31:19 25 4
gpt4 key购买 nike

我正在尝试将 gjh 求解器(用 C 编写)编译成 Windows 中的可执行文件。可用 on netlib

我下载了 c 文件,并在 Windows 命令提示符下通过 WinGW 使用 gcc 编译器。尝试直接编译 gjh.c 文件给了我一个错误:

gjh.c:33:21: fatal error: getstub.h: No such file or directory
#include "getstub.h"
compilation terminated.

我假设编译 gjh.c 需要依赖项 getstub.h

getstub.h 不是唯一需要的依赖项,还有其他依赖项,即:arith.hasl.hfuncadd.hstdio1.h。所有这些文件都可以在我找到 getstub.h 的同一链接上找到。但是,可以使用 arith.h0stdio1.h0,而不是 arith.hstdio1.h

这些文件相同吗?我尝试将 .h0 文件重命名为 .h 并尝试编译 gjh.c,但出现此错误:

collect2.exe: error: ld returned 1 exit status

这两个文件相同吗?如果没有,有什么办法可以将 gjh 求解器成功编译成 .exe 吗?

最佳答案

如果这是编译中的唯一问题,请尝试在 gcc 中使用 -I 开关:

gcc -I/my/path/to/include/files -o gjh gjh.c

-I 开关提示 gcc 在哪里可以找到您的 #include 文件。

我不确定 stdio1.h。我认为您的重命名方法是可以的,但是对外部函数(例如 Sprintf)的引用。您需要链接到定义它的库。如果您知道它来自哪里,请使用 gcc 中的 -L-l 开关:

gcc -I/my/path/to/include/files -L/my/path/to/library -lnameoflibrary \
-o gjh gjh.c

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

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