Solved

How to build c program using make in mingw environment?

Posted on 2016-10-16
9
42 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
 

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
 

Author Comment

by:naseeam
ID: 41846624
How to invoke bash shell from imingw?
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 32

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
 

Author Comment

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

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
 

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.

706 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now