Форум АНТИЧАТ

Форум АНТИЧАТ (https://forum.antichat.xyz/index.php)
-   С/С++, C#, Delphi, .NET, Asm (https://forum.antichat.xyz/forumdisplay.php?f=24)
-   -   gcc и g++ (https://forum.antichat.xyz/showthread.php?t=127043)

Дикс 26.06.2009 12:44

gcc и g++
 
поставил в дебиан 4 gcc и g++
написал простой код:
PHP код:

#include <iostream>
using namespace std;

int main()
{

        
cout << "test";
        return 
1;


не компилируется:
Код:

deex@debian:~$ gcc -o ./file ./new.cpp
/tmp/cc6PLgCa.o: In function `__static_initialization_and_destruction_0(int, int)':
new.cpp:(.text+0x23): undefined reference to `std::ios_base::Init::Init()'
/tmp/cc6PLgCa.o: In function `__tcf_0':
new.cpp:(.text+0x6c): undefined reference to `std::ios_base::Init::~Init()'
/tmp/cc6PLgCa.o: In function `main':
new.cpp:(.text+0x8e): undefined reference to `std::cout'
new.cpp:(.text+0x93): 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/cc6PLgCa.o:(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status

почему? :confused:

Qwazar 26.06.2009 12:49

std::cout << "test";

Дикс 26.06.2009 12:52

это была опечатка
я исправил
так тоже не работает

Qwazar 26.06.2009 12:56

gcc <source> -lstdc++

(c) первая же ссылка в гугле: http://www.codeguru.com/forum/archiv.../t-351875.html

M@X Dr.Akyla 26.06.2009 13:14

Код правильный. У меня на убунте g++ все скомпилил. Ваш код написан на C++ и компилить его надо не в gcc, а в g++.

Дикс 26.06.2009 14:09

да, я уже это понял, спасибо
gcc - как я понимаю - это коллекция компиляторов, а g++ - конкретный компилятор для С++


Время: 09:16