This question has already been asked: Magick++ not linking in OS X 10.8 without a resolution.
This is also a follow-on from two previous questions I've asked in an attempt to get a c++ image-stitching algorithm to work properly (the second question was unnecessary, I should have found the issue, but, for clarity). Using MTL/Boost Library Mac Terminal C++ :: "no such instruction" error when using gcc-4.9 on osx-yosemite
My issue is that I cannot properly link imagemagick to my gcc-4.9 compile, as follows:
$ make
Linking ...
Undefined symbols for architecture x86_64:
"Magick::Image::write(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)", referenced from:
FileRender::finish() in main.o
"Magick::Image::Image(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)", referenced from:
planet(char const*) in main.o
work(int, char**) in main.o
test_transform(char const*, char const*) in main.o
test_warp(int, char**) in main.o
gallery(char const*, char const*) in main.o
test_extrema(char const*) in main.o
test_feature(char const*, int) in main.o
...
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
make: *** [image-stitching] Error 1
I've tried what is suggested on the magick page, what is listed here Undefined symbols for architecture x86_64, and quite a bit of others. But, alas, no luck.
As requested, the makefile (from the original project on my first link, with current edits).
# $File: Makefile
# $Date: Wed Jun 17 20:52:38 2015 +0800
OBJ_DIR = obj
TARGET = image-stitching
INCLUDE_DIR = -Iinclude -I/usr/local/include
DEFINES = -DDEBUG
OPTFLAGS = -O3 -Wall -Wextra
LIBS =
#INCLUDE_DIR += $(shell pkg-config --cflags $(LIBS))
CXXFLAGS = $(INCLUDE_DIR) -fopenmp
CXXFLAGS += $(DEFINES) -std=c++11 $(OPTFLAGS)
CXXFLAGS += $(shell Magick++-config --cxxflags)
LDFLAGS = -fopenmp $(OPTFLAGS)
#LDFLAGS += $(shell pkg-config $(LIBS) --libs)
LDFLAGS += $(shell Magick++-config --ldflags --libs)
LDFLAGS += -L/usr/local/Cellar/libpng/1.6.18/lib
#LDFLAGS += -lImageMagick
CC = g++-4.9
SHELL = bash
ccSOURCES = $(shell find -name "*.cc" | sed 's/^\.\///g')
OBJS = $(addprefix $(OBJ_DIR)/,$(ccSOURCES:.cc=.o))
DEPFILES = $(OBJS:.o=.d)
.PHONY: all clean run
all: $(TARGET)
ifneq ($(MAKECMDGOALS), clean)
sinclude $(DEPFILES)
endif
$(OBJ_DIR)/%.o: %.cc
@echo "[cc] $< ..."
@$(CC) -c $< -o $@ $(CXXFLAGS)
$(OBJ_DIR)/%.d: %.cc Makefile
@mkdir -p $(dir $@)
@echo "[dep] $< ..."
@$(CC) $(CXXFLAGS) $(DEFINES) -MM -MT "$(OBJ_DIR)/$(<:.cc=.o) $(OBJ_DIR)/$(<:.cc=.d)" "$<" > "$@"
$(TARGET): $(OBJS)
@echo "Linking ..."
@$(CC) $(OBJS) -o $@ $(LDFLAGS)
@echo "done."
clean:
@rm -rvf $(OBJ_DIR)
run: $(TARGET)
./$(TARGET) lenna.png lenna_r.png