Hi,
I made a program with the wxWidgets library. But I don't know how to statically link it to that library?
What I want to achieve is that all the wxWidgets library code is inside the executable (such as a .lib in Windows). All the other libraries can be dynamically linked. This is because I know if you run my program you will have all the X-libraries on your system... But I can't assume you have the wx-ones.
What I have done so far (and works great for dynamically linking):
Code:
EXECUTABLE=test
BUILDDIR=builddir
CC=gcc
CFLAGS=-c -Wall -I/usr/lib/wx/include/gtk2-unicode-release-static-2.7 -I/usr/include/wx-2.7 -O2 -D__WXGTK__ -D_UNICODE -fPIC
LDFLAGS=-pthread -L/usr/lib -s -lwx_gtk2u_adv-2.7 -lwx_gtk2u_core-2.7 -lwx_baseu_net-2.7 -lwx_baseu-2.7
SOURCES=$(wildcard *.cpp)
OBJECTS := $(patsubst %.cpp,$(BUILDDIR)/%.o,$(SOURCES))
all: BUILDDIR_CREATION $(SOURCES) $(EXECUTABLE)
BUILDDIR_CREATION:
if [ ! -d $(BUILDDIR) ]; then mkdir -p $(BUILDDIR); fi
$(EXECUTABLE): $(OBJECTS)
$(CC) $(LDFLAGS) $(OBJECTS) -o $@
upx --best $@
$(BUILDDIR)/%.o: %.cpp
$(CC) $(CFLAGS) $< -o $@
clean:
if [ -d $(BUILDDIR) ]; then rm -Rf $(BUILDDIR); fi
distclean: clean
rm -f *~
rm -f $(EXECUTABLE)
This works fine as far as dynamically linking is involved.
Now I tried to find where I can look something up about static linking, and they all say "add the libraries to the end (after the -o) when linking. So I tried, but no avail. Also I read you need to use the flag '-static', but this even generates more errors about missing stuff (like missing 'delete' function and so on?!).
Is there someone who can help me with this problem?
Thanks