Hi Oliver,

you try to compile a C++ program using a C compiler. gcc runs the C 
compiler and g++ runs the C++ compiler.

And there is another problem with the command line. Calling the compiler 
without -c flag runs the linker also. The you should not specify a *.o 
file as output.

Either
     g++ -c tntsocketserver.cpp
     g++ -o tntsocketserver -lcxxtools -lcxxtools-http -lcxxtools-xmlrpc 
tntsocketserver.o

to just compile tntsocketserver.cpp to tntsocketserver.o and run the 
linker separately. or:
     g++ -o tntsocketserver -lcxxtools -lcxxtools-http -lcxxtools-xmlrpc 
tntsocketserver.cpp

to compile and link in one step.

And this answers your other question also. You need -lcxxtools-http 
since xmlrpc uses the http server.


Tommi

Am 18.08.2014 15:26, schrieb Oliver Rath:
> Hi list,
>
> Im trying to use xmlrpc-socket, taken from
> http://www.tntnet.org/howto/xmlrpc-howto.html
>
> So i created a file tntsocketserver  (original code from tntnet.org):
> -------------- snip -------------------------------
> #include <cxxtools/eventloop.h>
> #include <cxxtools/http/server.h>
> #include <cxxtools/xmlrpc/service.h>
>
>
> double add(double a1, double a2)
> {
>      return a1 + a2;
> }
>
> double sub(double a1, double a2)
> {
>      return a1 - a2;
> }
> int main(int argc, char* argv[])
> {
>      try
>      {
>          // Define a event loop
>          cxxtools::EventLoop loop;
>
>          // Define a http server first
>          cxxtools::http::Server httpServer(loop, 8077);
>
>          // for xml rpc we need a service object
>          cxxtools::xmlrpc::Service service;
>
>          // register the methods
>          service.registerFunction("add", add);
>          service.registerFunction("sub", sub);
>
>          // ... and register the service under a url
>          httpServer.addService("/xmlrpc", service);
>
>          // and run our server
>          loop.run();
>      }
>      catch (const std::exception& e)
>      {
>          std::cerr << e.what() << std::endl;
>      }
> }
> -------------- snip -------------------------------
> # gcc -o tntsocketserver.o tntsocketserver.cpp
> tntsocketserver.cpp: In function ‘int main(int, char**)’:
> tntsocketserver.cpp:40:9: error: ‘cerr’ is not a member of ‘std’
>           std::cerr << e.what() << std::endl;
>           ^
>
> including <iostream> didnt help also.
>
> Whats wrong here?
>
> Tfh!
> Oliver
>
>
> ------------------------------------------------------------------------------
> _______________________________________________
> Tntnet-general mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/tntnet-general


------------------------------------------------------------------------------
_______________________________________________
Tntnet-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tntnet-general

Reply via email to