在makefile中指定路径(在Windows上为GNU make) [英] Specifying path in makefile (GNU make on Windows)

查看:669
本文介绍了在makefile中指定路径(在Windows上为GNU make)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用GNU make使用Microsoft Visual C ++构建项目,我希望能够从任何CMD窗口中运行它,而不必打开路径(以及其他各种环境变量)中预先配置的窗口)由批处理文件预先配置.理想情况下,我想在makefile本身中定义相关的环境变量,所以我要做的就是弹出一个CMD窗口并键入"make".

总的来说,这很简单,但是我在PATH上苦苦挣扎;到目前为止,我尝试采用标准PATH变量(在操作系统中定义)并将路径附加到各种构建工具的每种语法都失败了.

我没有尝试使用六种或七种不同的语法-有些语法给出了错误消息,有些语法没有给出错误消息,但是却没有用-我会简单地问这个问题:

  • 我必须在我的makefile中插入哪一行,以便将link.exe的路径(即"C:\ Program Files(x86)\ Microsoft Visual Studio 9.0 \ VC \ bin")添加到使用的路径中通过制造"?

到目前为止,我最接近成功的定义是:

LINK ="C:\ Program Files(x86)\ Microsoft Visual Studio 9.0 \ VC \ bin \ link.exe"

...并用$(LINK)替换所有对"link.exe"的后续引用,但这失败了,因为link.exe具有各种依赖项(例如mspdb80.dll),这些依赖项也必须位于路径上. /p>

解决方案

这有效:

DevEnvDir=C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE
VCINSTALLDIR=C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin

export Path:=$(DevEnvDir);$(VCINSTALLDIR);$(Path)

以前使我无法胜任的是出口"和区分大小写的需求.

I'm using GNU make to build a project using Microsoft Visual C++, and I'd like to be able to run it from any CMD window rather than having to open the preconfigured one where the path (and various other environment variables) are preconfigured by a batch file. Ideally I'd like to define the relevant environment variables in the makefile itself, so all I need to do is pop open a CMD window and type "make".

By and large this is straightforward, but I'm struggling with PATH; so far every syntax I've tried for taking the standard PATH variable (as defined in the operating system) and appending the paths to the various build tools has failed.

Rather than go through the six or seven different syntaxes I have tried - some of which gave error messages, some of which didn't give error messages but just didn't work - I'll ask the question plainly:

  • What line to I have to put in my makefile so that the path to link.exe, namely "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin", will be added to the path used by "make"?

So far the nearest I've come to success has been to define:

LINK = "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin\link.exe"

...and replace all subsequent references to "link.exe" by $(LINK), but this fails because link.exe has various dependencies (such as mspdb80.dll) that also have to be on the path.

解决方案

This works:

DevEnvDir=C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE
VCINSTALLDIR=C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin

export Path:=$(DevEnvDir);$(VCINSTALLDIR);$(Path)

It was the need for "export" and for case-sensitivity that had defeated me before.

这篇关于在makefile中指定路径(在Windows上为GNU make)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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