Solved

How to build c program using make in mingw environment?

Posted on 2016-10-16
9
100 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 1

Author Comment

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

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 34

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.
Suggested Courses

626 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