GNU CGI using C++

GNU CGI using C++

本文关键字:C++ using CGI GNU      更新时间:2023-10-16

我正在用c++ (Windows)编写CGI程序。我试图使用cookie,但我得到编译时错误。我使用了来自http://www.gnu.org/software/cgicc/
的GNU库我提取zip文件,并将文件夹放在我的包括文件夹在Dev c++目录。我也可以使用Visual studio (Visual c++)。但我还是得到了同样的错误。cicc名称空间无法识别。请帮帮我。如果你知道其他软件,我将使用它。请告诉我,在哪里以及如何添加库。

错误包括:

"C:UsersUSIDesktopUntitled1.cpp" -o "C:UsersUSIDesktopUntitled1.exe"    -I"C:Dev-Cpplibgccmingw323.4.2include"  -I"C:Dev-Cppincludec++3.4.2backward"  -I"C:Dev-Cppincludec++3.4.2mingw32"  -I"C:Dev-Cppincludec++3.4.2"  -I"C:Dev-Cppinclude"   -L"C:Dev-Cpplib" 
C:UsersUSIDesktopUntitled1.cpp:8:27: cgicc/CgiDefs.h: No such file or directory
C:UsersUSIDesktopUntitled1.cpp:9:26: cgicc/Cgicc.h: No such file or directory
C:UsersUSIDesktopUntitled1.cpp:10:41: cgicc-3.0.1/HTTPHTMLHeader.h: No such file or directory
C:UsersUSIDesktopUntitled1.cpp:11:37: cgicc-3.0.1/HTMLClasses.h: No such file or directory
C:UsersUSIDesktopUntitled1.cpp:14: error: expected namespace-name before ';' token
C:UsersUSIDesktopUntitled1.cpp:14: error: `<type error>' is not a namespace
C:UsersUSIDesktopUntitled1.cpp: In function `int main()':
C:UsersUSIDesktopUntitled1.cpp:21: error: `Cgicc' undeclared (first use this function)
C:UsersUSIDesktopUntitled1.cpp:21: error: (Each undeclared identifier is reported only once for each function it appears in.)
C:UsersUSIDesktopUntitled1.cpp:21: error: expected `;' before "cgi"
C:UsersUSIDesktopUntitled1.cpp:22: error: `const_cookie_iterator' undeclared (first use this function)
C:UsersUSIDesktopUntitled1.cpp:22: error: expected `;' before "cci"
C:UsersUSIDesktopUntitled1.cpp:37: error: expected primary-expression before "const"
C:UsersUSIDesktopUntitled1.cpp:37: error: expected `;' before "const"
C:UsersUSIDesktopUntitled1.cpp:39: error: `cci' undeclared (first use this function)
C:UsersUSIDesktopUntitled1.cpp:39: error: `env' undeclared (first use this function)
Execution terminated

#include <iostream>
#include <iostream>
#include <vector>  
#include <string>  
#include <stdio.h>  
#include <stdlib.h> 
#include <cgicc/CgiDefs.h>
#include <cgicc/Cgicc.h> 
#include <cgicc/HTTPHTMLHeader.h> 
#include <cgicc/HTMLClasses.h>
using namespace std;
using namespace cgicc;

int main ()
{
     Cgicc cgi;
   const_cookie_iterator cci;
    cout << "Set-Cookie:guessNo=2;rn";
   cout << "Content-type:text/htmlrnrn";

    cout << "Content-type:text/htmlrnrn";
   cout << "<html>n";
   cout << "<head>n";
   cout << "<title>Cookies in CGI</title>n";
   cout << "</head>n";
   cout << "<body>n";
   cout << "<table border = "0" cellspacing = "2">";
   // get environment variables
   const CgiEnvironment& env = cgi.getEnvironment();
   for( cci = env.getCookieList().begin();
        cci != env.getCookieList().end(); 
        ++cci )
   {
      cout << "<tr><td>" << cci->getName() << "</td><td>";
      cout << cci->getValue();                                 
      cout << "</td></tr>n";
   }
   cout << "</table><n";
   cout << "<br/>n";
   cout << "</body>n";
   cout << "</html>n";
   return 0;
}

确保1) cgidef .h cgic .h, HTTPHTMLHeader.h和HTMLClasses.h都在cgic目录下2)cgic目录本身在Visual Studio c++编译器设置中的"附加包含目录"中列出的目录中,或与之等价的devc++目录。

你的错误表明编译器根本没有找到那些。h文件。

您似乎没有配置cgic头文件的路径。确保目录cicc和cicc -3.0.1位于使用-I标志设置的目录之一。