Google Answers Logo
View Question
 
Q: automake and dynamic libraries (.so) ( No Answer,   1 Comment )
Question  
Subject: automake and dynamic libraries (.so)
Category: Computers > Programming
Asked by: wshs-ga
List Price: $20.00
Posted: 22 Feb 2003 14:57 PST
Expires: 24 Mar 2003 14:57 PST
Question ID: 165724
Currently, I'm making my Makefiles manually.  I use the following 2
lines to compile a dynamic library:
gcc -fPIC -O9 -I. -c test.c
ld -Bshareable -x -o test.so test.o
...and all works fine.  However, I cannot find how to get automake to
compile the .so files, which are needed by my application.  I have the
following 3 lines in my automake file to compile test.so:
EXTRA_LTLIBRARIES = test.la
test_la_SOURCES = test.c
test_la_LDFLAGS = -module -export-dynamic $(LDFLAGS)
...Using those lines results in a .lo file being loaded, which cannot
be used by dlopen.  However, libtool has its own dlopen which can open
.lo files, but that is not what I want.  I'd rather use the system's
dlopen() suite.  If I change EXTRA to lib, it won't compile, and it
complains about duplicate _init and _fini functions in the source and
in /usr/lib/crti.o.  I'm using FreeBSD 4.7-STABLE, with gcc 2.95.4,
and automake 1.7.3.
Answer  
There is no answer at this time.

Comments  
Subject: Re: automake and dynamic libraries (.so)
From: schaffy-ga on 24 Feb 2003 07:59 PST
 
Hello,

The correct way to build your library with the autotools is, as you
wrote, by the 3 lines:

lib_LTLIBRARIES = test.la 
test_la_SOURCES = test.c 
test_la_LDFLAGS = -module -export-dynamic $(LDFLAGS)

The compile-time problem is a conflict between your source code and
the crti.o object file. I'm not sure where it comes from.
Anyway, according to the 2 lines you wrote at the beginning of your
mail, you do not want to have the crti (does it stand for C Run Time
Interrupt ?) object file included in your library.
So you should take a look at the output generated by the autotools to
know why crti.o is included. And thus, find a way to remove it from
the compilation process.

If you want a complete tutorial of the autotools, take a look at the
autobook.
(Chapter 10 might specialy interest you):
http://zeus.cs.ccu.edu.tw/~ska89/autobook-1.2/autobook_toc.html

Or you can download the source and auto-files of small library that I
did last year (I actually learned the autotools this way):
http://www.geocities.com/imageinfo_cpp/packages/ImageInfo_1.0.tar.gz

Hope this helps you,
Schaffy

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy