如何为C ++程序从MSYS Makefile定义路径? [英] How do I define a path from an MSYS Makefile for a C++ program?

查看:105
本文介绍了如何为C ++程序从MSYS Makefile定义路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题:在我同时在MSYS和MSYS2环境中使用的Makefile中,我知道一个路径PYTHON_ROOT_DIR,该路径将在C ++程序的编译时使用.问题是PYTHON_ROOT_DIR在称为posix样式路径的Makefile中,例如/mingw64/bin,在C ++程序中,其格式应为"C:\\prog64\\msys64\\mingw64\\bin".另一个挑战是,取决于配置变量PYTHONMAJOR,路径应为宽字符或普通字符.

My problem: in a Makefile which I use in both the MSYS and the MSYS2 environment I know a path, PYTHON_ROOT_DIR, which shall be used at compilation time in a C++ program. Problem is PYTHON_ROOT_DIR is in the Makefile known as posix style path such as /mingw64/bin, where in the C++ program it shall have a form like "C:\\prog64\\msys64\\mingw64\\bin". Additional challenge is that depending on a configuration variable PYTHONMAJOR the path shall be wide characters or normal characters.

我的问题:我如何在Makefile中解决此问题,而无需在msys或msys2环境中安装其他程序/脚本?

My question: how do I solve this in the Makefile without a need to install additional programs/scripts in the msys or msys2 environments?

推荐答案

部分问题在

Part of the question is addressed in msys path conversion (or cygpath for msys?), namely how to convert a msys style path to a windows style path. My full solution in the Makefile is:

ifeq ($(PYTHONMAJOR),3)
    L=L
endif
DEFINES += -DPYTHON_ROOT_DIR=$(L)'"'$(shell (cmd //c echo $(PYTHON_ROOT_DIR)) | sed 's|/|\\\\\\\\|g')'"'

定义具有正确路径的预处理器符号PYTHON_ROOT_DIR.

which defines the preprocessor symbol PYTHON_ROOT_DIR with the proper path.

这篇关于如何为C ++程序从MSYS Makefile定义路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆