Re: my libLIB.a is missing symbols, need sol'n
From: Fletcher Glenn (fletcher_at_removethisfoglight.com)
Date: 11/13/03
- Next message: xtaci: "Re: How To Do Single Step debugging Under Sparc"
- Previous message: William Ahern: "Re: C Socket Programming question"
- In reply to: Shea Martin: "my libLIB.a is missing symbols, need sol'n"
- Next in thread: Paul Pluzhnikov: "Re: my libLIB.a is missing symbols, need sol'n"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 13 Nov 2003 00:41:29 GMT
Shea Martin wrote:
> I created a lib which uses sockets. On solaris that means binarys must
> be compiled with -lsocket -lnsl. I build my libLIB.a, with the
> following makefile:
> LIBS = -lnsl -lsocket
>
> .cc.o:
> $(CC) $(CCFLAGS) $<
>
> $(SUBLIB):$(OBJECTS)
> $(AR) cvr $@ $(OBJECTS)
>
> This works fine. But when ever I link against my new library, I also
> have to manually link against -lnsl and -lsocket. This can be confusing
> to those using my API. As any code built agains my library must have:
>
> LIBS = -L/path/to/my/lib -lLIB -lnsl -lsocket
>
> as opposed to just:
> LIBS = -L/path/to/my/lib -lLIB
>
>
> I tried adding $(LIBS) into my .cc.o, but that did not work, because no
> linking takes place when compiling objects. I didn't see an option to
> statically linking the two libs in at the $(AR) stage, though it is
> possible I missed something.
>
> Is there anyway around this?
>
> ~Shea M.
>
When you say that "no linking takes place when compiling something",
that is incorrect. Normally, you have to tell the compiler to not
link as when using the -c directive. So, the compile command for
your users should be:
CC -o final_program $(OBJS) -L/pathtoyourlib -lLIB -lnsl -lsocket
-- Fletcher Glenn
- Next message: xtaci: "Re: How To Do Single Step debugging Under Sparc"
- Previous message: William Ahern: "Re: C Socket Programming question"
- In reply to: Shea Martin: "my libLIB.a is missing symbols, need sol'n"
- Next in thread: Paul Pluzhnikov: "Re: my libLIB.a is missing symbols, need sol'n"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|