I'm trying to use wxWidgets to do a college project and I ended up trying to use the Makefile out of curiosity, below the makefile I'm using as an example for the project.
Makefile
CPP_FILES := $(wildcard src/*.cpp)
OBJ_FILES := $(addprefix obj/,$(notdir $(CPP_FILES:.cpp=.o)))
LD_FLAGS := -lm
CPP_FLAGS := -Wall -Wextra
Crypto: $(OBJ_FILES)
g++ -o $@ $^ $(LD_FLAGS)
obj/%.o: src/%.cpp src/%.h
g++ $(CPP_FLAGS) -c -o $@ $<
clean:
rm -f $(OBJ_FILES) *.o
I tried to adapt it to use the flags and libs of wxWidgets but when I run the makefile it gives me some linker errors ...
Makefile wxWidgets
CPP_FILES := $(wildcard src/*.cpp)
OBJ_FILES := $(addprefix obj/,$(notdir $(CPP_FILES:.cpp=.o)))
# wx-config --libs
WX_LIBS = $(shell wx-config --libs)
# wx-config --cxxflags
WX_CXXFLAGS = $(shell wx-config --cxxflags)
LD_FLAGS := -lm
CPP_FLAGS := -Wall -Wextra
Crypto: $(OBJ_FILES)
g++ -o $@ $^ $(LD_FLAGS)
obj/%.o: src/%.cpp src/%.h
g++ $(CPP_FLAGS) $(WX_CXXFLAGS) $(WX_LIBS) -o $@ $<
clean:
rm -f $(OBJ_FILES) *.o
One of the linker errors that is generated
mainWindow.cpp:(.text._ZN20wxEventFunctorMethodI14wxEventTypeTagI14wxCommandEventE12wxEvtHandler7wxEventS3_EclEPS3_RS4_[_ZN20wxEventFunctorMethodI14wxEventTypeTagI14wxCommandEventE12wxEvtHandler7wxEventS3_EclEPS3_RS4_]+0x8c): undefined reference to 'wxTrap()'
collect2: error: ld returned 1 exit status
What can I modify in this makefile? I'm still studying how the makefile works and I'm trying to apply it using wxWidgets