0

HTTP 要求を実行して結果を受け取ることができるように POCO を含めることで、C++ プログラムを変更しようとしています。基本的に、別の 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++ に慣れていないため)。

4

0 に答える 0