0

I have used this command.

libtool --mode=compile gcc -g -o -c foo.c

Actual output should be like this after the command:

$libtool --mode=compile gcc -g -O -c foo.c
     mkdir .libs
     gcc -g -O -c foo.c  -fPIC -DPIC -o .libs/foo.o
     gcc -g -O -c foo.c -o foo.o >/dev/null 2>&1 

but observed output is

$libtool --mode=compile gcc -g -O -c foo.c
     gcc -g -O -c foo.c  -fPIC -DPIC -o .libs/foo.o
     gcc -g -O -c foo.c -o foo.o >/dev/null 2>&1. 

.libs directory is not creating. It there any changes i have to make

user2732944
  • 75
  • 2
  • 4
  • 10

1 Answers1

0

http://www.gnu.org/software/libtool/manual/html_node/Creating-object-files.html

On shared library systems, libtool automatically generates an additional PIC object by inserting the appropriate PIC generation flags into the compilation command:

 burger$ libtool --mode=compile gcc -g -O -c foo.c
 mkdir .libs
 gcc -g -O -c foo.c  -fPIC -DPIC -o .libs/foo.o
 gcc -g -O -c foo.c -o foo.o >/dev/null 2>&1
 burger$

Note that Libtool automatically created .libs directory upon its first execution, where PIC library object files will be stored.

Since ‘burger’ supports shared libraries, and requires PIC objects to build them, Libtool has compiled a PIC object this time, and made a note of it in the libtool object:

 # foo.lo - a libtool object file
 # Generated by ltmain.sh (GNU libtool) 2.4.2
 #
 # Please DO NOT delete this file!
 # It is necessary for linking the library.

 # Name of the PIC object.
 pic_object='.libs/foo.o'

 # Name of the non-PIC object.
 non_pic_object='foo.o'

Notice that the second run of GCC has its output discarded. This is done so that compiler warnings aren't annoyingly duplicated. If you need to see both sets of warnings (you might have conditional code inside ‘#ifdef PIC’ for example), you can turn off suppression with the -no-suppress option to libtool's compile mode:

 burger$ libtool --mode=compile gcc -no-suppress -g -O -c hello.c
 gcc -g -O -c hello.c  -fPIC -DPIC -o .libs/hello.o
 gcc -g -O -c hello.c -o hello.o
 burger$

I hope this would be helpful. Thanks & Regards,
Alok

linux_fanatic
  • 4,767
  • 3
  • 19
  • 20
  • I think u didn't understand my question. i too had this tutorial. my problem is .libs is not creating while giving the above command – user2732944 Sep 10 '13 at 07:55
  • http://stackoverflow.com/questions/10815954/libtool-doesnt-create-a-shared-library this would surely help, you can use rpath. – linux_fanatic Sep 10 '13 at 08:31