LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Autotools - linking application and library and dependency issue (https://www.linuxquestions.org/questions/programming-9/autotools-linking-application-and-library-and-dependency-issue-4175440641/)

AuthorsGary 12-09-2012 01:39 AM

Autotools - linking application and library and dependency issue
 
Hi Guys,

I'm trying to use autotools for the first time, and I'm quite new to it, I've read several tutorials about it and still I can't find myself, Autotools seems like everything I need (and will need in the future) but it is so complected :confused:

anyhow, here are my questions:

1. my project tree is quite simple:
1.1 one application composed of 2-3 files.
1.2 one static library (not shared object) that is based on other standards linux library (pthread for example).

I've tried to create a configure.ac and Makefile.am files, started with autoscan template to create the configure.ac file, it all goes well when using the
Code:

autoreconf -i
but when trying to compile with
Code:

make
the completion fails, I'm quite sure that there is something wrong with my Makefile.am

Code:

AUTOMAKE_OPTIONS = subdir-objects

bin_PROGRAMS = testapp
testapp_SOURCES = tests/testapp_threaded.c \
tests/common.h \
tests/worker.c
testapp_LDADD = workqueue.a

noinst_LIBRARIES = workqueue.a
workqueue_a_SOURCES = lib/workqueue.h \
lib/workqueue.h
workqueue_a_LDADD = pthread


2. is there another build system nearly as powerful as the autotools but more user friendly for linux world?

I must say that my intention here is to learn the process and not to solve a specific issue cause I'm sure I'm gonna need to handle such situations in the near future.

many thanks in advance

ntubski 12-09-2012 11:22 AM

Quote:

Originally Posted by AuthorsGary (Post 4845530)
it all goes well when using the
Code:

autoreconf -i
but when trying to compile with
Code:

make
the completion fails,

You didn't say what "fails" means, are there some error message, or what? I guess the problem is that you are missing a step, it goes like this:

Code:

autoreconf does configure.ac ---> configure & Makefile.am --> Makefile.in
./configure does Makefile.in ---> Makefile // NOTE: you missed this step
make uses Makefile to perform compilation.

Quote:

I'm quite sure that there is something wrong with my Makefile.am
Code:

...
noinst_LIBRARIES = workqueue.a
workqueue_a_SOURCES = lib/workqueue.h \
lib/workqueue.h
workqueue_a_LDADD = pthread


One of those hs should be a c, right? I also think pthread should linked to the final executable, not the helper library. Furthermore, you should also pass -pthread while compiling:
Quote:

man gcc
...
-pthread
Adds support for multithreading with the pthreads library. This option sets flags for both the preprocessor and linker.


Quote:

2. is there another build system nearly as powerful as the autotools but more user friendly for linux world?
I think the most common system after autotools is CMake. If you aren't looking to be portable to other unixes, using plain GNU Make is probably enough.


All times are GMT -5. The time now is 09:37 PM.