Overview
Features
Download
Documentation
Community
Add-Ons & Services

Need help setting up PocoNet with codeblocks

Please post support and help requests here.

Need help setting up PocoNet with codeblocks

Postby innocentasia » 18 Jun 2012, 19:07

I downloaded and put the library in the right place but I get this error message :

obj\Debug\main.o||In function `main':|
C:\codeblocks\random numbe gen\main.cpp|37|undefined reference to `Poco::URI::URI(char const*)'|
C:\codeblocks\random numbe gen\main.cpp|38|undefined reference to `Poco::URI::getPort() const'|
C:\codeblocks\random numbe gen\main.cpp|38|undefined reference to `Poco::Net::HTTPClientSession::HTTPClientSession(std::string const&, unsigned short)'|
C:\codeblocks\random numbe gen\main.cpp|41|undefined reference to `Poco::URI::getPathAndQuery() const'|
C:\codeblocks\random numbe gen\main.cpp|45|undefined reference to `Poco::Net::HTTPMessage::HTTP_1_1'|
C:\codeblocks\random numbe gen\main.cpp|45|undefined reference to `Poco::Net::HTTPRequest::HTTP_GET'|
C:\codeblocks\random numbe gen\main.cpp|45|undefined reference to `Poco::Net::HTTPRequest::HTTPRequest(std::string const&, std::string const&, std::string const&)'|
C:\codeblocks\random numbe gen\main.cpp|46|undefined reference to `Poco::Net::HTTPClientSession::sendRequest(Poco::Net::HTTPRequest&)'|
C:\codeblocks\random numbe gen\main.cpp|49|undefined reference to `Poco::Net::HTTPResponse::HTTPResponse()'|
C:\codeblocks\random numbe gen\main.cpp|53|undefined reference to `Poco::Net::HTTPClientSession::receiveResponse(Poco::Net::HTTPResponse&)'|
C:\codeblocks\random numbe gen\main.cpp|54|undefined reference to `Poco::StreamCopier::copyStream(std::istream&, std::ostream&, unsigned int)'|
C:\codeblocks\random numbe gen\main.cpp|54|undefined reference to `Poco::Net::HTTPResponse::~HTTPResponse()'|
C:\codeblocks\random numbe gen\main.cpp|54|undefined reference to `Poco::Net::HTTPResponse::~HTTPResponse()'|
C:\codeblocks\random numbe gen\main.cpp|54|undefined reference to `Poco::Net::HTTPRequest::~HTTPRequest()'|
C:\codeblocks\random numbe gen\main.cpp|54|undefined reference to `Poco::Net::HTTPRequest::~HTTPRequest()'|
C:\codeblocks\random numbe gen\main.cpp|54|undefined reference to `Poco::Net::HTTPClientSession::~HTTPClientSession()'|
C:\codeblocks\random numbe gen\main.cpp|54|undefined reference to `Poco::Net::HTTPClientSession::~HTTPClientSession()'|
C:\codeblocks\random numbe gen\main.cpp|54|undefined reference to `Poco::URI::~URI()'|
C:\codeblocks\random numbe gen\main.cpp|54|undefined reference to `Poco::URI::~URI()'|
C:\codeblocks\random numbe gen\main.cpp|58|undefined reference to `Poco::Exception::displayText() const'|
||=== Build finished: 20 errors, 0 warnings ===|



This is the example code I am trying to compile:

#include <Poco/Net/HTTPClientSession.h>
#include <Poco/Net/HTTPRequest.h>
#include <Poco/Net/HTTPResponse.h>
#include <Poco/StreamCopier.h>
#include <Poco/Path.h>
#include <Poco/URI.h>
#include <Poco/Exception.h>
#include <iostream>
#include <string>
using namespace Poco::Net;
using namespace Poco;
using namespace std;

int main(int argc, char **argv)
{
if (argc != 2)
{
cout << "Usage: " << argv[0] << " <uri>" << endl;
cout << " fetches the resource identified by <uri> and print it" << endl;
return -1;
}

try
{
// prepare session
URI uri(argv[1]);
HTTPClientSession session(uri.getHost(), uri.getPort());

// prepare path
string path(uri.getPathAndQuery());
if (path.empty()) path = "/";

// send request
HTTPRequest req(HTTPRequest::HTTP_GET, path, HTTPMessage::HTTP_1_1);
session.sendRequest(req);

// get response
HTTPResponse res;
cout << res.getStatus() << " " << res.getReason() << endl;

// print response
istream &is = session.receiveResponse(res);
StreamCopier::copyStream(is, cout);
}
catch (Exception &ex)
{
cerr << ex.displayText() << endl;
return -1;
}

return 0;
}


Any help will be appreciated. Thanks
innocentasia
 
Posts: 1
Joined: 18 Jun 2012, 18:52

Re: Need help setting up PocoNet with codeblocks

Postby pasorobo » 23 Jun 2012, 14:35

First you must build POCO library (Foundation, Net, etc) using you C::B's backend compiler (Mingw GCC, or CL).

Then in you C::B project setting, just specify the POCO library path and the above built libraries.
(Your error log shows PocoFoundation and PocoNet can not be found )
pasorobo
 
Posts: 5
Joined: 01 Jun 2012, 19:24


Return to Support

Who is online

Users browsing this forum: No registered users and 6 guests

cron