Re: my libLIB.a is missing symbols, need sol'n

From: Fletcher Glenn (fletcher_at_removethisfoglight.com)
Date: 11/13/03


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


Relevant Pages

  • Re: linking issue
    ... my code (of which i have made my lib) consist of Functions which are ... mapped into the WinCE API's. ... this library it is giving me linking issues. ... which i have to include while compiling or any flags issue. ...
    (microsoft.public.windowsce.embedded.vc)
  • Re: DDK W2k3 bug? WNET and WXP build ok, W2k doesnt work
    ... > Linking Executable - ...
    (microsoft.public.development.device.drivers)
  • DDK W2k3 bug? WNET and WXP build ok, W2k doesnt work
    ... W2k does only work for executables and some of the libraries. ... Compiling message file - src\input\kbdclass\kbdlog.mc for all platforms ...
    (microsoft.public.development.device.drivers)
  • Re: linking issue
    ... mapped into the WinCE API's. ... this library it is giving me linking issues. ... which i have to include while compiling or any flags issue. ... Please do tell me all the paths and flags needed to compile code on ...
    (microsoft.public.windowsce.embedded.vc)
  • Re: directx samples
    ... > headers for compiling, libs for linking, src for the common files. ... I checked the paths and settings to see lib files already added. ... the same as the error for the newer PC with larger directx3D programs like ...
    (microsoft.public.win32.programmer.directx.graphics)