Hello,
This is a simple C++ code (which is there in C++ primer): - #include <iostream>
-
-
int main()
-
{
-
std :: cout << "Enter the numbers: " << std :: endl;
-
int v1, v2;
-
-
std :: cin >> v1 >> v2;
-
std :: cout << "The sum of " << v1 << " and " << v2<< " is " << v1 + v2 << std :: endl;
-
-
return 0;
-
}
Now when I try compiling with gcc 3.3.5 under OpenBSD 4.4, I get following output at terminal: - $gcc -o file file.cpp
-
try.cpp:13:2: warning: no newline at end of file
-
/tmp//ccF18167.o(.text+0x1c): In function `main':
-
: 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//ccF18167.o(.text+0x29): In function `main':
-
: undefined reference to `std::cout'
-
/tmp//ccF18167.o(.text+0x2e): In function `main':
-
: 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//ccF18167.o(.text+0x37): In function `main':
-
: 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//ccF18167.o(.text+0x4d): In function `main':
-
: undefined reference to `std::cin'
-
/tmp//ccF18167.o(.text+0x52): In function `main':
-
: undefined reference to `std::basic_istream<char, std::char_traits<char> >::operator>>(int&)'
-
/tmp//ccF18167.o(.text+0x5b): In function `main':
-
: undefined reference to `std::basic_istream<char, std::char_traits<char> >::operator>>(int&)'
-
/tmp//ccF18167.o(.text+0x66): In function `main':
-
: 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//ccF18167.o(.text+0x99): In function `main':
-
: undefined reference to `std::cout'
-
/tmp//ccF18167.o(.text+0x9e): In function `main':
-
: 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//ccF18167.o(.text+0xa7): In function `main':
-
: undefined reference to `std::basic_ostream<char, std::char_traits<char> >::operator<<(int)'
-
/tmp//ccF18167.o(.text+0xb0): In function `main':
-
: 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//ccF18167.o(.text+0xb9): In function `main':
-
: undefined reference to `std::basic_ostream<char, std::char_traits<char> >::operator<<(int)'
-
/tmp//ccF18167.o(.text+0xc2): In function `main':
-
: 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//ccF18167.o(.text+0xcb): In function `main':
-
: undefined reference to `std::basic_ostream<char, std::char_traits<char> >::operator<<(int)'
-
/tmp//ccF18167.o(.text+0xd4): In function `main':
-
: 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//ccF18167.o(.text+0x11e): In function `__static_initialization_and_destruction_0(int, int)':
-
: undefined reference to `std::ios_base::Init::Init()'
-
/tmp//ccF18167.o(.text+0x14d): In function `__tcf_0':
-
: undefined reference to `std::ios_base::Init::~Init()'
-
/tmp//ccF18167.o(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
-
collect2: ld returned 1 exit status
-
Now I dont know the reason for this. I even tried using gcc under linux, MinGW under windows but got similar compiler output.
If I try compiling with g++, all is fine. But as man page says, gcc and g++ are same. So what is the problem?
Thanks.....
AmbrNewlearner
1 2355
gcc and g++ are not the same. g++ is for compiling c++ files while gcc is for c files. gcc will compile as c++ when it sees a file extension it regards to be c++ but it will not link the object files created during the compilation correctly itself, which is why you are getting those errors.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Drew Lettington |
last post by:
I'm making a simple call to display error messages in a
MessageBox from a Windows form and the MessageBox is not
behaving in a modal fashion. My modal form displays, the
user clicks a button and...
|
by: amit kumar |
last post by:
I am calling a function which returns pointer to a map.
The declaration of the map is map<int,vectxyz*>. vectxyz is a vector
containing pointer to a class xyz.
For map<int,vectxyz*>* p1
In the...
|
by: DamonChong |
last post by:
Hi, I am new and had this piece of code which I created but it is not
behaving as expected. I'm using g++, can someone help me out? Thank
you.
//--------file (Object.cc)-----------
class Object...
|
by: ellre923 |
last post by:
I use gdb to trace the following code and find "howlong" is changed
strangely.
int CmDispatch::waitFor(timeval* howlong) {
int nfound=-1;
for(;nfound<0;) {
CmFdSet& r=onRead_->onSelects();...
|
by: elime |
last post by:
Hi all
I have a strange behaving on some PC with my DataGrid.
It only occurs on some PC, on others it works perfectly fine. ->(same
..net version installed) it's very confusing.
starting...
|
by: Steve - DND |
last post by:
I just implemented a page that performs a Response.Redirect(url, true). As
such, I wrapped it in a try catch, and explicitly caught a
ThreadAbortException. However, the thread abort exception was...
|
by: bingomanatee |
last post by:
I have developed what amounts to a fancy shopping cart wizard for a
scientific instrument using VB.NET. We are having some disturbing
phenomena relating to dropdown controls.
On my system and...
|
by: sujitksharma |
last post by:
Hi,
Following is a simple html which has a table with one "<tr>" and two "<td>". Both the "<td>"s have a fixed width of "150px". In one "<td>" I have put some long text, while in the second "<td>"...
|
by: bill.wu |
last post by:
the tutor list has been strangely silent for a few days. Anyone know
what has happened? why?
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |