Thread: linker error:(

  1. #1
    Registered User
    Join Date
    Feb 2008
    Posts
    1

    Unhappy linker error:(

    Code:
    hello!..i am new to c++ programming...I hav turbo c++ installed on my comp...whenever i include <iostream.h> i get linker error...all c programs are working...
    i jus did a "hello world" program and saved it as v.cpp
    #include<iostream.h>
    main()
    {
    cout<<"hello world";
    }
    
    linker error:undefined symbol _cout in the module v.cpp
    linker error:undefined symbol ostream::operator<<(long) in module v.cpp
    
    
    can any 1 please tel me what i should do?..
    i actually copied the turbo c++ compiler from my friends comp....all c++ programs are working on her comp but not on mine....but c progs are working....
    
    
    thanx in advance...

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Your test code is incorrect. I suggest testing with:
    Code:
    #include <iostream>
    int main()
    {
        std::cout << "hello world\n";
    }
    i actually copied the turbo c++ compiler from my friends comp
    That might be a bad idea, it depends on how the compiler is supposed to be installed. Especially if this is an old version of the compiler, you might want to just change to a newer and more standard conformant compiler such as the MinGW port of g++ or the compiler that comes with Microsoft Visual Studio 2005 or 2008 Express.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    main()
    Is not valid in C++. All functions must return a type.
    I would follow on laserlight's advice and get a better IDE. Here's some free ones: http://cpwiki.sf.net/Integrated_Development_Environment

    You should also include <iostream>, not <iostream.h> and use std::cout.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Errors including <windows.h>
    By jw232 in forum Windows Programming
    Replies: 4
    Last Post: 07-29-2008, 01:29 PM
  2. Crazy errors caused by class, never seen before..
    By Shamino in forum C++ Programming
    Replies: 2
    Last Post: 06-10-2007, 11:54 AM
  3. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 10:03 AM
  4. pointer to array of objects of struct
    By undisputed007 in forum C++ Programming
    Replies: 12
    Last Post: 03-02-2004, 04:49 AM
  5. Linking error
    By DockyD in forum C++ Programming
    Replies: 10
    Last Post: 01-20-2003, 05:27 AM