3

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 Answers 2

4

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:\msys\bin\bash.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.

Sign up to request clarification or add additional context in comments.

Comments

2

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.

2 Comments

If I set bash.exe as my shell, then go back to my text editor and run make, i get: "/bin/bash: /A: No such file or directory" I also had to change the wx-config lines to read /c/wxWidgets2.8.10/wx-config --- so with that change I can load bash.exe, manually navigate to the directory, execute mingw32-make and everything is fine. I think for some reason when executed via text editor it is not getting the correct working directory.
sorry for reading between the lines! My mistake setting the actual shell instead of the MAKESHELL varible. Thanks! All is working.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.