Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compilation error for module.so under Ubuntu 17.10 #7

Open
markrofail opened this issue Apr 23, 2018 · 0 comments
Open

compilation error for module.so under Ubuntu 17.10 #7

markrofail opened this issue Apr 23, 2018 · 0 comments

Comments

@markrofail
Copy link

Got the following two error from setup.py:

- kitti/bp/module.cpp:580:10: fatal error: numpy/arrayobject.h: No such file or directory
 #include "numpy/arrayobject.h"
- kitti/bp/module.cpp:586:10: fatal error: opencv2/opencv.hpp: No such file or directory
 #include "opencv2/opencv.hpp"

solved by:

  • installing opencv libraries
sudo apt install libopencv-dev
  • installing numpy
pip install numpy

and the following changes to setup.py

diff --git a/setup.py b/setup.py
index 83c228c..cde6e6d 100644
--- a/setup.py
+++ b/setup.py
@@ -2,16 +2,22 @@ from setuptools import setup
 
 from distutils.extension import Extension
 from Cython.Distutils import build_ext
+import numpy
+import subprocess
+ 
+proc_libs = subprocess.check_output("pkg-config --libs opencv".split())
+proc_incs = subprocess.check_output("pkg-config --cflags opencv".split())
+libs = [lib for lib in str(proc_libs, "utf-8").split()]
 
 ext_modules = []
 ext_modules.append(Extension(
     "kitti.bp.module",
     ["kitti/bp/module.pyx", "kitti/bp/interp.cpp", "kitti/bp/stereo.cpp", "kitti/bp/bp.cpp"],
-    include_dirs=["kitti/bp", "/opt/opencv/include"],
+    include_dirs=[numpy.get_include(), "kitti/bp", "/opt/opencv/include"],
     library_dirs=["/opt/opencv/lib"],
     libraries=["opencv_core", "opencv_imgproc"],
     language="c++",
-    extra_compile_args=["-w", "-O3"]))
+    extra_compile_args=["-w", "-O3"].append(libs)))
 
 setup(
     name="kitti",

Just wanted to share the fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant