Using header files in C [closed]

↘锁芯ラ 提交于 2019-12-06 19:43:32

Including the header file is not sufficient. The prototype in the header file just tells the compiler that there should be a function.

You have to actually add the function to the program. That is done when linking. the simplest way would be

gcc -o myprog test.c library.c

There are more sophisticated option. If you want to add several files actually to a library you can compile them independently and build the archive. Here are some commmands that show the basic idea.

gcc -o library.o library.c
gcc -o someother.o someother.c
ar a libmy.a library.o someother.o

gcc -o myprog test.c -l my
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!