Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Need help to compile the file in C++ in linux

Status
Not open for further replies.

H_D_R

Full Member level 6
Joined
Jan 31, 2008
Messages
329
Helped
26
Reputation
52
Reaction score
9
Trophy points
18
Location
India
Activity points
0
Hello all,

i am learning C++ on linux.
i have tried to compile very simple code "Fiert.cc"

Code:
1: #include <iostream.h>
2:
3: main()
4: {
5:     float pi = 3.14;
6:     cout << "The value of pi is " << pi << "\n";
7:     return 0;

8: }
when i compiled this code i am getting such warning msg.

In file included from /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2/backward/iostream.h:31,
from 1.cpp:1:
/usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <iostream> instead of the deprecated header <iostream.h>. To disable this warning use -Wno-deprecated.
/tmp/ccYMN8qn.o: In function `__static_initialization_and_destruction_0(int, int)':
1.cpp:(.text+0x23): undefined reference to `std::ios_base::Init::Init()'
/tmp/ccYMN8qn.o: In function `__tcf_0':
1.cpp:(.text+0x6c): undefined reference to `std::ios_base::Init::~Init()'
/tmp/ccYMN8qn.o: In function `main':
1.cpp:(.text+0x96): undefined reference to `std::cout'
1.cpp:(.text+0x9b): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::eek:perator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
1.cpp:(.text+0xac): undefined reference to `std::basic_ostream<char, std::char_traits<char> >::eek:perator<<(float)'
1.cpp:(.text+0xbc): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::eek:perator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
/tmp/ccYMN8qn.o: (.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status

can any one please help me to solve this problem..??
 

Hi

Everything in standard headers like <iostream> is inside std namespace, hence
it's std::cin and std::cout .
btw, cin and cout are not functions.

change iostream.h by.. iostream

Code:
#include <iostream>
main()
{
float pi = 3.14;
std::cout << "The value of pi is " << pi << "\n";
return 0;
}

compile:
$ g++ Fiert.cc -o Fiert.out


g++ compile c++
gcc compile c

enjoy
 

    H_D_R

    Points: 2
    Helpful Answer Positive Rating
Thank you so much aospinas,

i have got the solution.
BTW, i was able to see output from my code also but the problem was warning. it was appearing on every compilation.

anyway thanks a lot again...!!!

God bless you..:D :D
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top