简体   繁体   English

如何在 distutils 中正确包含目录

[英]How to properly include the directory in distutils

I have a pretty basic question regarding building Python extensions with C++.关于使用 C++ 构建 Python 扩展,我有一个非常基本的问题。 In one of my header files, I have a line #include "veins_python/veins_python.h" , which is a relative path that Python does not see.在我的 header 文件之一中,我有一行#include "veins_python/veins_python.h" ,这是 Python 看不到的相对路径。 When I run python setup.py build , I get当我运行python setup.py build时,我得到

In file included from MyVeinsAppRoss.cc:24:
MyVeinsAppRoss.h:25:10: fatal error: veins_python/veins_python.h: No such file or directory
   25 | #include "veins_python/veins_python.h"
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.

I have tried to give an give an absolute path to veins_python.h in my setup.py file我试图在我的setup.py文件中给出一个到veins_python.h的绝对路径

module1 = Extension('MyTest',
                    include_dirs = ["~/veins_python_practice/src/veins_python"],
                    sources = ['MyVeinsAppRoss.cc']
                    )

and also the path just before the veins_python directory以及veins_python目录之前的路径

module1 = Extension('MyTest',
                    include_dirs = ["~/veins_python_practice/src"],
                    sources = ['MyVeinsAppRoss.cc']
                    )

But the error does not change.但错误并没有改变。 Could somebody help?有人可以帮忙吗?

The issue is that it is that you have to type the home directory as /home/username , ie ~ will not work.问题是您必须将主目录键入为/home/username ,即~不起作用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM