Generate a binary file using make


 
Thread Tools Search this Thread
Top Forums Programming Generate a binary file using make
# 1  
Old 01-13-2010
Generate a binary file using make

Hi,
i am trying to create a makefile for my C++ program. when i say "make" it should generate the binary file. and when i say make clean, it should delete all the bins and libs.
can u please help me out.
# 2  
Old 01-13-2010
We'll need more information than that to do EVERYTHING you want. Here's a fairly generic makefile:

Code:
# Compiler flags, i.e. optimization and include paths
CFLAGS=-O2 -pipe
# C++ compiler flags, including CFLAGS
CXXFLAGS=$(CFLAGS)
# Linker flags, i.e. libraries and lib paths
LDFLAGS=-lm
# All object files
OBJECTS=a.o b.o c.o d.o
# All output target files
TARGETS=ab cd

# The first target should cause all targets to be built
all:$(TARGETS)

# Link ab from a.o and b.o
ab:a.o b.o
        $(CXX) a.o b.o $(LDFLAGS) -o $@

# Link cd from c.o and d.o
cd:c.o d.o
        $(CXX) c.o d.o $(LDFLAGS) -o $@

# Delete all targets and objects
clean:
        rm -f $(TARGETS) $(OBJS)

Wherever I've put eight leading spaces, they're actually tabs and must be tabs for the makefile to work right.
# 3  
Old 01-13-2010
i need to generate a .bin file for my program. how can i do that using makefile ??
# 4  
Old 01-13-2010
Hi.

As Corona688 said, the makefile is a generic one, to get you started.

If the TARGET is to generate a .bin file, then perhaps you should modify the makefile to suit your requirements?
# 5  
Old 01-13-2010
yeah... i am new to creating a makefile... so i dont know what to write in the makefile to create a .bin file. Can anyone please tell me what command to use...
thanks in advance.
# 6  
Old 01-14-2010
Depends on what a .bin file is and what commands are used to create it! I've given you a totally generic makefile to fill in the blanks with; if your build procedure is more complicated or completely different than what I've shown, we're going to need to know what it actually is before we can show how to do it in make.

Last edited by Corona688; 01-14-2010 at 11:50 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How can i make my cron/script to generate a log filename with timestamp in it ?

Hello Friends, I would like my script to display date timestamps in the file name for every script execution. Below is the scenario: (just for testing purpose) I scheduled a cron job, lets say it runs every 5 min and record/logs output in to a log file. 0,5,10,15,20,25,30,35,40,45,50,55 *... (5 Replies)
Discussion started by: System Admin 77
5 Replies

2. Shell Programming and Scripting

Convert binary file to csv and then back to the binary format

Hello *nix specialists, Im working for a non profit organisation in Germany to transport DSL over WLAN to people in areas without no DSL. We are using Linksys WRT 54 router with DD-WRT firmware There are at the moment over 180 router running but we have to change some settings next time. So my... (7 Replies)
Discussion started by: digidax
7 Replies

3. Shell Programming and Scripting

Needed script to FTP a File and generate a quality checksum file

hi all i want a script to FTP a file and should generate a quality checksum file means when I FTP a file from one server to another server it should generate a QC file which should contain timestamp,no.of records in that file Thanks in advance saikumar (3 Replies)
Discussion started by: hemanthsaikumar
3 Replies

4. Programming

Make cannot generate .ko linux kernel module

cannot generate .ko file on my linux, although it can generate module.symvers. But when I copy .c file and Makefile to another linux computer, there's no problem. The strange thing is: make is successfuly executed, and returned 0; make output: make -C /lib/modules/2.6.18-92.el5xen/build ... (4 Replies)
Discussion started by: vistastar
4 Replies

5. Shell Programming and Scripting

KSH - help needed for creating a script to generate xml file from text file

Dear Members, I have a table in Oracle DB and one of its column name is INFO which has data in text format which we need to fetch in a script and create an xml file of a new table from the input. The contents of a single cell of INFO column is like: Area:app - aam Clean Up Criteria:... (0 Replies)
Discussion started by: Yoodit
0 Replies

6. Emergency UNIX and Linux Support

Generate Info From a Unix Binary

We have a situation where a binary from our build system is failing in one specific flow but the same from dev works fine. We are sure that build system picks up the right libs and code, however we see a difference of 6000 bytes in both. (build - 6000 bytes = size of dev binary) Hence we would... (7 Replies)
Discussion started by: uunniixx
7 Replies

7. Programming

makeutility: how to get the make-file name inside of the make-file?

How I can get the current make-file name in a make-file So, if I run make with specified file:make -f target.mak is it possible to have the 'target' inside of the that 'target.mak' from the file name? (2 Replies)
Discussion started by: alex_5161
2 Replies

8. Shell Programming and Scripting

need help in Parsing a CSV file and generate a new output file

Hi Scripting Gurus, I am trying to parse a csv file and generate a new output file. The input file will be a variable length in turns of rows and columns. output file will have 8 columns. we have three columns from the header for each set. just to give little bit more clarification each row... (15 Replies)
Discussion started by: vkr
15 Replies

9. UNIX for Dummies Questions & Answers

Script to generate text file from excel file

Hello, I have a excel file which has almost ten columns on the shared drive. I have to write a shell script to ftp that daily to unix server and then extract some columns from there and generate oracle standard text file. The columns should be in proper order and aligned properly, otherwise... (1 Reply)
Discussion started by: isingh786
1 Replies

10. Solaris

compiled binary file gives "cannot execute binary file"

Hi, I have two Solaris machines. 1. SunOS X 5.8 Generic_108528-29 sun4u sparc SUNW,Sun-Blade-1500 2. SunOS Y 5.8 Generic_108528-13 sun4u sparc SUNW,Ultra-60 I am trying to buiild a project on both these machines. The Binary output file compiled on machine 2 runs on both the machines. Where... (0 Replies)
Discussion started by: scgupta
0 Replies
Login or Register to Ask a Question