我正在尝试使用 wxWidgets 库.wikipedia.org/wiki/MinGW" rel="nofollow noreferrer">MinGW 和 msys 来编译代码。到目前为止一切顺利,但我找不到通过 CMD.exe 向 MSYS 发送命令的方法。
我使用 Sublime Text 来编辑文件,并且它有一个运行 makefile 的选项。我希望我的 makefile 能够打开 MSYS 的实例并向其发送 g++ 命令和参数。
示例:
现在我的 makefile 是:
test.exe : main.cpp
g++ -s main.cpp -o test.exe `wx-config --cxxflags` `wx-config --libs`
当 mingw32-make 去运行 g++ 命令时,它将它发送到 cmd.exe,它不处理反引号和 wx-config jazz。 (但是当从 MSYS 和包含 main.cpp 的目录运行时,该命令确实有效)
我希望能够使用类似...的东西
msys --command g++ -s main.cpp*...etc..*
,因此它将加载 MSYS 环境并运行该命令。这可能吗?
我是一个巨大的 makefile 新手,所以如果有更简单的方法,请告诉我!
I am trying to learn the wxWidgets library, using MinGW and msys to compile the code. So far so good, but I can not find a way to send a command to MSYS through CMD.exe.
I use Sublime Text to edit files, and it has an option to run makefiles. I want my makefiles to be able to open an instance of MSYS and send the g++ command and arguments to it.
Example:
Right now my makefile is:
test.exe : main.cpp
g++ -s main.cpp -o test.exe `wx-config --cxxflags` `wx-config --libs`
When mingw32-make goes to run the g++ command, it sends it to cmd.exe, which doesn't handle the back-ticks and wx-config jazz. (But the command does work when run from inside MSYS and the directory holding main.cpp)
I want to be able to use something like...
msys --command g++ -s main.cpp*...etc..*
So it will load the MSYS enviroment and run the command. Is this possible?
I am a huge makefile newbie, so if there is an easier way, please show me!
发布评论
评论(2)
我从未设法通过 MSYS 使用 wxwidgets,尽管我以这种方式编译了所有其他代码。在 wx 文档中探索了几天未能找到解决方案,无论如何 Qt 可能是一个更好的可移植性选择。
但脾够了。当您运行 msys 时,您实际上正在运行一个启动 rxvt 控制台的批处理文件。你真的不想用这个。相反,只需创建一个桌面快捷方式
(或您的 MSYS 目录所在的任何位置)并单击它。
完成此操作后,如果 MSYS bin 目录位于您的 Windows PATH 上,则看起来像这样的 makefile 将理解反引号:
根据我的经验,它不会执行以下操作:编译 wx.
I've never managed to use wxwidgets via MSYS, though I compile all my other code that way. Several days of spelunking in the wx docs failed to find a solution and Qt is probably a better portability bet anyway.
But enough spleen. When you run msys, you are actually running a batch file that starts up the rxvt console. You really don't want to use this. Instead, just create a desktop shortcut to
(or wherever your MSYS directory is) and click on that.
Once you have done that, a makefile that looks like this will understand backticks, provided the MSYS bin directory is on your Windows PATH:
What it won't do, in my experience is compile wx.
您可能想要 设置gmake 使用 来执行组成 makefile 的命令的 shell。我认为 MSYS 带有 bash 甚至普通的 sh,应该可以完成这项工作。
You probably want to set the shell that gmake uses to execute the commands that make up the makefile. I assume that MSYS comes with bash or even plain sh, which should do the job.