"vivekian" <[EMAIL PROTECTED]> writes:

> These are the steps i followed to create a shared library

These steps are un-necessarily complicated.
You are (apparently) following some DSO-HOWTO, but without
understanding why things are done in "complicated" way, and whether
that complicated way is appropriate for your situation.

> g++ -shared -Wl,-soname,libcppsocket.so.1 -o libcppsocket.so.1.0.1
> SockException.o Socket.o TcpSocket.o UdpSocket.o SocketReaderWriter.o -
> lc

Until you need "external library versioning", I suggest you use
"simple" way:

  g++ -shared -o libcppsocket.so \
    SockException.o Socket.o TcpSocket.o UdpSocket.o SocketReaderWriter.o

> 5. Compiling this test program
>
> g++  main.cpp
> /tmp/ccPqeVa9.o: In function `main':
> main.cpp:(.text+0x8a): undefined reference to `TcpSocket::TcpSocket()'
> main.cpp:(.text+0x95): undefined reference to
> `TcpSocket::~TcpSocket()'
> collect2: ld returned 1 exit status
>
> gives the above error.
>
> This i suppose indicates that the library has to be linked.

Correct.

> But the following doesnt help
> g++ main.cpp -llibcppsocket

And it shouldn't help. Provided /usr/lib/libcppsocket.so exists,
correct link line is:

  g++ main.cpp -lcppsocket

> What am i missing here ?

Well, for starters you didn't tell us (nor paid attention to)
the error linker gave you, which likely was:

  /usr/bin/ld: cannot find -llibcppsocket

Please read "info gcc" to understand what library the linker will
search for given '-llibcppsocket' argument. Hint libcppsocket.*
it is not.

Cheers,
-- 
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.
_______________________________________________
help-gplusplus mailing list
help-gplusplus@gnu.org
http://lists.gnu.org/mailman/listinfo/help-gplusplus

Reply via email to