Thread: gotta love linker errors

  1. #1
    Registered User
    Join Date
    Jul 2004
    Posts
    61

    gotta love linker errors

    I get the following linker errors:

    Code:
        umneg.obj : error LNK2001: unresolved external symbol "int __cdecl num_neg(int * const,int)" (?num_neg@@YAHQAHH@Z)
    Debug/numneg.exe : fatal error LNK1120: 1 unresolved externals
    Any help would be greatly appreciated.

    Code:
    #include <iostream>
    using namespace std;
    int num_neg(int a[],int size );//prototype
    int main()
    {
    
     
     const int size=10;
    int a[size]={1,2,3,-4,5,-6,7,8,9,10};
    
    
     cout<<num_neg(a,size);//call
    
      return 0;
    
    }
    
    
     int pos(int a[], int size) //return number of negative values in array
     {
        int n=0;
    	 for(int i=0;i<size;i++){
             if((a[i]<0))
    	         n++;
    	  
    	                                   }
    	 
    	    return n;
    
    
    	 
    		   
    		
     }

  2. #2
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    Just so you know, your function names don't match.

  3. #3
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    The linker error is saying that you are calling a function named num_neg() but it can not find where that function is defined.

  4. #4
    Registered User
    Join Date
    Jul 2004
    Posts
    61
    Hmmmm ok.....6 hours of working on code is really taking a toll on me....LOL. Thanks sean.

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, 12:56 PM
  2. Linker errors with 2005 Express
    By thetinman in forum Windows Programming
    Replies: 4
    Last Post: 12-30-2006, 09:04 AM
  3. Dev C++/mySQL linker errors
    By WDT in forum C Programming
    Replies: 2
    Last Post: 03-30-2004, 03:40 PM
  4. gotta love those jaggies....*cough*
    By jverkoey in forum Game Programming
    Replies: 9
    Last Post: 04-22-2003, 08:44 PM
  5. Linker errors
    By Unregistered in forum C++ Programming
    Replies: 4
    Last Post: 06-20-2002, 10:55 PM