Link to home
Start Free TrialLog in
Avatar of VWrestle97
VWrestle97

asked on

GNU Makefile - What needs to be done to go from Linux to make it run on Windows?

I have a GNU Makefile that already exists for a Linux C program.  What types of things need to be done to make the Makefile work on a Windows machine?
Avatar of yjwong
yjwong

If your program is portable to Cygwin, then it will work seamlessly. Try compiling your program using the standard Make utilities in the Cygwin suite.
Avatar of VWrestle97

ASKER

I don't think this is an option for me as posted in a recent question titled, "Using Windows Command Prompt, How to run a series of Cygwin statements immediately after Cygwin Starts"  where I stated, "I have Cygwin installed on my Windows XP.  I would like -  from windows command prompt -  to be able to open up Cygwin immediatley followed by a series of commands.  What is the best way to approach this?  Please provide example syntax."

An answer provided to this question was, "The only other way to pass on another command from the same batch file is to add a syntax to BASH.EXE; however I could not find anything for running another batch file. The only syntaxes are for logging in and setting the home directory. I don't think what you are asking is possible to do from one batch file."

Does this sound correct to you?  If that is true, then I can't use Cygwin because I am trying to get Matlab to run a series of Linux commands, so I believe the only solution that I have is to create a windows .bat version for the C program.  Do you agree with this?
I'm not sure if that's what you wanted, but here's just a possible solution. You could actually directly run the Cygwin executables (i.e. make) without starting BASH by adding the Cygwin bin directory into your %PATH% environment variable. That way, you are able to run the make utilities directly through the Windows command prompt, or through the batch file.
Ah... this wasn't exactly my question, and I was able to do this but not the way you describe.  I don't have the example on me right now, but I will post it here when I get access to it so you can see how I did it.  I am not sure of the way you explain it, but can you explain in more detail about how to do it your way?

Getting back to my original question; I don't want to use Cygwin.  Basically I want to know the differences between the linux and windows makefile and what type of changes need to be made to make it compatible with windows.  Sorry for the confusion.

What I did was just setting the PATH variable in the batch file to include the Cygwin's bin directory. For example, if your Cygwin bin directory is in C:\Cygwin\bin, then the batch file would look something like:

set PATH=%PATH%;C\Cygwin\bin
cd source_directory
make <some target>

If you are going to use the Windows makefile syntax, then I can't really help. I don't really know the differences between nmake and make. Sorry if I can't help.
I'm sorry, the I used Matlab to setup my path - path('C:\blah\blah',path);  

so nmake is the windows version of linux's make?
I ended up using Cygwin after-all because I found a command for windows batch file that can be used to send a series of commands to Cygwin with just requiring one instance of Cygwin open.  

The command I used in batch to access Cygwin is:

bash --login -c "command_1; command_2; ... command_N; exit; exec bash -rcfile exit"

I was misinformed from another thread that what I wanted to do cannot be accomplished with Cygwin, but when I figured it out I decided to use Cygwin instead of making my own version of windows makefile from a Linux makefile.
ASKER CERTIFIED SOLUTION
Avatar of VWrestle97
VWrestle97

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Closed, 500 points refunded.
Vee_Mod
Community Support Moderator