This repo contains a sample project with the Makefile.am and configure.ac files with content to construct a shared and static library for C++ (Linux and OSX).
Clone repo
git clone git@github.com:dblommesteijn/autotools-example.git
cd autotools-exampleConfiguration
Constructing configuration and Makefiles
autoreconf -vfi
./configureCompiling/ Linking
Compile and install the library to the OS defaults (/usr/local/lib and /usr/local/include)
sudo make installIncluding the created library with your project.
NOTE: you have to install the library before headers can be found, and linking can be done
C++ code snippet
This example can be found in example/.
#include <toollib.h>
int main(int args, char** argv) {
toollib("I'm using toollib!!");
return 0;
}Compile with clang
Assuming the library is installed at the OS default location, otherwise you have to provide flags -I and -L accordingly.
clang++ -Wall -std=c++11 -O3 -fPIC -c main.cpp
clang++ main.o -o main -lautotools
./mainYou have to become root to cleanup, because sudo make install generates src/.libs/*.
sudo sh cleanup.shsudo make uninstall