Find the answer to your Linux question:
Results 1 to 3 of 3
Hi, How can i make gcc linker to use static library to link from a predefined library path where i have .so and .a libraries of same name, like libx.so ...
  1. #1
    Just Joined!
    Join Date
    Jan 2008
    Posts
    2

    static library linking

    Hi,

    How can i make gcc linker to use static library to link from a predefined library path where i have .so and .a libraries of same name, like libx.so and libx.a ???

    Actually, if i give " gcc < myprogram.c > -lx " , by default linking is done with .so library ie libx.so. So, what i mean is i dont want to mention entire path of my .a library which is at predefined library path, where a .so library is present too with same name.

    Thanks in advance
    Barz

  2. #2
    Linux Enthusiast
    Join Date
    Aug 2006
    Posts
    631

  3. #3
    Just Joined!
    Join Date
    Jan 2007
    Posts
    9
    surround the libraries you wish to link statically with -static and -dynamic
    Ex:
    gcc -o foo foo.o bar.o -L/s/X11R6.3-1/lib -R/s/X11R6.3-1/lib \
    -static -lX11 -lXext -dynamic -lXt -lSM -lsocket -lnsl

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...