Shortly before I asked this question : g++ undefined reference to library symbols
It seems I misused predefined variables of make, namely LINK.cpp. The error was that I linked the library before the objects instead of afterwards.
Now this raised the question what those variables, particularly the LINK.cpp one, are good for because they expand like this :
LINK.cpp = $(LINK.cc)
LINK.cc = $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH)
^
I usually store my libs in LDFLAGS variable, which I thought was common, so LINK.cc will always link the libs before , because I can add my object files only after, and will cause errors like in the posted question.
Where do I have to put my objects then to use the LINK.cpp variable properly? Candidates are :
- CXXFLAGS
- CPPFLAGS
,which both seem not to be right. Have I gotten the use case of the variable wrong ?
To be clear : The question does not aim at the errors a linker can throw at you, but the usage of the variables in make.