--=-UxTidu79pV7/+pndGGsT
Content-Type: multipart/alternative; boundary="=-hBro3+Unp5t+dvHbgTo4"
--=-hBro3+Unp5t+dvHbgTo4
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
Somebody please explain what I'm doing wrong here. I'm trying to work on
some of my Advanced Placement computer science AB projects here at home.
Well, I typed in the code, checked it twice and ran 'gcc main.cpp' to no
avail. First it gave me warnings about textspace standard so I fixed the
code to make it recent (the book is 1994) and tried again. I now get all
kinds of linker errors:
/tmp/ccv7OZu3.o: In function `main':
/tmp/ccv7OZu3.o(.text+0x36): undefined reference to
`std::basic_ostream<char, std::char_traits<char> >& std::endl<char,
std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char>
>&)'
/tmp/ccv7OZu3.o(.text+0x43): undefined reference to `std::cout'
/tmp/ccv7OZu3.o(.text+0x48): 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/ccv7OZu3.o(.text+0x51): undefined reference to
`std::basic_ostream<char, std::char_traits<char>
>::operator<<(std::basic_ostream<char, std::char_traits<char> >&
(*)(std::basic_ostream<char, std::char_traits<char> >&))'
/tmp/ccv7OZu3.o(.text+0x86): undefined reference to `std::cout'
/tmp/ccv7OZu3.o(.text+0x8b): undefined reference to
`std::basic_ostream<char, std::char_traits<char> >& std::operator<<
<char, std::char_traits<char> >(std::basic_ostream<char,
std::char_traits<char> >&, std::_Setw)'
/tmp/ccv7OZu3.o(.text+0x94): undefined reference to
`std::basic_ostream<char, std::char_traits<char> >::operator<<(int)'
/tmp/ccv7OZu3.o(.text+0x10b): undefined reference to
`std::basic_ostream<char, std::char_traits<char> >& std::endl<char,
std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char>
>&)'
/tmp/ccv7OZu3.o(.text+0x118): undefined reference to `std::cout'
/tmp/ccv7OZu3.o(.text+0x11d): 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/ccv7OZu3.o(.text+0x126): undefined reference to
`std::basic_ostream<char, std::char_traits<char>
>::operator<<(std::basic_ostream<char, std::char_traits<char> >&
(*)(std::basic_ostream<char, std::char_traits<char> >&))'
/tmp/ccv7OZu3.o(.text+0x15b): undefined reference to `std::cout'
/tmp/ccv7OZu3.o(.text+0x160): undefined reference to
`std::basic_ostream<char, std::char_traits<char> >& std::operator<<
<char, std::char_traits<char> >(std::basic_ostream<char,
std::char_traits<char> >&, std::_Setw)'
/tmp/ccv7OZu3.o(.text+0x169): undefined reference to
`std::basic_ostream<char, std::char_traits<char> >::operator<<(int)'
/tmp/ccv7OZu3.o(.text+0x17b): undefined reference to
`std::basic_ostream<char, std::char_traits<char> >& std::endl<char,
std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char>
>&)'
/tmp/ccv7OZu3.o(.text+0x180): undefined reference to `std::cout'
/tmp/ccv7OZu3.o(.text+0x185): undefined reference to
`std::basic_ostream<char, std::char_traits<char>
>::operator<<(std::basic_ostream<char, std::char_traits<char> >&
(*)(std::basic_ostream<char, std::char_traits<char> >&))'
/tmp/ccv7OZu3.o: In function
`__static_initialization_and_destruction_0(int, int)':
/tmp/ccv7OZu3.o(.text+0x1b6): undefined reference to
`std::ios_base::Init::Init[in-charge]()'
/tmp/ccv7OZu3.o: In function `__tcf_0':
/tmp/ccv7OZu3.o(.text+0x1e5): undefined reference to
`std::ios_base::Init::~Init [in-charge]()'
/tmp/ccv7OZu3.o(.eh_frame+0x11): undefined reference to
`__gxx_personality_v0'
collect2: ld returned 1 exit status
Does anyone know what I can do about this?
-- Zach Schimke
--=-hBro3+Unp5t+dvHbgTo4
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: 7bit
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
<META NAME="GENERATOR" CONTENT="GtkHTML/1.1.7">
</HEAD>
<BODY>
Somebody please explain what I'm doing wrong here. I'm trying to work on some of my Advanced Placement computer science AB projects here at home. Well, I typed in the code, checked it twice and ran 'gcc main.cpp' to no avail. First it gave me warnings about textspace standard so I fixed the code to make it recent (the book is 1994) and tried again. I now get all kinds of linker errors:<BR>
<BR>
/tmp/ccv7OZu3.o: In function `main':<BR>
/tmp/ccv7OZu3.o(.text+0x36): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)'<BR>
/tmp/ccv7OZu3.o(.text+0x43): undefined reference to `std::cout'<BR>
/tmp/ccv7OZu3.o(.text+0x48): 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*)'<BR>
/tmp/ccv7OZu3.o(.text+0x51): undefined reference to `std::basic_ostream<char, std::char_traits<char> >::operator<<(std::basic_ostream<char, std::char_traits<char> >& (*)(std::basic_ostream<char, std::char_traits<char> >&))'<BR>
/tmp/ccv7OZu3.o(.text+0x86): undefined reference to `std::cout'<BR>
/tmp/ccv7OZu3.o(.text+0x8b): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, std::_Setw)'<BR>
/tmp/ccv7OZu3.o(.text+0x94): undefined reference to `std::basic_ostream<char, std::char_traits<char> >::operator<<(int)'<BR>
/tmp/ccv7OZu3.o(.text+0x10b): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)'<BR>
/tmp/ccv7OZu3.o(.text+0x118): undefined reference to `std::cout'<BR>
/tmp/ccv7OZu3.o(.text+0x11d): 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*)'<BR>
/tmp/ccv7OZu3.o(.text+0x126): undefined reference to `std::basic_ostream<char, std::char_traits<char> >::operator<<(std::basic_ostream<char, std::char_traits<char> >& (*)(std::basic_ostream<char, std::char_traits<char> >&))'<BR>
/tmp/ccv7OZu3.o(.text+0x15b): undefined reference to `std::cout'<BR>
/tmp/ccv7OZu3.o(.text+0x160): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, std::_Setw)'<BR>
/tmp/ccv7OZu3.o(.text+0x169): undefined reference to `std::basic_ostream<char, std::char_traits<char> >::operator<<(int)'<BR>
/tmp/ccv7OZu3.o(.text+0x17b): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)'<BR>
/tmp/ccv7OZu3.o(.text+0x180): undefined reference to `std::cout'<BR>
/tmp/ccv7OZu3.o(.text+0x185): undefined reference to `std::basic_ostream<char, std::char_traits<char> >::operator<<(std::basic_ostream<char, std::char_traits<char> >& (*)(std::basic_ostream<char, std::char_traits<char> >&))'<BR>
/tmp/ccv7OZu3.o: In function `__static_initialization_and_destruction_0(int, int)':<BR>
/tmp/ccv7OZu3.o(.text+0x1b6): undefined reference to `std::ios_base::Init::Init[in-charge]()'<BR>
/tmp/ccv7OZu3.o: In function `__tcf_0':<BR>
/tmp/ccv7OZu3.o(.text+0x1e5): undefined reference to `std::ios_base::Init::~Init [in-charge]()'<BR>
/tmp/ccv7OZu3.o(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'<BR>
collect2: ld returned 1 exit status<BR>
<BR>
Does anyone know what I can do about this?<BR>
<TT></TT><BR>
<BR>
<TABLE CELLSPACING="0" CELLPADDING="0" WIDTH="100%">
<TR>
<TD>
<PRE>-- Zach Schimke</PRE>
</TD>
</TR>
</TABLE>
</BODY>
</HTML>
--=-hBro3+Unp5t+dvHbgTo4--
--=-UxTidu79pV7/+pndGGsT
Content-Disposition: attachment; filename=main.cpp
Content-Type: text/x-c++; name=main.cpp; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
// main.cpp
//
// This program sorts an array's values into ascending order.
#include <iostream>
#include <iomanip>
using namespace std;
int main(){
const int arraySize = 10;
int a[arraySize] = { 2, 6, 4, 8, 10, 12, 89, 68, 45, 37};
int hold;
int j=0;
cout << "Data items in original order" << endl;
for (int i = 0; i < arraySize; i++)
cout << setw(4) << a[i];
for (int pass = 1; pass < arraySize - 1; pass++)
for (int i = 0; i < arraySize - pass; i++)
if (a[i] > a[i + 1]) {
hold = a[i];
a[i] = a[i + 1];
a[i + 1] = hold;
}
cout << "Data items in ascending order" << endl;
for (int i = 0; i < arraySize; i++)
cout << setw(4) << a[i];
cout << endl;
return 0;
}
--=-UxTidu79pV7/+pndGGsT--