Skip to content

Instantly share code, notes, and snippets.

@mike-lawrence
Created July 4, 2014 17:54
Show Gist options
  • Save mike-lawrence/b1da52cdba1521014cc3 to your computer and use it in GitHub Desktop.
Save mike-lawrence/b1da52cdba1521014cc3 to your computer and use it in GitHub Desktop.
opencv-ndarray-conversion-Makefile
PYTHON_VERSION = 2.7
PYTHON_INCLUDE = /usr/local/Cellar/python/2.7.8/Frameworks/Python.framework/Versions/Current/include/python2.7
NUMPY_INC = /usr/local/lib/python2.7/site-packages/numpy/core/include
BOOST_INC = /usr/local/Cellar/boost/1.55.0_2/include
BOOST_LIB = /usr/local/Cellar/boost/1.55.0_2/lib
OPENCV_LIB = /usr/local/Cellar/opencv/2.4.9/lib/
OPENCV_INC = /usr/local/Cellar/opencv/2.4.9/include/
TARGET = matrmul
$(TARGET).so: $(TARGET).o conversion.o
g++ -shared -Wl, \
$(TARGET).o conversion.o -L$(BOOST_LIB) -lboost_python -lboost_numpy \
$(OPENCV_LIB) \
-L/usr/lib/python$(PYTHON_VERSION)/config -lpython$(PYTHON_VERSION) \
-o $(TARGET).so
$(TARGET).o: $(TARGET).cpp
g++ -std=c++11 -I$(PYTHON_INCLUDE) -I$(NUMPY_INC) -I$(OPENCV_INC) -I$(BOOST_INC) -fPIC -c \
$(TARGET).cpp
conversion.o: conversion.cpp conversion.h
g++ -std=c++11 -I$(PYTHON_INCLUDE) -I$(NUMPY_INC) -I$(OPENCV_INC) -I$(BOOST_INC) -fPIC -c \
conversion.cpp
clean:
rm -f $(TARGET).so $(TARGET).o conversion.o
test:
python -m test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment