Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to build c program using make in mingw environment?

Posted on 2016-10-16
9
Medium Priority
?
133 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 500 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 1

Author Comment

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

Assisted Solution

by:sarabande
sarabande earned 500 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 35

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 1000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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…
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 how to use strings and some functions related to them 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.
Suggested Courses

877 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