Archived

This forum has been archived. Please start a new discussion on GitHub.

Client as shared object

Hi,
i'm trying to make Client.cpp (even that from manual) as postgresql funtion. So i compiled (under Linux) Server like manual says and in Client i replace "int main(int argc, char* argv[])" to "::Ice::Double ClientSquare(::Ice::Double x)". I create Client.h:
#ifndef __Client_h__
#define __Client_h__
double ClientSquare(double x);
#endif

And i compiled this:
g++ -I. -I/home/include -fPIC -c -Wall Sqrt.cpp Client.cpp
g++ -shared -Wl,-soname,libsqrt.so.1 -o libsqrt.so.1.0.1 Sqrt.o Client.o -L/home/lib -lIce -lIceUtil

I don't know if i did that correct... Does anybody could tell me how to make client as shared object file?

Thanks for all suggestions

Comments

  • benoit
    benoit Rennes, France
    Hi,

    I recommend checking out the compilation of the IceBox hello service for an example on how to build a shared library, the demo is located in your demo/IceBox/hello directory.

    Cheers,
    Benoit.
  • benoit wrote: »
    Hi,

    I recommend checking out the compilation of the IceBox hello service for an example on how to build a shared library, the demo is located in your demo/IceBox/hello directory.

    Cheers,
    Benoit.

    Thanks for reply Benoit. But this example is for Windows and it shows how to make server as share library, and i would like make client as share object under linux. Does THIS example is also for me? I'm not very advanced in compiling under Linux.
  • benoit
    benoit Rennes, France
    Hi,

    The IceBox hello demo also has a Makefile to build the demo on Linux. Building an Ice client or an Ice server as a shared library is the same so I recommend checking out the build commands of this demo to figure out how to build your Ice program as a shared library on Linux.

    If you are looking for instructions on how to write an Ice client (and not only how to build it), you should start with taking a look at demo/Ice/minimal/Client.cpp (and not the IceBox hello code which is not what you want). This minimal client demonstrates the code required at a minimum to make an Ice invocation on a server.

    Cheers,
    Benoit.
  • Meybe i don't understanding something but in folder ZeroC\Ice-3.4.2-demos\demo\IceBox\hello i have only Makefile.mak, which is for Windows, but i can't find makefile for Linux.
  • benoit
    benoit Rennes, France
    For Unix platforms, you need to download the sample programs archive from our download page at this link.

    Cheers,
    Benoit.
  • xdm
    xdm La Coruña, Spain
    Note that if you are trying to build a postgresql function, your ClientSquare function must use extern C linkage, see PostgreSQL documentation about using C++ PostgreSQL: Documentation: 9.1: C-Language Functions
  • So of course you're right :) But now when i do make in ~/Ice-3.4.2-demos/demo/ $ or ~/Ice-3.4.2-demos/demo/IceBox $
    i always get error:
    make[2]: *** No rule to make target `/usr/lib/libSlice.so.3.4.2', needed by `Hello.cpp'.  Stop.
    

    I working under Gentoo and i get Ice from emerge Ice, so i have installed

    * dev-libs/Ice
    Latest version available: 3.4.1
    Latest version installed: 3.4.1
    Size of files: 5,140 kB
    Homepage: Welcome to ZeroC, the Home of Ice
    Description: ICE middleware C++ library and generator tools
    License: GPL-2


    but i also see

    * dev-cpp/IceE [ Masked ]
    Latest version available: 1.3.0-r1
    Latest version installed: [ Not Installed ]
    Size of files: 1,222 kB
    Homepage: ZeroC - Ice-E Overview
    Description: The Internet Communications Engine (Ice) is a modern object-oriented middleware with support for C++, .NET, Java, Python, Ruby, and PHP
    License: GPL-2



    Should i install dev-cpp/IceE? I've read that that error shows when you don't have installed Ice, but i have dev-libs/Ice
    dev-cpp/IceE
  • xdm
    xdm La Coruña, Spain
    The demo fails to build because you have not installed Ice-3.4.2. If you are using 3.4.1 you can download 3.4.1 demos from http://www.zeroc.com/download/Ice/3.4/Ice-3.4.1-demos.tar.gz

    You can also try to update to Ice-3.4.2, build it from source , or unmask the Ice-3.4.2 package in gentoo portage.

    To install 3.4.2 from gentoo portage.
    # echo "=dev-libs/Ice-3.4.2 **" >>  /etc/portage/package.keywords 
    # emerge dev-libs/Ice -a
    These are the packages that would be merged, in order:
    
    Calculating dependencies... done!
    [ebuild  N    ~] dev-libs/Ice-3.4.2  USE="ncurses -debug -doc -examples -mono -python -ruby -test" RUBY_TARGETS="-ruby18" 
    
    Would you like to merge these packages? [Yes/No] 
    
  • I have made that using classic hello world from IceManual for C++. I had to manual compile library with postgreSQL and it's working!

    Thanks for your help!