使用预构建库构建C ++应用程序会产生编译错误

时间:2013-03-27 11:22:16

标签: c++ build poco

我试图通过包含POCO来修改C ++程序,以便能够执行HTTP请求并接收结果。基本上,我只需要在另一个C ++程序中提供用户名和密码,并获得简单的“OK”或“ERROR”响应。

我根本不熟悉C ++(主要使用Java)。我构建POCO项目并安装它没有任何问题,但是当我将它添加到项目中时,我在构建时遇到了一堆编译器错误:

In file included from ../crtmpserver/sources/applications/idomsconnector/src/rtmpappprotocolhandler.cpp:30:
In file included from /usr/local/include/Poco/Net/HTTPClientSession.h:44:
In file included from /usr/local/include/Poco/Net/HTTPSession.h:44:
In file included from /usr/local/include/Poco/Net/StreamSocket.h:44:
In file included from /usr/local/include/Poco/Net/Socket.h:44:
In file included from /usr/local/include/Poco/Net/SocketImpl.h:47:
In file included from /usr/local/include/Poco/Timespan.h:44:
/usr/local/include/Poco/Timestamp.h:50:1: error: declaration of anonymous class must be a definition
class Foundation_API Timestamp
^
/usr/local/include/Poco/Timestamp.h:149:24: error: expected identifier
inline bool Timestamp::operator == (const Timestamp& ts) const
                       ^
/usr/local/include/Poco/Timestamp.h:149:13: error: declaration of anonymous struct must be a definition
inline bool Timestamp::operator == (const Timestamp& ts) const
            ^
../crtmpserver/sources/common/include/platform/osx/osxplatform.h:109:19: note: expanded from macro 'Timestamp'
#define Timestamp struct tm
                  ^
In file included from ../crtmpserver/sources/applications/idomsconnector/src/rtmpappprotocolhandler.cpp:30:
In file included from /usr/local/include/Poco/Net/HTTPClientSession.h:44:
In file included from /usr/local/include/Poco/Net/HTTPSession.h:44:
In file included from /usr/local/include/Poco/Net/StreamSocket.h:44:
In file included from /usr/local/include/Poco/Net/Socket.h:44:
In file included from /usr/local/include/Poco/Net/SocketImpl.h:47:
In file included from /usr/local/include/Poco/Timespan.h:44:
/usr/local/include/Poco/Timestamp.h:262:1: error: expected unqualified-id
} // namespace Poco
^
In file included from ../crtmpserver/sources/applications/idomsconnector/src/rtmpappprotocolhandler.cpp:30:
In file included from /usr/local/include/Poco/Net/HTTPClientSession.h:44:
In file included from /usr/local/include/Poco/Net/HTTPSession.h:44:
In file included from /usr/local/include/Poco/Net/StreamSocket.h:44:
In file included from /usr/local/include/Poco/Net/Socket.h:44:
In file included from /usr/local/include/Poco/Net/SocketImpl.h:47:
/usr/local/include/Poco/Timespan.h:54:21: error: no struct named 'TimeDiff' in 'tm'
        typedef Timestamp::TimeDiff TimeDiff;
                ~~~~~~~~~~~^
In file included from ../crtmpserver/sources/applications/idomsconnector/src/rtmpappprotocolhandler.cpp:30:
In file included from /usr/local/include/Poco/Net/HTTPClientSession.h:44:
In file included from /usr/local/include/Poco/Net/HTTPSession.h:47:
/usr/local/include/Poco/Any.h:123:46: error: cannot use typeid with -fno-rtti
        return _content ? _content->type() : typeid(void);
                                             ^
/usr/local/include/Poco/Any.h:149:20: error: cannot use typeid with -fno-rtti
            return typeid(ValueType);
                   ^
/usr/local/include/Poco/Any.h:180:42: error: cannot use typeid with -fno-rtti
    return operand && operand->type() == typeid(ValueType)
                                         ^
In file included from ../crtmpserver/sources/applications/idomsconnector/src/rtmpappprotocolhandler.cpp:30:
/usr/local/include/Poco/Net/HTTPClientSession.h:291:8: error: expected member name or ';' after declaration specifiers
        Poco::Timestamp _lastRequest;
        ~~~~  ^
../crtmpserver/sources/common/include/platform/osx/osxplatform.h:109:19: note: expanded from macro 'Timestamp'
#define Timestamp struct tm
                  ^
../crtmpserver/sources/applications/idomsconnector/src/rtmpappprotocolhandler.cpp:94:10: error: expected expression
form.add(<D2>entry1<D3>, <D2>value1<D3>);
         ^
../crtmpserver/sources/applications/idomsconnector/src/rtmpappprotocolhandler.cpp:97:25: error: variable has incomplete type 'Poco::Net::HTTPResponse'
Poco::Net::HTTPResponse response;
                        ^
/usr/local/include/Poco/Net/HTTPClientSession.h:55:7: note: forward declaration of 'Poco::Net::HTTPResponse'
class HTTPResponse;
      ^
../crtmpserver/sources/applications/idomsconnector/src/rtmpappprotocolhandler.cpp:99:41: error: no member named 'cout' in namespace 'std'; did you mean 'count'?
Poco::StreamCopier::copyStream(rs, std::cout);
                                   ~~~~~^~~~
                                        count
/usr/include/c++/4.2.1/bits/stl_algo.h:424:5: note: 'count' declared here
    count(_InputIterator __first, _InputIterator __last, const _Tp& __value)
    ^
../crtmpserver/sources/applications/idomsconnector/src/rtmpappprotocolhandler.cpp:99:36: error: address of overloaded function 'count' does not match required type 'std::basic_ostream<char>'
Poco::StreamCopier::copyStream(rs, std::cout);
                                   ^~~~~~~~~
/usr/include/c++/4.2.1/bits/stl_algo.h:424:5: note: candidate function
    count(_InputIterator __first, _InputIterator __last, const _Tp& __value)
    ^
/usr/local/include/Poco/StreamCopier.h:57:73: note: passing argument to parameter 'ostr' here
    static std::streamsize copyStream(std::istream& istr, std::ostream& ostr, std::size_t bufferSize = 8192);
                                                                        ^
13 errors generated.
make[2]: *** [applications/idomsconnector/CMakeFiles/idomsconnector.dir/Users/[...]/sources/applications/idomsconnector/src/rtmpappprotocolhandler.cpp.o] Error 1
make[1]: *** [applications/idomsconnector/CMakeFiles/idomsconnector.dir/all] Error 2
make: *** [all] Error 2
build failed

我的代码片段如下:

#include <Poco/Net/HTTPRequest.h>
#include <Poco/Net/HTTPClientSession.h>
#include <Poco/Net/HTMLForm.h>
#include <Poco/StreamCopier.h>

string RTMPAppProtocolHandler::GetAuthPassword(string user) {
     INFO("Testing auth: %s", STR(user));

     Poco::Net::HTTPClientSession s("www.somehost.com");
     //s.setProxy("localhost", srv.port());
     Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_GET, "/large");
     Poco::Net::HTMLForm form;
     form.add(“entry1”, “value1”);
     form.prepareSubmit(request);
     s.sendRequest(request);
     Poco::Net::HTTPResponse response;
     std::istream& rs = s.receiveResponse(response);
     Poco::StreamCopier::copyStream(rs, std::cout); 

   return user;
}

我做了些蠢事吗?这只是与我需要修改的HTTP服务器的这种小交互,所以我只是在寻找一个非常简单的解决方案,但很难找到一些简单易用的东西(主要是因为我不熟悉C ++)

0 个答案:

没有答案