Linux Archive

Linux Archive (http://www.linux-archive.org/)
-   Debian User (http://www.linux-archive.org/debian-user/)
-   -   how to configure gcc (http://www.linux-archive.org/debian-user/433447-how-configure-gcc.html)

Mark Allums 09-29-2010 06:40 PM

how to configure gcc
 
On 9/29/2010 12:46 PM, abdelkader belahcene wrote:

hi,
by default I have to add option -lm to the command gcc -lm file.c
when I use math functions. Where can I configure gcc to add it to the
default gcc, after what I don't need the option -lm , just gcc file.c
thanks for help






You can pass a filename of a file containing your command line options
using "@file", where "file" is the filename, but if you type that every
time, you aren't gaining anything. That method is really for cases when
there is a long list of options, or they are complicated and easy to get
wrong.


Just put everything in a makefile, and call make.



--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org

Archive: 4CA38804.5010206@allums.com">http://lists.debian.org/4CA38804.5010206@allums.com

David Jardine 09-29-2010 07:31 PM

how to configure gcc
 
On Wed, Sep 29, 2010 at 06:46:20PM +0100, abdelkader belahcene wrote:
> hi,
> by default I have to add option -lm to the command gcc -lm file.c
> when I use math functions. Where can I configure gcc to add it to the
> default gcc, after what I don't need the option -lm , just gcc file.c
> thanks for help
>

You could add

alias gcc='gcc -lm ' (note the last space)

to /etc/profile

Cheers,
David


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 20100929193157.GA1908@gennes.augarten">http://lists.debian.org/20100929193157.GA1908@gennes.augarten

Joseph Lenox 09-29-2010 07:53 PM

how to configure gcc
 
It's called a makefile.
http://www.cs.utah.edu/dept/old/texinfo/make/make_toc.html

On 9/29/2010 12:46 PM, abdelkader belahcene wrote:

hi,
by default I have to add option -lm to the command gcc -lm file.c
when I use math functions. Where can I configure gcc to add it to the
default gcc, after what I don't need the option -lm , just gcc file.c
thanks for help






--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org

Archive: 4CA3992A.8000308@gmail.com">http://lists.debian.org/4CA3992A.8000308@gmail.com

Mark Allums 09-29-2010 08:15 PM

how to configure gcc
 
On 9/29/2010 2:31 PM, David Jardine wrote:

On Wed, Sep 29, 2010 at 06:46:20PM +0100, abdelkader belahcene wrote:

hi,
by default I have to add option -lm to the command gcc -lm file.c
when I use math functions. Where can I configure gcc to add it to the
default gcc, after what I don't need the option -lm , just gcc file.c
thanks for help



You could add

alias gcc='gcc -lm ' (note the last space)

to /etc/profile



Good idea. There may be an existing alias for gcc, then he might want
to edit it carefully, rather than simply adding the line.


:)




--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org

Archive: 4CA39E4B.9000703@allums.com">http://lists.debian.org/4CA39E4B.9000703@allums.com

abdelkader belahcene 09-29-2010 08:18 PM

how to configure gcc
 
Thanks for answer
yes but normally gcc should be configured, where is the config file,
for example sshd_config is a config file for ssh, vsftpd.conf for
ftp server and so on .., so where is the config file for gcc, just this
I couldn't find it.

thanks a lot
regards



--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 1285791526.1853.29.camel@belaHome.bela.home">http://lists.debian.org/1285791526.1853.29.camel@belaHome.bela.home

09-29-2010 11:53 PM

how to configure gcc
 
>
>
>
>---- Original Message ----
>From: abelahcene@gmail.com
>To: debian-user@lists.debian.org
>Subject: RE: how to configure gcc
>Date: Wed, 29 Sep 2010 18:46:20 +0100
>
>>hi,
>>by default I have to add option -lm to the command gcc -lm
>file.c
>>when I use math functions. Where can I configure gcc to add it to
>the
>>default gcc, after what I don't need the option -lm , just gcc
>file.c
>>thanks for help
>>
>>
just do an alias that includes the -lm link to the math lib
Larry
>>
>>--
>>To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
>>with a subject of "unsubscribe". Trouble? Contact
>listmaster@lists.debian.org
>>Archive: http://lists.debian.org/1285782380.1853.26.camel@belaHome.b
>ela.home
>>
>>



--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 380-220109329235334359@netptc.net">http://lists.debian.org/380-220109329235334359@netptc.net

"Boyd Stephen Smith Jr." 09-30-2010 03:42 AM

how to configure gcc
 
On Wednesday 29 September 2010 15:18:46 abdelkader belahcene wrote:
> Thanks for answer
> yes but normally gcc should be configured, where is the config file,
> for example sshd_config is a config file for ssh, vsftpd.conf for
> ftp server and so on .., so where is the config file for gcc, just this
> I couldn't find it.

It's in the same place as the config file for ls, cp, and rm. (There isn't
one.)

sshd runs continuously as a daemon, as does vsftp, which is part of why they
have configuration files.

You should use make or another build system to provide options to gcc, ld, and
other tools used for building your source.
--
Boyd Stephen Smith Jr. ,= ,-_-. =.
bss@iguanasuicide.net ((_/)o o(\_))
ICQ: 514984 YM/AIM: DaTwinkDaddy `-'(. .)`-'
http://iguanasuicide.net/ \_/

Anand Sivaram 09-30-2010 03:50 AM

how to configure gcc
 
On Thu, Sep 30, 2010 at 09:12, Boyd Stephen Smith Jr. <bss@iguanasuicide.net> wrote:

On Wednesday 29 September 2010 15:18:46 abdelkader belahcene wrote:

> Thanks for answer

> yes but normally *gcc should be configured, where is the config file,

> for example *sshd_config * is a config file for ssh, *vsftpd.conf *for

> ftp server and so on .., *so where is the config file for gcc, just this

> I couldn't find it.



It's in the same place as the config file for ls, cp, and rm. *(There isn't

one.)



sshd runs continuously as a daemon, as does vsftp, which is part of why they

have configuration files.



You should use make or another build system to provide options to gcc, ld, and

other tools used for building your source.

--

Boyd Stephen Smith Jr. * * * * * * * * * ,= ,-_-. =.

bss@iguanasuicide.net * * * * * * * * * ((_/)o o(\_))

ICQ: 514984 YM/AIM: DaTwinkDaddy * * * * `-'(. .)`-'

http://iguanasuicide.net/ * * * * * * * * * *\_/


I think using an alias 'gcc -lm' is not a good idea. *It may be looking easier for this particular C file, but '-lm' would be linked always for even in the case of hello_world.c which is really unnecessary.
The best way to solve this problem is as I mentioned previously..... use makefiles

09-30-2010 07:20 PM

how to configure gcc
 
>> On Thu, 30 Sep 2010 09:20:36 +0530,
>> Anand Sivaram <aspnair@gmail.com> said:

AS> On Thu, Sep 30, 2010 at 09:12, Boyd Stephen Smith Jr. wrote:
B> On Wednesday 29 September 2010 15:18:46 abdelkader belahcene wrote:
A> yes but normally gcc should be configured, where is the config file,

B> It's in the same place as the config file for ls, cp, and rm. (There
B> isn't one.)

This is where the BSD version of make has an advantage over GNU make.
It checks for system-wide defaults in the file /etc/make.conf:

me% uname -sr
FreeBSD 6.2-RELEASE

me% cat /etc/make.conf
CPUTYPE?=pentium4
CFLAGS= -O2 -pipe -funroll-loops
COPTFLAGS= -O -pipe

AS> I think using an alias 'gcc -lm' is not a good idea. It may be looking
AS> easier for this particular C file, but '-lm' would be linked always for
AS> even in the case of hello_world.c which is really unnecessary.

The additional linking won't do much besides take an extra millisecond
of time and add around 25 bytes to your binary; that's what I saw when
comparing on a Deadrat Enterprise system. Build the executable both
ways, run "nm" and chop the first 10 characters to see for yourself.
The results should be identical.

You're right about the alias -- it works fine right up to the part where
someone changes their login shell or alias setup. It's safer to use a
script as a front-end, so you can check for environment variables in a
global or user-specific config file:

#!/bin/sh
# front-end for make with preset preferences.
export PATH=/usr/local/bin:/bin:/sbin:/usr/sbin:/usr/bin
cbase='make.conf'
for cfg in /etc/$cbase $HOME/etc/$cbase; do
test -f "$cfg" && . $cfg
done
exec /usr/bin/make ${1+"$@"} # Use full path just to be safe...
exit 1

Under Linux, the config file looks like this:

me% cat $HOME/etc/make.conf
# Default values for make.
export CC="gcc"
export CFLAGS="-O2 -pipe -funroll-loops"
export COPTFLAGS="-O -pipe"

Comparison:

me% cat Makefile
hello: hello.o
hello.o: hello.c

me% cat hello.c
#include <stdio.h>
#include <stdlib.h>
main()
{
printf("hello, world
");
#ifdef unix
printf("unix defined
");
#endif
exit(0);
}

me% make
cc -c -o hello.o hello.c
cc hello.o -o hello

me% ./make # using the frontend script
gcc -O2 -pipe -funroll-loops -c -o hello.o hello.c
gcc hello.o -o hello

--
Karl Vogel I don't speak for the USAF or my company

Beauty is only a light switch away.
--Perkins Library, Duke University, Durham, North Carolina


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 20100930192027.79C5ABF65@kev.msw.wpafb.af.mil">htt p://lists.debian.org/20100930192027.79C5ABF65@kev.msw.wpafb.af.mil


All times are GMT. The time now is 05:34 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.