• C

How to build c program using make in mingw environment?

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
LVL 1
naseeamAsked:
Who is Participating?
 
phoffricConnect With a Mentor Commented:
>> 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
 
evilrixSenior Software Engineer (Avast)Commented:
You need to be running the bash shell that comes with Mingw. Execute the commands in that shell.
0
 
naseeamAuthor Commented:
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
What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

 
evilrixConnect With a Mentor Senior Software Engineer (Avast)Commented:
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
 
naseeamAuthor Commented:
How to invoke bash shell from imingw?
0
 
sarabandeConnect With a Mentor Commented:
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
 
naseeamAuthor Commented:
>> yes. what happens if you do so?
bash.exe"--3.1$
0
 
sarabandeCommented:
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
 
naseeamAuthor Commented:
As expert said, problem solved.  I agree.

Bash shell might be topic in future.

Thank you to all experts.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.