Compiling fcgi-test.cpp

nblew <[email protected]> Fri, 30 Mar 2007 05:55:06 -0700 (PDT)
Newsgroups gmane.comp.gcc.cgicc.general
Message-ID <[email protected]>
I=E2=80=99ll be the first to confess that I don=E2=80=99t know what I=E2=80=
=99m doing.  It=E2=80=99s been
awhile since I=E2=80=99ve worked in C++ and I=E2=80=99m trying to get fcgi-=
test.cpp to
build.

My environment:

Windows XP
Apache 2.x
VC6

I had FastCGI running on Apache and wanted to get it working with cgicc, so
I attempted to build cgicc.  I immediately got a host of =E2=80=9Cerror C20=
39:
=E2=80=98isspace=E2=80=99 is not an element of =E2=80=98std=E2=80=99=E2=80=
=9D =E2=80=93 type errors, so I stripped out any
=E2=80=9Cstd::=E2=80=9D prefix that the compiler complained about (probably=
 a bad move).

Cgicc then compiled and I put cgicc.lib and cgicc.dll in places where my
fcgi-test project could get to them (cgicc.lib in /visual studio/vc98/libs/
until I figured out a better place for it and cgicc.dll in
/windows/system32).

Then I attempted to compile fcgi-test.cpp:=20

#include <exception>
#include <iostream>


#include "cgicc/Cgicc.h"
#include "cgicc/HTTPHTMLHeader.h"
#include "cgicc/HTMLClasses.h"

#include "FCgiIO.h"

// To use the debug logging feature, the variable gLogFile MUST be
// defined, and it _must_ be an ofstream
#if DEBUG
  std::ofstream gLogFile( "/Debug/cgicc.log", std::ios::app );
#endif

using namespace std;
using namespace cgicc;

int=20
main(int /*argc*/,=20
     const char **/*argv*/,=20
     char **/*envp*/)
{
  unsigned count =3D 0;

  FCGX_Request request;

  FCGX_Init();
  FCGX_InitRequest(&request, 0, 0);

  while(FCGX_Accept_r(&request) =3D=3D 0) {

    try {
      FCgiIO IO(request);
      Cgicc CGI(&IO);

      // Output the HTTP headers for an HTML document, and the HTML 4.0 DTD
info
      IO << HTTPHTMLHeader() << HTMLDoctype( HTMLDoctype::eStrict ) << endl
         << html().set( "lang", "en" ).set( "dir", "ltr" ) << endl;

      // Set up the page's header and title.
      IO << head() << endl
         << title() << "GNU cgicc v" << CGI.getVersion() << title() << endl
         << head() << endl;

      // Start the HTML body
      IO << body() << endl;

      // Print out a message
      IO << h1("Cgicc/FastCGI Test") << endl
         << "count: " << count++ << br() << endl;

      IO  << "Form Elements:" << br() << endl;

      for(const_form_iterator i =3D CGI.getElements().begin();=20
=09  i !=3D CGI.getElements().end(); ++i )
        IO << i->getName() << " =3D " << i->getValue() << br() << endl;

      // Close the document
      IO << body() << html();
=20
   }
    catch(const exception&) {
      // handle error condition
    }

    FCGX_Finish_r(&request);
  }

  return 0;
}

It failed with a boatload of warnings (ugh) and 2 errors:

Linking...

fcgi-test.obj : error LNK2001: unresolved external symbol
"__declspec(dllimport) public: void __thiscall cgicc::FCgiIO::`vbase
destructor'(void)" (__imp_??_DFCgiIO@cgicc@@QAEXXZ)

fcgi-test.obj : error LNK2001: unresolved external symbol
"__declspec(dllimport) public: __thiscall cgicc::FCgiIO::FCgiIO(struct
FCGX_Request &)" (__imp_??0FCgiIO@cgicc@@QAE@AAUFCGX_Request@@@Z)

c:\development\httpd\fcgi-bin\test.fcgi : fatal error LNK1120: 2 unresolved
externals
=E2=80=A6

The compiler apparently is having a problem with the line FCgiIO
IO(request);

Happily hacking away, I added # define CGICC_EXPORTS 1 in cgidefs.h, which
eliminated the first link error.  My changes to cgidefs.h are excerpted
here:

=E2=80=A6
// Win32-specific setup
#ifdef WIN32

// HACK ALERT: forcing dllexport
# define CGICC_EXPORTS 1

// export library symbols
#  ifdef CGICC_EXPORTS
#    define CGICC_API __declspec(dllexport)
#  else
#    define CGICC_API __declspec(dllimport)
#  endif

#  define HOST "Win32"
#  define VERSION "3.2.3"

#else
#  define CGICC_API
#endif /* WIN32 */

#endif /* ! _CGIDEFS_H_ */
=E2=80=A6

I=E2=80=99m stuck on the second link error.  Of course, even if I somehow m=
anaged to
hack the second link error away I=E2=80=99ll certainly still have problems.=
  So
hopefully an expert out there can show me how to build cgicc and
fcgi-test.cpp the right way and get this up and running

Much thanks for accommodating my complete lack-of-clues=E2=80=A6

--=20
View this message in context: http://www.nabble.com/Compiling-fcgi-test.cpp=
-tf3492021.html#a9752568
Sent from the cgicc - General mailing list archive at Nabble.com.