INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

gcc error

gcc error

(OP)
Hi Everyone,

    I am using gcc to compile a simple .cpp program .I have gcc version 2.95.3 on SunOS 5.8.When i am using gcc it gives the following errors as pasted below.
My code works fine when i am using g++ as follows g++ TestMem.cpp or g++ TestMem.cc but it does not work for the following gcc TestMem.cc or gcc TestMem.cpp . Do i have to download a patch for gcc? Your feedback will be appreciated.

Thanks in advance.
regards,
-VN

ERRORS:
solaris1$ gcc TestMem.cpp
Undefined                       first referenced
 symbol                             in file
cout                                /var/tmp/ccuOVOvP.o
ostream::operator<<(ostream &(*)(ostream &))/var/tmp/ccuOVOvP.o
endl(ostream &)                     /var/tmp/ccuOVOvP.o
ostream::operator<<(char const *)   /var/tmp/ccuOVOvP.o
ld: fatal: Symbol referencing errors. No output written to a.out
collect2: ld returned 1 exit status
solaris1$

RE: gcc error

(OP)
Hello Everyone,
   
   I found out the answer for this question. When i was using the gcc compiler it was linking with the C libraries and so was not able to find "cout". Where as, when i was using g++ it was automatically linking with the C++ libraries. So basically when we use the gcc compiler to compile C++ code we need to tell the linker which library to take.
I used the following for my code and everything worked fine.
solaris1$ gcc TestMem.cc -L/usr/local/include/g++-3 -lstdc++
solaris1$ a.out

Regards,
-VN

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close