Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
519 views
in Technique[技术] by (71.8m points)

c++ - Executing MSYS from cmd.exe with arguments

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!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

C:msysinash.exe

(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:

foobar:
    echo `ls`

What it won't do, in my experience is compile wx.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...