Re: gcc vs g++
On Tue, 05.05.2009 14:01:36 , Vasil'ev Michail wrote:
> Здравствуйте!
>
> Возникла странная проблема.
>
> --(~/calc_with_fedotchev/calc/experimental)--
> -->cat test.c
> #include <math.h>
> #include <stdio.h>
>
> int main()
> {
> double res;
> double inp = 3.1415;
> res = ceil(inp);
> return 0;
> }
> --(~/calc_with_fedotchev/calc/experimental)--
> -->gcc -o test test.c
> /tmp/cc41kOdl.o: In function `main':
> test.c:(.text+0x21): undefined reference to `ceil'
> collect2: ld returned 1 exit status
>
> Почему этот код не компилируется? При этом
> g++ -o test test.c
> работает нормально. Debian Lenny 5.0.1, gcc из репозитория.
> В чём может быть проблема?
>
> Заранее спасибо.
t:~$ gcc -o tmp/test tmp/test.c
/tmp/ccxBRvaA.o: In function `main':
test.c:(.text+0x21): undefined reference to `ceil'
collect2: выполнение ld завершилось с кодом возврата 1
t:~$ gcc -lm -o tmp/test tmp/test.c
t:~$
--
С уважением,
Тихон Тарнавский.
http://linuxforum.ru
http://posix.ru
Reply to:
- References:
- gcc vs g++
- From: Vasil'ev Michail <dlia-spama@mail.ru>