ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hi, I've been using linux for some time now, but am new to programming on it. When trying to compile a simple c++ program the compilation fails.
Program:
Code:
#include <iostream>
using namespace std;
// C++ Program
int main()
{
cout << "Hello World";
return 0;
}
Error:
Code:
/tmp/cc4geWt3.o: In function `main':
c++.cpp:(.text+0x25): undefined reference to `std::cout'
c++.cpp:(.text+0x2a): 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/cc4geWt3.o: In function `__tcf_0':
c++.cpp:(.text+0x47): undefined reference to `std::ios_base::Init::~Init()'
/tmp/cc4geWt3.o: In function `__static_initialization_and_destruction_0(int, int)':
c++.cpp:(.text+0x74): undefined reference to `std::ios_base::Init::Init()'
/tmp/cc4geWt3.o:(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status
Hey, the same thing happens on my compiler as well!
#include <iostream.h> works but not
#include <iostream>
But interestingly enough it warns me that <iostream.h> is deprecated and I should replace it with <iostream>.
I thought <iostream> was STANDARD, though.
hi, thanx for the replies. redazzz was right, using "g++ -o ... ..." solved the problem. I would like to say thanks to redazz because i see him post really helpfull comments all the time. Unfourtanatly i just broke my arm today, so i wont be awnsering many posts for a while. Typing with one hand is hard
hi, thanx for the replies. redazzz was right, using "g++ -o ... ..." solved the problem. I would like to say thanks to redazz because i see him post really helpfull comments all the time. Unfourtanatly i just broke my arm today, so i wont be awnsering many posts for a while. Typing with one hand is hard
I'm also learning C++ so some of the stuff is still fresh in my mind.
hi, thanx for the replies. redazzz was right, using "g++ -o ... ..." solved the problem. I would like to say thanks to redazz because i see him post really helpfull comments all the time. Unfourtanatly i just broke my arm today, so i wont be awnsering many posts for a while. Typing with one hand is hard
Owwhhh... Get better soon! And good luck with the learning!
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.