Solved

How to build c program using make in mingw environment?

Posted on 2016-10-16
9
71 Views
Last Modified: 2016-10-18
I have simple ex1.c that prints a  line on the screen.

I get attached build error.

I create attached makefile but still build error.  make utitlity is not using my makefile.  I specify gcc compiler but it's using some makefile that has cc compiler command.

How do I buld this simple c program with make utility that comes with mingw?
Makefile.txt
build-error.PNG
0
Comment
Question by:naseeam
  • 4
  • 2
  • 2
  • +1
9 Comments
 
LVL 40

Expert Comment

by:evilrix
ID: 41845999
You need to be running the bash shell that comes with Mingw. Execute the commands in that shell.
0
 
LVL 1

Author Comment

by:naseeam
ID: 41846029
I removed .txt extension from the makefile I had created.   Then, it worked from windows command window.

If i use bash shell then I don't need to create my own makefile?

I invoked bash application from MinGW\msys\1.0\bin.  That's how to run bash shell?
0
 
LVL 40

Assisted Solution

by:evilrix
evilrix earned 125 total points
ID: 41846049
Odd, because the error was "cc not found". The error should have been something different if it couldn't fine the make fine.

You would still need a make file to build a project, but not a single file. It's still better to build with a make file.
0
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 
LVL 1

Author Comment

by:naseeam
ID: 41846624
How to invoke bash shell from imingw?
0
 
LVL 33

Assisted Solution

by:sarabande
sarabande earned 125 total points
ID: 41846735
I invoked bash application from MinGW\msys\1.0\bin.  That's how to run bash shell?
yes. what happens if you do so?

if you are a beginner, mingw might not be the easiest way to start with.

you may consider to using an IDE which has Project and MakeFile management included.

at Windows you have some choices:

- Visual Studio 2015 Community
- QT
- Eclipse with C/C++ development package

all these are free (at least for non-commercial development). for the last you would use the compiler that came with mingw.

Sara
0
 
LVL 1

Author Comment

by:naseeam
ID: 41847414
>> yes. what happens if you do so?
bash.exe"--3.1$
0
 
LVL 33

Expert Comment

by:sarabande
ID: 41847819
bash.exe"--3.1$
can you post a picture?

it is some time ago but if i remember rightly of my last mingw installation, they added a menu item into start menu where you could open a bash shell command window.

are you familar with using bash shell? or any other shell?

if not, i would strongly recommend to using an IDE.

Sara
0
 
LVL 32

Accepted Solution

by:
phoffric earned 250 total points
ID: 41848824
>> How to build c program using make in mingw environment?
>> I removed .txt extension from the makefile I had created.   Then, it worked from windows command window.

If I understand you correctly, then you figured out how to build the executable from your Makefile in a Windows cmd window. If this is the case, then congrats on solving your own question.

I see that I installed mingw-64 two years ago, and had no trouble using your Makefile to build the .exe file, and running it from a Windows cmd window that I create when clicking on mingw-w64.bat. Only difference in my cmd was that I used mingw32-make that came with my mingw-64 instead of make. (I guess you installed some extra programs.)

But now, you want to be able to do the same in a bash shell. I never did that in mingw since I generally will use Cygwin or Ubuntu.
0
 
LVL 1

Author Comment

by:naseeam
ID: 41848972
As expert said, problem solved.  I agree.

Bash shell might be topic in future.

Thank you to all experts.
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question