Reputation: 233
I am trying to use DUMA (http://duma.sourceforge.net/) but cannot seem to properly link it into my code. Here is my makefile:
CXX := /home/projects/gcc/482/bin/c++
CXXFLAGS := -std=c++11 -pedantic -Wall -I/home/duma_2_5_15/
LDFLAGS := -L/home/duma_2_5_15/ -lduma
#CXX_DEPEND := -MMD -MF .d.$(subst .cc,,$*) -MP -MT $@
CXX_DEPEND :=
define compile-c++-and-emit-deps
$(CXX) $(CXXFLAGS) $(CXX_DEPEND) -c $< -o $@
endef
%.o : %.cc
$(compile-c++-and-emit-deps)
srcs := $(wildcard *.cc)
objs := $(srcs:.cc=.o)
deps := $srcs:%.cc=.d.%)
default: test
test: $(objs)
$(CXX) $(LDFLAGS) -o $@ $(objs)
#-include $(deps)
when I run "make", I receive the following errors:
> make
/home/projects/gcc/482/bin/c++ -L/home/duma_2_5_15/ -lduma -o test main.o
main.o: In function `main':
main.cc:(.text+0x193c): undefined reference to `_duma_malloc'
main.cc:(.text+0x19f8): undefined reference to `_duma_free'
collect2: error: ld returned 1 exit status
make: *** [test] Error 1
Am I not linking duma properly? My main.cc file does include the following header:
#include "duma.h"
I did read the following note on the DUMA homepage:
Some systems will require special arguments to the linker to assure that you are using the DUMA malloc() and not the one from your C library.
However I'm not sure how to proceed from here. This is running on Linux 2.6.18-308.el5.
Thanks
Upvotes: 0
Views: 679
Reputation: 233
Here is the solution to my own question. Note the "-lduma" addition on the second to last line of code at the bottom. This was all I had to add to make it link properly.
CXX := /home/projects/gcc/482/bin/c++
CXXFLAGS := -std=c++11 -pedantic -Wall -I/home/duma_2_5_15/
LDFLAGS := -L/home/duma_2_5_15/ -lduma
#CXX_DEPEND := -MMD -MF .d.$(subst .cc,,$*) -MP -MT $@
CXX_DEPEND :=
define compile-c++-and-emit-deps
$(CXX) $(CXXFLAGS) $(CXX_DEPEND) -c $< -o $@
endef
%.o : %.cc
$(compile-c++-and-emit-deps)
srcs := $(wildcard *.cc)
objs := $(srcs:.cc=.o)
deps := $srcs:%.cc=.d.%)
default: test
test: $(objs)
$(CXX) $(LDFLAGS) -o $@ $(objs) -lduma
#-include $(deps)
Upvotes: 1