gpt4 book ai didi

c++ - 调用静态库中的方法

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

我正在尝试使用 gcc 在 OSX 上从头开始编写 C 标准库。当我尝试将我的库中的头文件包含在我的测试程序中时,我收到未定义的错误。我尝试使用 -nostdlib 标志,但我仍然无法包含我的文件。

我的测试程序:

#include <math.h>
#include <bool.h>
#include <ctype.h>
#include <string.h>
#include <io.h>

int main(){
int x = sin(0.5);
int y = pow(2,3);
int z = abs(12);
myiofunction(7);
exit(0);
}

math.h、bool.h、ctype.h、string.h 和 io.h 在我的库中定义。我做错了什么?

编辑:我收到的错误消息是:

helloTest.c:10:10: fatal error: 'bool.h' file not found

最佳答案

头文件不会编译成静态库。它们必须可供图书馆和项目使用。

因此,在编译您的程序时,请务必指定-I 选项,让编译器找到您的库的头文件。

关于c++ - 调用静态库中的方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25827909/

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