Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

gcc nece da kompajlira...

[es] :: Linux :: gcc nece da kompajlira...

[ Pregleda: 2133 | Odgovora: 2 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

vladab
Vladimir Bašanović
Beograd

Član broj: 9512
Poruke: 498
*.vdial.verat.net.



Profil

icon gcc nece da kompajlira...04.11.2004. u 08:06 - pre 187 meseci
Imam cpp fajl
Code:
#include <iostream>
using namespace std;

void read()
{
    char i;
    cout << "Should I rename?" << endl << "Y/n"<<endl ;
    cin >> i;
    cout << "Should I format HDD?" << endl << "Y/n"<<endl ;
    cin >> i;
    cout << "Formatting... press s and <enter> to stop" << endl;
    cin >> i;
    cout << "The end"<< endl;
}

int main()
{
read();
return 0;
}

Cisto da nesto radi. gcc u devcpp pod windozom mi ga iskompajlira bez problema, a pod linuxom imam
bash-2.05b$ cc '/home/vladab/Desktop/virus.cpp'
/tmp/ccrxv8Je.o(.text+0x11): In function `read()':
: undefined reference to `std::cout'
/tmp/ccrxv8Je.o(.text+0x16): In function `read()':
: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
/tmp/ccrxv8Je.o(.text+0x1e): In function `read()':
: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)'
/tmp/ccrxv8Je.o(.text+0x26): In function `read()':
: undefined reference to `std::basic_ostream<char, std::char_traits<char> >::operator<<(std::basic_ostream<char, std::char_traits<char> >& (*)(std::basic_ostream<char, std::char_traits<char> >&))'
/tmp/ccrxv8Je.o(.text+0x36): In function `read()':
: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
/tmp/ccrxv8Je.o(.text+0x3e): In function `read()':
: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)'
/tmp/ccrxv8Je.o(.text+0x46): In function `read()':
: undefined reference to `std::basic_ostream<char, std::char_traits<char> >::operator<<(std::basic_ostream<char, std::char_traits<char> >& (*)(std::basic_ostream<char, std::char_traits<char> >&))'
/tmp/ccrxv8Je.o(.text+0x54): In function `read()':
: undefined reference to `std::cin'
/tmp/ccrxv8Je.o(.text+0x59): In function `read()':
: undefined reference to `std::basic_istream<char, std::char_traits<char> >& std::operator>><char, std::char_traits<char> >(std::basic_istream<char, std::char_traits<char> >&, char&)'
/tmp/ccrxv8Je.o(.text+0x68): In function `read()':
: undefined reference to `std::cout'
/tmp/ccrxv8Je.o(.text+0x6d): In function `read()':
: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
/tmp/ccrxv8Je.o(.text+0x75): In function `read()':
: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)'
/tmp/ccrxv8Je.o(.text+0x7d): In function `read()':
: undefined reference to `std::basic_ostream<char, std::char_traits<char> >::operator<<(std::basic_ostream<char, std::char_traits<char> >& (*)(std::basic_ostream<char, std::char_traits<char> >&))'
/tmp/ccrxv8Je.o(.text+0x8d): In function `read()':
: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
/tmp/ccrxv8Je.o(.text+0x95): In function `read()':
: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)'
/tmp/ccrxv8Je.o(.text+0x9d): In function `read()':
: undefined reference to `std::basic_ostream<char, std::char_traits<char> >::operator<<(std::basic_ostream<char, std::char_traits<char> >& (*)(std::basic_ostream<char, std::char_traits<char> >&))'
/tmp/ccrxv8Je.o(.text+0xab): In function `read()':
: undefined reference to `std::cin'
/tmp/ccrxv8Je.o(.text+0xb0): In function `read()':
: undefined reference to `std::basic_istream<char, std::char_traits<char> >& std::operator>><char, std::char_traits<char> >(std::basic_istream<char, std::char_traits<char> >&, char&)'
/tmp/ccrxv8Je.o(.text+0xbf): In function `read()':
: undefined reference to `std::cout'
/tmp/ccrxv8Je.o(.text+0xc4): In function `read()':
: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
/tmp/ccrxv8Je.o(.text+0xcc): In function `read()':
: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)'
/tmp/ccrxv8Je.o(.text+0xd4): In function `read()':
: undefined reference to `std::basic_ostream<char, std::char_traits<char> >::operator<<(std::basic_ostream<char, std::char_traits<char> >& (*)(std::basic_ostream<char, std::char_traits<char> >&))'
/tmp/ccrxv8Je.o(.text+0xe2): In function `read()':
: undefined reference to `std::cin'
/tmp/ccrxv8Je.o(.text+0xe7): In function `read()':
: undefined reference to `std::basic_istream<char, std::char_traits<char> >& std::operator>><char, std::char_traits<char> >(std::basic_istream<char, std::char_traits<char> >&, char&)'
/tmp/ccrxv8Je.o(.text+0xf6): In function `read()':
: undefined reference to `std::cout'
/tmp/ccrxv8Je.o(.text+0xfb): In function `read()':
: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
/tmp/ccrxv8Je.o(.text+0x103): In function `read()':
: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)'
/tmp/ccrxv8Je.o(.text+0x10b): In function `read()':
: undefined reference to `std::basic_ostream<char, std::char_traits<char> >::operator<<(std::basic_ostream<char, std::char_traits<char> >& (*)(std::basic_ostream<char, std::char_traits<char> >&))'
/tmp/ccrxv8Je.o(.text+0x14b): In function `__static_initialization_and_destruction_0(int, int)':
: undefined reference to `std::ios_base::Init::Init[in-charge]()'
/tmp/ccrxv8Je.o(.text+0x17c): In function `__tcf_0':
: undefined reference to `std::ios_base::Init::~Init [in-charge]()'
/tmp/ccrxv8Je.o(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status
bash-2.05b$
u cemu je problem, tj sta fali. Da napomenem da sam instalirao programe iz source-a bez problema.
 
Odgovor na temu

Časlav Ilić
Braunšvajg, Nemačka

Član broj: 4945
Poruke: 562
*.informatik.uni-erlangen.de.



+23 Profil

icon Re: gcc nece da kompajlira...04.11.2004. u 09:54 - pre 187 meseci
Citat:
man gcc:
However, C++ programs often require class libraries as well as a compiler that understands the C++ language---and under some circumstances, you might want to compile programs from standard input, or otherwise without a suffix that flags them as C++ programs. g++ is a program that calls GCC with the default language set to C++, and automatically specifies linking against the C++ library. On many systems, g++ is also installed with the name c++.

Drugim rečima, kad upotrebiš naredbu cc (odnosno gcc) na C++ datoteci, kompilator ne podrazumeva da treba da poveže i standardne C++ biblioteke. Zato upotrebi c++ (odnosno g++), ili zadaj eksplicitno koje biblioteke treba povezati.
 
Odgovor na temu

vladab
Vladimir Bašanović
Beograd

Član broj: 9512
Poruke: 498
213.244.197.*



Profil

icon Re: gcc nece da kompajlira...04.11.2004. u 21:30 - pre 187 meseci
Hvala ti puno! Do sada sam pisao samo C kod, pa nisam imao slicnih problema!
 
Odgovor na temu

[es] :: Linux :: gcc nece da kompajlira...

[ Pregleda: 2133 | Odgovora: 2 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.