I have the same problem as others have:
- I have a
*.la
file generated by libtool in an Automake project (e.g.module.la
), - but I need the
*.so
of it to use it fordlopen()
(eg.module.so
).
But: project is configured and built with --disable-shared
to make sure the created main binary is one big statically linked program, e.g. main.x
(easier for deployment and debugging). Thus *.so
files are not created.
The program main.x
is a huge framework-like application which is capable of loading extensions (modules) via dlopen()
-- despite it being linked statically.
This works fine when I build module.so
by hand. But putting this to work in Makefile.am
seems impossible to me. Yes, I can write lib_LTLIBRARIES
, but with my standard --disable-shared
I do not get a *.so
file.
lib_LTLIBRARIES = module.la
module_so_SOURCES = module.cpp
The file module.la
is created, which dlopen()
refuses to load (of course).
I tried to put rules into Makefile.am
building it manually and that works:
# Makefile.am (yes, .am)
all: mm_cpp_logger.so
SUFFIXES = .so
%.so: %.cpp
$(CXX) $(CXXFLAGS) -fPIC -fpic -c -I $(top_srcdir)/include -o $@ $<
%.so: %.o
$(CXX) $(LDFLAGS) -shared -fPIC -fpic -o $@ $<
But this can only be a workaround. I do not get all the nice auto-features like dependency-checking and installation.
How can I build module.so
with still building the main program with --disable-shared
(or with the same effect) in the Makefile.am
-way?
- can I postprocess
*.la
files to*.so
files with a special automake rule? - can I tweak the
lib_LTLIBRARIES
process to create*.so
files in any case?
-all-static
at ''application'' with-static-libtool-libs
at my other "convenience" libraries (not the one under our discussion) -- I had to do that becausedl_blahblah()
-stuff crashed the program when I did-all-static
(I am quite sure that it was the culprit). Anyway: Alas, I still do get the.libs/mm_cpp_logger.so
-- which I find a bit awkward when writing tests for the module. Loading it from.libs/
seems... wrong. Is it normal that it always gets there, no matter what I do? – Nolte