Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 131331
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T06:05:18+00:00 2026-05-11T06:05:18+00:00

In my project, modules are organized in subdirs for tidiness. My project dir hierarchy:

  • 0

In my project, modules are organized in subdirs for tidiness.

My project dir hierarchy:

$ ls -R .:         configure.in Makefile.am  Makefile.cvs  src ./src:     log          Makefile.am  main.cpp ./src/log: log.cpp      Makefile.am 

configure.in:

AC_INIT(configure.in) AM_CONFIG_HEADER(config.h) AM_INIT_AUTOMAKE(myapp, 0.1) AC_LANG_CPLUSPLUS AC_PROG_CXX AM_PROG_LIBTOOL AC_OUTPUT(Makefile src/Makefile src/log/Makefile) 

Makefile.am:

AUTOMAKE_OPTIONS = foreign SUBDIRS = src 

Makefile.cvs:

default:     aclocal     libtoolize --force --copy     autoheader     automake --add-missing --copy     autoconf 

src/Makefile.am

bin_PROGRAMS = myapp myapp_SOURCES = main.cpp SUBDIRS = log myapp_LDADD = $(top_builddir)/src/log/liblog.la 

src/log/Makefile.am:

INCLUDES = $(all_includes) METASOURCES = AUTO noinst_LTLIBRARIES = liblog.la liblog_la_SOURCES = log.cpp 

src/main.cpp: contains int main(){}, src/log/log.cpp contains void f(){}.

Invoking make produces (edited for brevity):

libtool --mode=compile g++     -MT log.lo -MD -MP -MF .deps/log.Tpo -c -o log.lo log.cpp libtool: compile:  g++ -MT log.lo -MD -MP -MF .deps/log.Tpo -c log.cpp  -fPIC -DPIC -o .libs/log.o libtool: compile:  g++ -MT log.lo -MD -MP -MF .deps/log.Tpo -c log.cpp -o log.o >/dev/null 2>&1 mv -f .deps/log.Tpo .deps/log.Plo libtool --mode=link g++    -o liblog.la  log.lo   libtool: link: ar cru .libs/liblog.a .libs/log.o  libtool: link: ranlib .libs/liblog.a libtool: link: ( cd '.libs' && rm -f 'liblog.la' && ln -s '../liblog.la' 'liblog.la' ) g++ -MT main.o -MD -MP -MF .deps/main.Tpo -c -o main.o main.cpp mv -f .deps/main.Tpo .deps/main.Po libtool --mode=link g++    -o myapp main.o ../src/log/liblog.la  libtool: link: g++ -o myapp main.o  ../src/log/.libs/liblog.a 

The problem is the first three lines: log.cpp is compiled twice!

The question: why isn’t it just compiled once — taking half the time?

note: I have no idea what I’m doing — autotools is black magic to me, but we have to use it in our place. The docs are incomprehensible to me.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T06:05:19+00:00Added an answer on May 11, 2026 at 6:05 am

    By default Libtool creates two types of libraries: static and shared. (aka libfoo.a and libfoo.so)

    Static and shard require different compilation flags. Dynamic libraries — shared objects use Position Independent Code with following gcc flags:

    -fPIC -DPIC 

    Static are not. You can force build only one type by specifing

    ./configure --disable-shared 

    or

    ./configure --disable-static 

    Rationale

    Usually when library is provided for user it provide in two setups — static for development that allows create pure static builds and dynamic for use by most of programs that use this library. So, usually when you install library in the system you only install shared object. (aka libfoo_XYZ.deb)

    When you add development version (aka libfoo-dev_XYZ.deb) you add headers and statically build version of the library that allows users make staic builds if they whant.

    This is common practice for shipping libraries in UNIX. Thus libtool does this for you automatically.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My project modules are organized in such a way that I have to maintain
I have a maven multi-modules project which has a depth of around 5 levels.
I have maven project with several modules. Need to deploy all modules( jars and
Our project constitutes of many modules (e.g. a HR management system containing modules like
I have a project divided into several sub-modules (each of them are jar libraries):
the project that i am involved in has a lot of small modules that
If I have 6 modules in my project is it possible to build only
I have a project that comprises pre-build Dll modules, built some time in the
I want to share some modules between a python GAE project, and another python
Every time I make a project I develop several generic routines/modules/libraries that I expect

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.