Thread View: es.comp.os.linux.programacion
4 messages
4 total messages
Started by gustavo
Thu, 30 Sep 1999 00:00
Novato intentando aprender C.
Author: gustavo
Date: Thu, 30 Sep 1999 00:00
Date: Thu, 30 Sep 1999 00:00
38 lines
1525 bytes
1525 bytes
Hola a todos. Estoy intent�ndome iniciarme en el mundo de la
programaci�n en C. Pues bien. Estoy intentando compilar los primeros
ejemplos que vienen en el manual. El problema aparece cuando intento
compilar los primeros ejemplos que utilizan alguna funci�n matem�tica.
Os pongo este simple ejemplo:
#include "stdio.h"
#include "math.h"
main()
{
double answer;
answer= sqrt (10.0);
printf("%f",answer);
}
y da el siguiente error �?�?�
make -k prog
cc prog.c -o prog
/tmp/cccPdBGy: In function `main':
/tmp/cccPdBGy(.text+0xe): undefined reference to `sqrt'
make: *** [prog] Error 1
Compilation exited abnormally with code 2 at Thu Sep 30 22:52:40
Como que no hay referencia definida para sqrt si incluyo el archivo de
cabecera math.h???
Siento molestaros con esta pregunta seguramente tonta pero es que no
me aclaro con esto todavia. Gracias de antemano
Gustavo
Re: Novato intentando aprender C.
Author: Fernand0
Date: Fri, 01 Oct 1999 00:00
Date: Fri, 01 Oct 1999 00:00
46 lines
1968 bytes
1968 bytes
Hola,
On 30 Sep 1999 23:35:44 +0200, gustavo <guscal@antrumis.es> wrote:
>
>
>Hola a todos. Estoy intent�ndome iniciarme en el mundo de la
>programaci�n en C. Pues bien. Estoy intentando compilar los primeros
>ejemplos que vienen en el manual. El problema aparece cuando intento
>compilar los primeros ejemplos que utilizan alguna funci�n matem�tica.
>Os pongo este simple ejemplo:
>
>#include "stdio.h"
>#include "math.h"
>
>main()
>{
> double answer;
>
> answer= sqrt (10.0);
> printf("%f",answer);
>}
>
>
>y da el siguiente error �?�?�
>
>make -k prog
>cc prog.c -o prog
>/tmp/cccPdBGy: In function `main':
>/tmp/cccPdBGy(.text+0xe): undefined reference to `sqrt'
>make: *** [prog] Error 1
>
>Compilation exited abnormally with code 2 at Thu Sep 30 22:52:40
>
>
>Como que no hay referencia definida para sqrt si incluyo el archivo de
>cabecera math.h???
est� el prototipo de la funci�n que es lo que contiene el .h, pero nada m�s.
Necesitas poner, en alg�n sitio de tu Makefile una l�nea como esta:
LFLAGS = -lm
(esto es, que compile tu programa con la biblioteca matem�tica).
Un saludo,
--
Fernand0
Re: Novato intentando aprender C.
Author: NoP / Compiler
Date: Fri, 01 Oct 1999 00:00
Date: Fri, 01 Oct 1999 00:00
22 lines
1446 bytes
1446 bytes
gustavo wrote: > cc prog.c -o prog > /tmp/cccPdBGy: In function `main': > /tmp/cccPdBGy(.text+0xe): undefined reference to `sqrt' > make: *** [prog] Error 1 necesitas incluir la libreria matematica: gcc -o prog prog.c -lm salu2. -- El hombre nunca es demasiado viejo para aprender. ------------------------------------------------------------ __ --- | NoP / Compiler - compiler@iname.com | /oo\ | |--------------------------------------------------------| (\/) | | POWERED BY - Linux RedHat 6.0 - Reg. User #74.821 | / __ \ | | NoP en IrcHispano | |\ /| | | |_OO __ OO_| | <Espacio cedido para publicidad por 100$> | -------------------------------------------------------------------
Re: Novato intentando aprender C.
Author: *puntero_loco
Date: Fri, 01 Oct 1999 00:00
Date: Fri, 01 Oct 1999 00:00
51 lines
2103 bytes
2103 bytes
-----BEGIN PGP SIGNED MESSAGE-----
El 30 Sep 1999 23:35:44 +0200, gustavo nos ray� diciendo:
Tienes que compilar con la opci�n -lm. (gcc archivo.c -lm)
|#include "stdio.h"
|#include "math.h"
|
|main()
|{
| double answer;
|
| answer= sqrt (10.0);
| printf("%f",answer);
|}
|
|
|y da el siguiente error �?�?�
|
|make -k prog
|cc prog.c -o prog
|/tmp/cccPdBGy: In function `main':
|/tmp/cccPdBGy(.text+0xe): undefined reference to `sqrt'
|make: *** [prog] Error 1
|
|Compilation exited abnormally with code 2 at Thu Sep 30 22:52:40
- --
____ _ _
__/\_| _ \ _ _ _ __ | |_ ___ _ __ ___ | | ___ ___ ___
\ / |_) | | | | '_ \| __/ _ \ '__/ _ \ | | / _ \ / __/ _ \
/_ _\ __/| |_| | | | | || __/ | | (_) | | |__| (_) | (_| (_) |
\/ |_| \__,_|_| |_|\__\___|_| \___/___|_____\___/ \___\___/
|_____|
P�gina personal + clave p�blica: http://personal5.iddeo.es/jajs
-----BEGIN PGP SIGNATURE-----
Version: 2.6.3ia
Charset: latin1
Comment: Requires PGP version 2.6 or later.
iQCVAwUBN/S+kARI4vufvzrFAQEqSwQAisnfJgdQ6+U8ls4F/gjEsuRd6YhFd4Fm
Rwebq7cJn1NQYIXUbJtoF3/fmX7EQHmS24PawUMatNGnYoeRyNDHuh2u+CPCkNKU
myqnFCSuhMfsa+d35eyprWL+Ikr7KYzrz72Wu9H3Q23E4gw1shz7NzdalSn+LUBk
v7yZdIQD4QM=
=hExX
-----END PGP SIGNATURE-----
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads