Re: [LINUX:3150] C++ derleme?

Erol Ozcan (eozcan@superonline.com)
Thu, 18 Jun 1998 21:16:02 +0000


Merhaba,

Osman Demirhan wrote:

> Herkese selam;
>
> C++ ile yazilmis basit bir iki programi derlerken derleme hatalari ile
>

> ----------------------------------------------------------
> Birinci Dosya: (Klasik baslama programi:)
>
> #include <iostream.h>
> #include <iomanip.h>
> main (){
> cout << "Hello!;
> }
>
> Komut satiri: gcc hello.cc -o hello
>
> HATA MESAJI:
>
> hello.cc:4: unterminated string or character constant
> hello.cc:4: possible real start of unterminated constant
> ---------------------------------------------------------------
>

Bu hatanin cikmasi dogal. Cunku yazilacak string cift tirnakile
kapatilmamais. Ayrica C++ kodlarini derlemek icin
"g++" derleyicisini kullanmaniz gerekiyor.

% g++ yazlan.cpp -o yazlan

---------yazlan.cpp----
#include <iostream.h>
#include <iomanip.h>
main ()
{
cout << "Hello!\n";
}
----------------

> HATA MESAJI:
>
> /tmp/cca007571.o: In function `main':
> /tmp/cca007571.o(.text+0xc): undefined reference to `cout'
> /tmp/cca007571.o(.text+0x11): undefined reference to
> `ostream::operator<<(char const *)'
> /tmp/cca007571.o(.text+0x1f): undefined reference to `cin'
>

Ikinci kodu derlerkende gcc kullanmissiniz. dogal olarak buhatalar cikar.

% g++ cevirfahc.cpp -o cevirfahc

----cevirfahc.cpp-----
#include <iostream.h>
#include <iomanip.h>
main ()
{
float temp;
cout << "Please type the temprature (deg F): ";
cin >> temp;
cout << temp;
cout << " Deg F is ";
cout << (5.0 * (temp - 32)) / 9.0;
cout << " deg C\n";
}
--------------------

Benim size tavsiyem kod yazmaya baslamadan
once biraz Linux ve derleyiciler hakkindaki HOWTO
FAQ vb. dokumanlarina goz atmaniz.

Iyi calismalar..

Erol Ozcan
infoTRON A.S.
Sys Admin
Web: www.infotron-tr.com
email: eozcan@superonline.com