LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-19-2014, 02:29 PM   #1
hellopenguin
LQ Newbie
 
Registered: Oct 2014
Posts: 1

Rep: Reputation: Disabled
How to create makefile for compiling multiple programms


I am newbie , so have some problems with creating makefile. I have tried to compile them from terminal and found right options for gcc to do this. But I have some troubles with creating one makefile to compile to do all this tasks. Here is my commands that work.

Code:
gcc -c pstree.c -DHAVE_CONFIG_H -I.
gcc -o hello pstree.o -L/usr/lib/ -ltinfo

gcc -c fuser.c -DHAVE_CONFIG_H -I.
gcc -c -o libsignals.a signals.c
gcc -o hello fuser.o -L/usr/lib/ -L. -lsignals

gcc -c -o libsignals.a signals.c
gcc -o hello killall.o -L/usr/lib/ -L. -lsignals
gcc -c killall.c -DHAVE_CONFIG_H -I.
Please help with creating makefile for this purpose. Thanks in advance.
 
Old 10-20-2014, 04:25 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,830

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
the syntax of a makefile is something like this (simplified):
Code:
target: dependency
<tab>rule
where target is the file you want to create, the dependency is (are) the source file(s) to be used and the rule will tell how should we produce the target from the sources.
For example:
Code:
pstree.o: pstree.c
<tab>gcc -c pstree.c -DHAVE_CONFIG_H -I.
hello: pstree.o
<tab>gcc -o hello pstree.o -L/usr/lib/ -ltinfo
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
I need help to create a Makefile henrik9 Linux - Software 1 07-18-2009 02:01 AM
any tool that will create Makefile b123coder Programming 4 04-06-2006 10:00 AM
Compiling multiple .c file using single command in makefile vipulc Linux - General 2 03-18-2006 11:49 PM
How to create a Kernel 2.6 Makefile 7.e.Q Programming 1 11-03-2004 07:47 AM
Create my own configure and Makefile Ephracis Linux - Software 1 10-11-2004 08:00 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:16 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration