Linker Errors...

This is a discussion on Linker Errors... within the C Programming forums, part of the General Programming Boards category; Hi, I am trying out some simple stuff on C... I am trying to run them in MS Visual studio ...

  1. #1
    Registered User
    Join Date
    Oct 2005
    Posts
    7

    Linker Errors...

    Hi,

    I am trying out some simple stuff on C... I am trying to run them in MS Visual studio 6.0 on Windows... For every small function that I add to my program, I get a linker error (and not a compilation error...)


    Eg: For the part of the code below:

    Code:
    #include<process.h> 
    #include<stdlib.h> 
    #include<stdio.h> 
    #include <time.h> 
    int main() { 
    //.... some code or nothing 
    sleep( 1000 ); 
    printf("\n %s",getdate()); 
    //.... some code or nothing 
    }

    I get the errors:

    Code:
    Linking... 
    Thread_Run_Tests.obj : error LNK2001: unresolved external symbol _sleep 
    Thread_Run_Tests.obj : error LNK2001: unresolved external symbol _getdate 
    Debug/Thread_Run_Tests.exe : fatal error LNK1120: 2 unresolved externals 
    Error executing link.exe.

    Please tell me if I have missed out in specifying some compiler/linker option in visual Studio... Or else, if you could tell me how to compile with options on cmd prompt, even that is fine!

    Thanks a lot guys,
    -manu

  2. #2
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,264
    Try including windows.h, and using Sleep(1000) instead (notice the capital s). Also, I think you need to read up on how getdate() works.

  3. #3
    Registered User
    Join Date
    Oct 2005
    Posts
    7
    yeah... I tried Sleep() and included <windows.h>... There was no change in the results though

  4. #4
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,048
    I think getdate() is a POSIX function that doesn't work in MSVC.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  5. #5
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,048
    From google I found this page, which suggests getdate() is POSIX.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Linker errors
    By jw232 in forum C++ Programming
    Replies: 3
    Last Post: 06-12-2009, 01:56 PM
  2. Linker errors in VC++ 2005
    By C+/- in forum C++ Programming
    Replies: 0
    Last Post: 05-18-2007, 08:42 AM
  3. Sneaky little linker errors...
    By Tozar in forum C++ Programming
    Replies: 8
    Last Post: 10-25-2006, 06:40 AM
  4. Linker errors when compiling
    By The Wazaa in forum C++ Programming
    Replies: 4
    Last Post: 10-07-2006, 01:55 PM
  5. Linker errors with Visual C++
    By codegirl in forum C++ Programming
    Replies: 4
    Last Post: 09-11-2003, 10:20 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21