Archived

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

can not link on Mac OS X

Hello,

I am evaluating ICE for a project. I do not have a license so I hope someone can find time to give me a quick answer to what I hope is a simple question.

I am using your OS X kit downloaded from http://www.zeroc.com/download/Ice/3.4/Ice-3.4.2-bin-macosx.tar.gz . I exploded this and put it in /opt/Ice-3.4. I added /opt/Ice-3.4/bin to my PATH.

I am able to run slice2cpp with my Factory.ice file and generate Factory.cpp and Factory.h without incident.

I am able to compie my application using "-I/opt/Ice-3.4/include" without incident.

But when I link my app using "-L/opt/Ice-3.4/lib -lIce" I get a great many Undefined references. The linker does find libIce.dylib. The complete listing is hundreds of lines long but I have pasted the first few lines below.

I am running Mac OS X.8.2 and using g++ 4.2.1 (from Xcode 4.5.2).

Note that my app links and runs fine on Linux (CentOS 6.2).

Thanks for any ideas.

Best regards,

Elwood


g++ -g -L../libastro -L../liblilxml -L../libz -L../libip -L../liblevmar -L../libmd5sum -L/opt/local/lib -L/opt/Ice-3.4/lib -o indilbto indilbto.o Factory.o IIFServer.o indidrivermain.o eventloop.o configfile.o -lIce -lastro -lip -llilxml -lz -llevmar -lmd5sum -lm
Undefined symbols for architecture x86_64:
"IceInternal::BasicStream::readTypeId(std::basic_string<char, std::char_traits<char>, std::allocator<char> >&)", referenced from:
lbto::Factory::__read(IceInternal::BasicStream*, bool) in Factory.o
lbto::IIFServer::__read(IceInternal::BasicStream*, bool) in IIFServer.o
"IceInternal::BasicStream::writeTypeId(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)", referenced from:
lbto::Factory::__write(IceInternal::BasicStream*) const in Factory.o
virtual thunk to lbto::Factory::__write(IceInternal::BasicStream*) constin Factory.o
lbto::IIFServer::__write(IceInternal::BasicStream*) const in IIFServer.o
virtual thunk to lbto::IIFServer::__write(IceInternal::BasicStream*) constin IIFServer.o
"IceInternal::BasicStream::endReadSlice()", referenced from:
lbto::Factory::__read(IceInternal::BasicStream*, bool) in Factory.o
lbto::IIFServer::__read(IceInternal::BasicStream*, bool) in IIFServer.o
"IceInternal::BasicStream::endWriteSlice()", referenced from:
lbto::Factory::__write(IceInternal::BasicStream*) const in Factory.o
virtual thunk to lbto::Factory::__write(IceInternal::BasicStream*) constin Factory.o
lbto::IIFServer::__write(IceInternal::BasicStream*) const in IIFServer.o
virtual thunk to lbto::IIFServer::__write(IceInternal::BasicStream*) constin IIFServer.o

Comments

  • xdm
    xdm La Coruña, Spain
    You need to link with IceUtil and pthreads too, add -lIceUtil -lpthread to your link command
  • Thanks very much for the quick reply. Unfortunately, no joy:


    g++ -g -pthread -L../libastro -L../liblilxml -L../libz -L../libip -L../liblevmar -L../libmd5sum -L/opt/local/lib -o indilbto indilbto.o Factory.o IIFServer.o indilbtoprops.o indidrivermain.o eventloop.o configfile.o -L/opt/Ice-3.4/lib -lIce -lIceUtil -lastro -lip -llilxml -lz -llevmar -lmd5sum -lm
    Undefined symbols for architecture x86_64:
    "IceInternal::BasicStream::readTypeId(std::basic_string<char, std::char_traits<char>, std::allocator<char> >&)", referenced from:
    lbto::Factory::__read(IceInternal::BasicStream*, bool) in Factory.o
    lbto::IIFServer::__read(IceInternal::BasicStream*, bool) in IIFServer.o
    "IceInternal::BasicStream::writeTypeId(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)", referenced from:
    lbto::Factory::__write(IceInternal::BasicStream*) const in Factory.o
    virtual thunk to lbto::Factory::__write(IceInternal::BasicStream*) constin Factory.o
    lbto::IIFServer::__write(IceInternal::BasicStream*) const in IIFServer.o
    virtual thunk to lbto::IIFServer::__write(IceInternal::BasicStream*) constin IIFServer.o
  • xdm
    xdm La Coruña, Spain
    Seems to me that you have libICE from Xorg in the /opt/local/lib or an older Ice version from mac ports and that could be causing the link problems, try to put -L/opt/Ice-3.4/lib -lIce -lIceUtil before -L/opt/local/lib
  • xdm wrote: »
    Seems to me that you have libICE from Xorg in the /opt/local/lib or an older Ice version from mac ports and that could be causing the link problems, try to put -L/opt/Ice-3.4/lib -lIce -lIceUtil before -L/opt/local/lib

    That was it, I didn't know Xorg already installed an ICE in /opt/local. I changed the compile and linker flags to use the fresh copy I put in /opt/Ice-3.4 before /opt/local and now it works fine. Thanks very much for your help.
  • xdm
    xdm La Coruña, Spain
    Glad you solve the issue, note that the xorg library is not related to ZeroC Ice, is an xorg library (Inter-Client Exchange Library)
  • xdm wrote: »
    Glad you solve the issue, note that the xorg library is not related to ZeroC Ice, is an xorg library (Inter-Client Exchange Library)

    I learn something every day. Thanks again.
  • xdm wrote: »
    Glad you solve the issue, note that the xorg library is not related to ZeroC Ice, is an xorg library (Inter-Client Exchange Library)

    ... and can make it very very annoying to use cmake to build Ice serverson MacOS, because if you do FIND_LIBRARY(... Ice) it will find libICE before libIce and give you similar linker errors.

    I assume that's why MacPorts has renamed the file libZeroCIce -- although that renaming wasn't obvious either until I poked around a bit.

    Background: I don't use Macs myself, but I'm working on a large-ish system where some component developers do work and test on a Mac so our build process needs to support it.

    MEF