我正在学习如何在C中链接共享对象的教程
这是我的档案
test: glenn.c libhala.so
gcc glenn.c -L. -o test
libhala.so: hala.o
gcc -shared hala.o -o libhala.so
hala.o: hala.c hala.h
gcc -c -Wall -Werror -fpic hala.c
clean:
rm *.o
rm *.so
rm test
哈拉
#ifndef HALA
#define HALA
extern void test(char*);
#endif
哈拉
#include "hala.h"
#include <stdio.h>
extern void test(char* s)
{
printf("%s", s);
}
格伦c
#include <stdio.h>
#include "hala.h"
int main()
{
test("Hello There!");
return 0;
}
这让我很紧张。请帮帮我。。
最佳答案
链接-lhaha
时应添加glenn.c
。
gcc glenn.c -L. -lhala -o test