I've prefixed all the symbols exported from the wxGTK3 library with '
wxGTK3_', and I've prefixed all the symbols exported from the wxX11 library with '
wxX11_', as follows:
Code: Select all
#!/bin/sh
echo - - - - Deleting all files
rm -rf *.o *.a
echo - - - - Copying intact .a files
/usr/local/lib/wx/config/gtk3-unicode-static-3.2 --libs all | tr ' ' '\n' | sort | uniq | grep "\.a$" | xargs -i -r -n1 cp "{}" ./
echo - - - - Extracting .o files from .a files
find -name "*\.a" | xargs -i -r -n1 ar -x "{}"
echo - - - - Deleting all .a files
rm -rf *.a
echo - - - - Compiling an exhaustive list of exported symbols
nm *.o | grep -E "^[0-9a-f]{16} T " | cut -d ' ' -f 3 | sort | uniq > exported_symbols.txt
echo - - - - Adding a prefix to all the exported symbols
find -name "*\.o" | while read objfile; do cat exported_symbols.txt | xargs -i -r -n1 objcopy --redefine-sym {}=wxGTK3_{} ${objfile}; done
Next in the
Makefile for my program, I compile all the GUI-related files twice, once for wxGTK3 and once for wxX11:
Code: Select all
wxwidgets/%.cpp.x11.o: wxwidgets/%.cpp $(wildcard wxwidgets/*.h wxwidgets/*.hpp)
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $< -o $@ $(wxwidgets_cxxflags_x11)
cat wxwidgets/x11/exported_symbols.txt | while read symbol; do objcopy --redefine-sym $${symbol}=wxX11_$${symbol} $@; done
wxwidgets/%.cpp.gtk3.o: wxwidgets/%.cpp $(wildcard wxwidgets/*.h wxwidgets/*.hpp)
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $< -o $@ $(wxwidgets_cxxflags_gtk3)
cat wxwidgets/gtk3/exported_symbols.txt | while read symbol; do objcopy --redefine-sym $${symbol}=wxGTK3_$${symbol} $@; done
When I link my program together, the object files seeking symbols from wxX11 should find them all prefixed with "wxX11_" in the altered wxX11 static library files, and the object files seeking symbols from wxGTK3 should find them all prefixed with "wxGTK3_" in the altered wxGTK3 static library files.
I might have this finished today. It's taking ages to rename all the symbols in static library files -- it's still not finished doing that.