Re: Strange C++ Compilation Error

  • From: "qubit" <lauraeaves@xxxxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Mon, 21 Sep 2009 20:04:33 -0500

perhaps you are using the wrong library? Your code looks good, with the 
possible exception of the line splitting in the middle of a string.  I don't 
know if that was the mail client that did that or the programmer... If you 
want to split a quoted line in the middle and put the rest on the next line, 
use \ as the last character on the broken line. The backslash won't show up 
in the output but it will appease the compiler.
Happy hacking.
--le



----- Original Message ----- 
From: "Jared Wright" <wright.jaredm@xxxxxxxxx>
To: <programmingblind@xxxxxxxxxxxxx>
Sent: Monday, September 21, 2009 3:30 AM
Subject: Strange C++ Compilation Error


'llo all, I've been away from C++ for a couple years but have recently
been asked to do a project for school in it. In getting started, I'm
having a very unexpected adventure trying to get the following Hello
World program to compile! I'm compiling it on the university's server
with GCC, which is necessary since the project is related to the OS
their server is running (some flavor of Solaris). Code below.

#include <iostream>
using namespace std;
int main()
{
   cout << "Hello World!" << endl;   cout << "Welcome to C++
Programming" << endl;
return 0;
}

The error received is:
gcc helloworld.cpp -o helloworld
Undefined                       first referenced
  symbol                             in file
std::basic_string<char, std::char_traits<char>, std::allocator<char>
 >::operator
[](unsigned int) const/var/tmp//ccSOACjU.o
std::basic_ostream<char, std::char_traits<char>
 >::operator<<(std::basic_ostream
<char, std::char_traits<char> >& (*)(std::basic_ostream<char,
std::char_traits<c
har> >&))/var/tmp//ccSOACjU.o
std::cout                           /var/tmp//ccSOACjU.o
std::ios_base::Init::~Init()        /var/tmp//ccSOACjU.o
std::ios_base::Init::Init()         /var/tmp//ccSOACjU.o
__gxx_personality_v0                /var/tmp//ccSOACjU.o
std::basic_ostream<char, std::char_traits<char> >& std::operator<<
<std::char_tr
aits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char
const*)/va
r/tmp//ccSOACjU.o
std::basic_string<char, std::char_traits<char>, std::allocator<char>
 >::size() c
onst/var/tmp//ccSOACjU.o
std::basic_ostream<char, std::char_traits<char> >& std::endl<char,
std::char_tra
its<char> >(std::basic_ostream<char, std::char_traits<char>
 >&)/var/tmp//ccSOACj
U.o
ld: fatal: Symbol referencing errors. No output written to helloworld
collect2: ld returned 1 exit status

In the googling I did, most of what I found for the "first unreferenced
symbol" business came back to not having a main() function, which isn't
the case here. And nothing I came across mentioned all that gunk in the
STD namespace. Any help or tips very appreciated.

Best,
Jared


__________
View the list's information and change your settings at
//www.freelists.org/list/programmingblind

__________
View the list's information and change your settings at 
//www.freelists.org/list/programmingblind

Other related posts: