Sponsored Content
Full Discussion: C++ application development
Top Forums Programming C++ application development Post 302701525 by Corona688 on Sunday 16th of September 2012 01:30:49 PM
Old 09-16-2012
The larger the project, the more work must be done when you end up ripping out all the IDE garbage to re-import into a newer or different IDE.

It doesn't help as much as you think, either, if you learn what you're doing first, which I think you should do at the very least! If you've never compiled anything yourself, never used a makefile, most of the options in an IDE will never make sense. It's not like makefiles are hard. Put all these files in the same folder and run make:

Code:
// libraryfunction.c

double square(double value)
{
        return(value*value);
}

Code:
// libraryfunction.h

#ifndef __LIBRARYFUNCTION_H__
#define __LIBRARYFUNCTION_H__

extern double square(double);

#endif/*__LIBRARYFUNCTION_H__*/

Code:
//main.c
#include "libraryfunction.h"
#include <math.h>
#include <stdio.h>

int main(void)
{
        printf("%f\n", square(sin(0.5)));
        return(0);
}

Code:
# Makefile

# Built-in variable for linker, defines libraries.
LDFLAGS=-lm
# Built in variable for CC, defines compile flags
# For C++ the simlar variable CXXFLAGS is used.
CFLAGS=-ggdb

# Note the eight spaces in front is actually a tab and MUST BE a tab
myapp:main.o library.o
        $(CC) $(LDFLAGS) $^ -o $@

...and that's a complete makefile. It knows how to convert .c and .cpp files into .o files by itself, so you just make a rule which builds your application out of .o files.

Whenever your .c files are newer than your .o files it rebuilds the .o files. Whenever your .o files are newer than myapp, it rebuilds myapp.

$@ is a special variable for 'output file'. It becomes myapp.
$^ is a special variable for 'input files'. It becomes main.o library.o.

Last edited by Corona688; 09-16-2012 at 02:38 PM..
This User Gave Thanks to Corona688 For This Post:
 

We Also Found This Discussion For You

1. Shell Programming and Scripting

Difference between development and Production unix servers for a application??

Hi all I am running a major script of my application in development for implementing code changes for process improvement in time. The script runs in production once in a month . It takes 8 hours 30 mins in Production server . what surprice me is , when I run the same script in development server... (9 Replies)
Discussion started by: sakthifire
9 Replies
gccmakedep(1)						      General Commands Manual						     gccmakedep(1)

NAME
gccmakedep - create dependencies in makefiles using 'gcc -M' SYNOPSIS
gccmakedep [ -sseparator ] [ -fmakefile ] [ -a ] [ -- options -- ] sourcefile ... DESCRIPTION
The gccmakedep program calls 'gcc -M' to output makefile rules describing the dependencies of each sourcefile, so that make(1) knows which object files must be recompiled when a dependency has changed. By default, gccmakedep places its output in the file named makefile if it exists, otherwise Makefile. An alternate makefile may be speci- fied with the -f option. It first searches the makefile for a line beginning with # DO NOT DELETE or one provided with the -s option, as a delimiter for the dependency output. If it finds it, it will delete everything following this up to the end of the makefile and put the output after this line. If it doesn't find it, the program will append the string to the makefile and place the output after that. EXAMPLE
Normally, gccmakedep will be used in a makefile target so that typing 'make depend' will bring the dependencies up to date for the make- file. For example, SRCS = file1.c file2.c ... CFLAGS = -O -DHACK -I../foobar -xyz depend: gccmakedep -- $(CFLAGS) -- $(SRCS) OPTIONS
The program will ignore any option that it does not understand, so you may use the same arguments that you would for gcc(1), including -D and -U options to define and undefine symbols and -I to set the include path. -a Append the dependencies to the file instead of replacing existing dependencies. -fmakefile Filename. This allows you to specify an alternate makefile in which gccmakedep can place its output. Specifying "-" as the file name (that is, -f-) sends the output to standard output instead of modifying an existing file. -sstring Starting string delimiter. This option permits you to specify a different string for gccmakedep to look for in the makefile. The default is "# DO NOT DELETE". -- options -- If gccmakedep encounters a double hyphen (--) in the argument list, then any unrecognized arguments following it will be silently ignored. A second double hyphen terminates this special treatment. In this way, gccmakedep can be made to safely ignore esoteric compiler arguments that might normally be found in a CFLAGS make macro (see the EXAMPLE section above). -D, -I, and -U options appearing between the pair of double hyphens are still processed normally. SEE ALSO
gcc(1), make(1), makedepend(1). AUTHOR
The version of the gccmakedep included in this X.Org Foundation release was originally written by the XFree86 Project based on code sup- plied by Hongjiu Lu. Colin Watson wrote this manual page, originally for the Debian Project, based partly on the manual page for makedepend(1). X Version 11 gccmakedep 1.0.2 gccmakedep(1)
All times are GMT -4. The time now is 01:32 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy