官网:https://boutell.com/cgic/#build
1. 可直接tar包安装
tar xvf libcgi-1.0.tar.gz
cd libcgi-1.0./configuremakecd srcsudo cp libcgi.so /usr/libsudo cp cgi.h session.h /usr/include写代码时包含头文件应写:#include <cgi.h>#include <session.h>学习libcgi库的方法:源码包目录/doc/html目录下有一个index.html是帮助文档。源码包目录/examples目录下是各种示例程序,结合帮助文档研究它们是如何工作的。2. apt-get源上安装sudo apt-get install libcgic-dev注:apt-get安装软件时下载的包存放在目录:/var/cache/apt/archives
包含头文件需要写:#include <cgic.h>在libcgic 2.0+,主程序主要实现cgiMain()函数。
一般编译命令:gcc cgictest.c -lcgic
注:通过dpgk -c libcgic-dev_2.05-3_i386.deb可查看文件安装目录
~$dpkg -c libcgic-dev_2.05-3_i386.deb drwxr-xr-x root/root 0 2012-05-24 23:13 ./drwxr-xr-x root/root 0 2012-05-24 23:13 ./usr/drwxr-xr-x root/root 0 2012-05-24 23:13 ./usr/share/drwxr-xr-x root/root 0 2012-05-24 23:13 ./usr/share/doc/drwxr-xr-x root/root 0 2012-05-24 23:13 ./usr/share/doc/libcgic-dev/drwxr-xr-x root/root 0 2012-05-24 23:13 ./usr/share/doc/libcgic-dev/examples/-rw-r--r-- root/root 4299 2004-04-23 04:49 ./usr/share/doc/libcgic-dev/examples/cgictest.c.gz-rw-r--r-- root/root 338 2004-04-23 04:49 ./usr/share/doc/libcgic-dev/examples/capture.c-rw-r--r-- root/root 105885 2004-11-16 00:59 ./usr/share/doc/libcgic-dev/cgic.html-rw-r--r-- root/root 990 2012-05-24 23:13 ./usr/share/doc/libcgic-dev/copyrightdrwxr-xr-x root/root 0 2012-05-24 23:13 ./usr/lib/-rw-r--r-- root/root 29364 2012-05-24 23:13 ./usr/lib/libcgic.adrwxr-xr-x root/root 0 2012-05-24 23:13 ./usr/include/-rw-r--r-- root/root 7403 2004-04-23 04:49 ./usr/include/cgic.hlrwxrwxrwx root/root 0 2012-05-24 23:13 ./usr/share/doc/libcgic-dev/changelog.Debian.gz -> ../libcgic2/changelog.Debian.gzlrwxrwxrwx root/root 0 2012-05-24 23:13 ./usr/lib/libcgic.so -> libcgic.so.2.05
3. 安装目录下capture.c为标准范例
#include "cgic.h" int cgiMain() { cgiWriteEnvironment("/CHANGE/THIS/PATH/capcgi.dat"); cgiHeaderContentType("text/html"); fprintf(cgiOut, "Captured \n"); fprintf(cgiOut, "Captured
\n"); fprintf(cgiOut, "Your form submission was captured for use in\n"); fprintf(cgiOut, "debugging CGI code.\n"); return 0;}
参考:
1.