memoryStream
memoryStream

Reputation: 27

Makefile: linking library

I'm trying to build a c++ Wt program. However, my makefile does not work.

I have the following:

CXX=g++
LDFLAGS=-lwt -lwthttp
CXXFLAGS=-Wall
SOURCES=main.cpp test.cpp
OBJ=$(SOURCES:.cpp=.o)
EXE=test

all: $(SOURCES) $(EXE)
     $(EXE): $(OBJ)
     $(CXX) $(LDFLAGS) $(OBJ) -o $@

.cpp.o:
     $(CXX) $(CXXFLAGS) $< -o $@

But this gives me the error that it is missing references to the Wt classes during compile-time.

Upvotes: 0

Views: 722

Answers (1)

Some programmer dude
Some programmer dude

Reputation: 409136

The GNU linker resolves dependencies in a specific order, which means you have to put libraries last when linking, So change

$(CXX) $(LDFLAGS) $(OBJ) -o $@

to

$(CXX) $(OBJ) $(LDFLAGS) -o $@

Upvotes: 2

Related Questions