这是我的 C 语言项目文件的文件结构:
首先是一个 fullCourse 文件夹
fullCourse 文件夹包含三个文件夹:
1. include
2. src
3. lib
4. test
in include 文件夹:
它包含一个头文件:temp.h
temp.h 的代码如下:
#ifndef __$__temp_h
#define __$__temp_h 234
int yash();
#endif
在 src 文件夹中:
它包含一个源文件: temp.c
的 temp.cc 代码如下:
#ifndef __$__temp_c
#define __$__temp_c 234
int yash()
{
return 22;
}
#endif
然后留在同一个文件夹中,创建 .o 文件如下:
gcc -I ../include -c temp.c
下一步是将这个 temp.o 文件移动到 lib 文件夹,如下所示:
mv temp.o ../lib
比停留在 lib 文件夹中创建了一个存档(或库)文件,如下所示:
ar rcs libtmds.a temp.o
比在 test 文件夹中写了一个源代码来测试 tempTest.c 的库(tempTest.c)
代码如下:
#include<stdio.h>
#include<temp.h>
int main()
{
int w;
w=yash();
printf("%d\n",w);
return 0;
}
比留在测试文件夹中尝试编译它如下:
gcc -static -I ../include tempTest.c -L ../lib -ltmds -o tempTest.exe
但代码未编译,显示以下错误:
ld: library not found for -lcrt0.o
clang: error: linker command failed with exit code 1 (use -v to see invocation)
请帮我解决这个问题。