Reputation: 7157
I have a simple C++ library which uses a short autoconf, automake and libtool to build a shared library object.
Now I want to be able to dynamically compile new code at run-time in my program, by:
I want to find the commands I need to run to do this. I can see the commands used by running 'make -n', but I really don't want to try using awk to search and replace bits of these commands!
Upvotes: 0
Views: 114
Reputation: 1023
This problem can be decomposed into following sub-problems:
Determine how you have compiled the program itself (compiler and / or flags should not be mixed, especially not in case of the C++ language).
You do this by exporting CC
, CXX
, CFLAGS
, CXXFLAGS
and CPPFLAGS
to the config.h
file using AC_DEFINE autoconf
macro in configure.ac
. Or you may use AC_SUBST
and your custom header.h.in
to store those variables in a file of your choice.
Then you call compiler CC
giving him CPPFLAGS
and CFLAGS
or CXX
with CPPFLAGS
and CXXFLAGS
. However, if you want to load those files by your program, you may consider using the Libtool library called libltdl, which implements plug-in stuff in a cross-platform way.
You may consider using libtool
script as a cross-platform compilation wrapper, but you will have to study it a bit since it is somehow arcane - there are compilation, linking and "installation" phases, but they are handled in a cross-platform way and if you pass the -sharee
argument, some additional flags you need (-fPIC
and possibly others) will be passed automagically.
Upvotes: 2