compiler errors - c++ "Hello World" program will not compile -


i have searched why c++ "hello world" program not compile wasn't able find works. wrote c++ hello world program using visual studio code , after save , try compile in command prompt using

gcc helloworld.cpp -o helloworld.exe 

it gives following:

gcc helloworld.cpp -o helloworld.exe c:\users\pgnic\appdata\local\temp\ccruakvt.o:helloworld.cpp:(.text+0x21): undefined reference `std::cout' c:\users\pgnic\appdata\local\temp\ccruakvt.o:helloworld.cpp:(.text+0x26): undefined reference `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)' c:\users\pgnic\appdata\local\temp\ccruakvt.o:helloworld.cpp:(.text+0x2d): undefined reference `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)' c:\users\pgnic\appdata\local\temp\ccruakvt.o:helloworld.cpp:(.text+0x34): undefined reference `std::ostream::operator<<(std::ostream& (*)(std::ostream&))' c:\users\pgnic\appdata\local\temp\ccruakvt.o:helloworld.cpp:(.text+0x54): undefined reference `std::ios_base::init::~init()' c:\users\pgnic\appdata\local\temp\ccruakvt.o:helloworld.cpp:(.text+0x75): undefined reference `std::ios_base::init::init()' collect2.exe: error: ld returned 1 exit status 

my code: helloworld.cpp

#include <iostream>  using namespace std;  int main(){   cout << "hello world!" << endl;   return(0); } 

i think has problem including iostream library or along lines, i'm not sure.

use g++, not gcc:

g++ helloworld.cpp -o helloworld.exe 

Comments

Popular posts from this blog

mongodb - How to keep track of users making Stripe Payments -

javascript - Fire on return from form "Submit" -

javascript - Thinglink image not visible until browser resize -