What I want to do is to create a new shared library called libxxx
that links against another shared library called libzzz
, this shared library has an independent "pkg-config"-like tool, let's say it's called "zzz-config" which gives the cflags needed by the compilation phase when using the libzzz
.
What I want to do is:
zzz-config
script cited above;src
directory and put compiled files in another directoryI've read almost all available tutorials for autotools but I was not able to figure a way to do that, if you can point some example would be very kindly.
Thank you !
My suggestion is to use CMake instead of autotools
. It's much easier to work with and it will also create platform-dependent projects to work with (i.e. Makefile-based projects, Visual Studio projects, Eclipse CDT projects, etc.).
It will also create debug
or release
projects, depending on the CMAKE_BUILD_TYPE
variable value.
Creating the libxxx
library is as simple as:
add_library(libxxx SHARED ${LIBXXX_SOURCES})
where LIBXXX_SOURCES
is a variable that holds the sources.
Linking the two libraries is just as easy (see target_link_libraries):
target_link_libraries(libxxx libzzz)
To get the compilation flags from the zzz-config
script you would use the execute_process command like so:
execute_process(COMMAND ./zzz-config
WORKING_DIRECTORY "<your_working_directory>"
OUTPUT_VARIABLE ZZZ_FLAGS)
Then you can set the CMAKE_C_FLAGS
or the CMAKE_CXX_FLAGS
variable to setup the required compilation flags.