This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Repost: OSR 5.0.5 strange linker problem.. (nobody?)


[Sorry, but I still haven't solved this.. Next repost I'd better mail to Robert Lipe directly :)]


Hi all,

I'm having a rather bizarre problem on SCO OSR 5.0.5 with GCC 2.95.2.
It seems that the result of getservbyname() is influenced by my
linking in a c++ library or omitting that library. I have included a
small testcase below.

Problem:
- If I make 'test' like this, it says 'Port: 0', which is incorrect.
- If I omit libdummy.so, or make libdummy.so a C-library by compiling
  with GCC instead of G++, or link with libdummy.a, then 'test' says
  'Port: 8900', which is correct.

The libdummy is just to show that linking any C++ library will kill
getservbyname(). I'm not entirely sure whether this is the correct
way to build a shared libdummy, but the method seems to work fine for
our 'real' libraries except for this problem. Building with '-shared'
won't work for me, the linker complains about missing libm symbols in
that case (don't have a libm.so)

Thanks!

        Rob Kramer
        robk@cyberway.com.sg


------------------------------------------------------------
(all in /usr/rob/test)

--- test.cc ---
#include <iostream>
#include <sys/socket.h>
#include <netdb.h>
#include <netinet/in.h>

int main ()
{
        struct servent  *port;
        char            *serv = "SMRTTISCM_BOOT_REQ";

        if (port = getservbyname (serv, "udp"))
             cout << "Port: " << ntohs ((short) port->s_port) << endl;
}


--- dummy.cc ---
void dummy ()
{
   static int count = 0;
   count++;
}


--- Makefile ---
CFLAGS          = -Wall -Wno-parentheses

LIBS            = libdummy.so \
                  -lsocket

all:            test


libdummy.a:     dummy.o
                rm -f libdummy.a
                ar rs libdummy.a dummy.o

libdummy.so:    dummy.o
                g++ -G -dy -h /usr/rob/test/libdummy.so dummy.o -o libdummy.so

test:           test.o
                g++ $(CFLAGS) -o test test.o $(LIBS)

.cc.o:
                g++ -c $(CFLAGS) $<





--== Sent via Deja.com http://www.deja.com/ ==--
Share what you know. Learn what you don't.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]