7

My makefile:

SHELL := /bin/bash

.PHONY: all
all:
    pip install runcython
    makecython++ stitch_wrapper.pyx "" "stitch_rects.cpp ./hungarian/hungarian.cpp"

hungarian: hungarian/hungarian.so

hungarian/hungarian.so:
    cd hungarian && \
    TF_INC=$$(python -c 'import tensorflow as tf; print(tf.sysconfig.get_include())') && \
    if [ `uname` == Darwin ];\
    then g++ -std=c++11 -shared hungarian.cc -o hungarian.so -fPIC -I $$TF_INC -undefined dynamic_lookup;\
    else g++ -std=c++11 -shared hungarian.cc -o hungarian.so -fPIC -I  $$TF_INC; fi

I have already installed

-cython
-runcython
-python-dev
-python3-dev
-cffi

Unfortunately I continue to get the error:

pkg-config: command not found
.cpp:4:20: fatal error: Python.h: No such file or directory
compilation terminated.
Makefile:5: recipe for target 'all' failed
make: *** [all] Error 1
AndreaF
  • 11,975
  • 27
  • 102
  • 168
  • See http://stackoverflow.com/a/21530866/4657412. You need to specify the path in the make file. I believe Python.h is not automatically on the include path to help multiple versions not conflict – DavidW Mar 27 '17 at 06:43
  • @Dawon I have added flag `-I/usr/include/python3.5 -lpython3.5` after `makecython++`command line with no success and get the error `makecython++ requires a *.pyx file. ` seems that flag syntax isn't correct for makecython++ – AndreaF Mar 27 '17 at 09:17
  • I'm not really familiar with `makecython++` so I'm guessing a bit, but I think you want to send those flags to g++ rather than `makecython++` – DavidW Mar 27 '17 at 09:21
  • @DavidW in my case I have to use makecython++ not gcc. How I should add \-I/usr/include/python3.5\ to path? – AndreaF Mar 27 '17 at 09:26
  • Sorry - don't know. Looking at the source https://github.com/Russell91/runcython/blob/master/makecython%2B%2B it looks like it tries to do this (the `pkg-config` part) but I wonder if it does it for Python2 rather than Python3. I have no really idea how to fix it though. – DavidW Mar 27 '17 at 09:44

1 Answers1

10

If you already have

sudo apt-get install python-dev
sudo apt-get install python3-dev
sudo apt-get install libpython3-dev
sudo apt-get install libpython3.4-dev
sudo apt-get install libpython3.5-dev

the problem may be related to missing of one of these packages:

sudo apt-get install Cython
sudo apt-get install pkgconf
sudo apt-get install libpkgconf
sudo apt-get install python-pkgconfig
sudo apt-get install python3-pkgconfig
Silverstorm
  • 15,398
  • 2
  • 38
  • 52