Thread: Meaning of an error

  1. #1
    Registered User
    Join Date
    May 2005
    Location
    Toronto, Canada
    Posts
    257

    Meaning of an error

    What does this error mean:
    Code:
    main.obj : error LNK2001: unresolved external symbol "int __cdecl GetWord(struct _iobuf *,char *)" (?GetWord@@YAHPAU_iobuf@@PAD@Z)
    All the function files are included in the project and are in the header file.

  2. #2
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    It means that the linker couldn't find the definition of that function, GetWord, with those parameters. If you wrote that function, make sure the function is defined and make sure that the definition is in a source file compiled with your project. Also make sure that the parameters of the definition match the parameters of the declaration for all overloads of the function. If it is a library function, make sure the library is linked to your project.

  3. #3
    Registered User
    Join Date
    May 2005
    Location
    Toronto, Canada
    Posts
    257
    It is all fine, or seems to be, I chekced all of it. I'm doing the exact same thing in another 2 projects, they work.

    here's the Header file:
    Code:
    # include <stdio.h>
    # include <string.h>
    # include <math.h>
    # include <stdlib.h>
    # include <ctype.h>
    
    struct DataLine
    {
    	char Param[20];
    	int Label, SFactor, SigBits;
    	int Bit30, Bit31, Max, Min;
    } ;
    
    
    #ifndef EDFParse3_H 
    #define EDFParse3_H 
    
    
    int FindWord(FILE *inp,char KeyWord[25]);
    int GetWord(FILE *inp, char *string);
    void SkipWS(FILE *inp);
            //void print_Struct( struct DataLine sec );
            //int ReadSection(FILE * inp, struct DataLine Sec[], int nExpected);
    FILE* OpenFile();
    
    
    #endif
    Last edited by earth_angel; 06-24-2005 at 01:40 PM.

  4. #4
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    The problem is that the function definition can't be found. That would normally be in the cpp file. Show that.

  5. #5
    Registered User
    Join Date
    Apr 2003
    Posts
    2,663
    ...and?

  6. #6
    Registered User
    Join Date
    May 2005
    Location
    Toronto, Canada
    Posts
    257
    here's one of the functions:

    Code:
    int GetWord(FILE *inp, char *string)
    {
    	int i=0;
    	int ch;	
    	
    	do
    	{
    		ch = fgetc ( inp );
    	
    		if (ch == ' ')     //White space
    			break; 
    
    		if (ch == EOF)
    		                   // eof reached
    		    break; 
    		if (ch == '\n')
    			break;         // end of line
    		
    		string[i] = ch;
    		i++;
    	}
    	while (i<25);
    
    	string[i] = '\0';
    
    	return 1;
    }
    and it's included in the project under sourse files, GetWord.cpp.

    For some reason it compiles fine if I save all sourse files as C files not C++.
    Last edited by earth_angel; 06-24-2005 at 02:03 PM. Reason: new function to be displayed

  7. #7
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    The linker error you posted is for the GetWord function. So if you are only going to show one function, that would be a good one to pick.

  8. #8
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,005
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. Testing some code, lots of errors...
    By Sparrowhawk in forum C Programming
    Replies: 48
    Last Post: 12-15-2008, 04:09 AM
  3. Post...
    By maxorator in forum C++ Programming
    Replies: 12
    Last Post: 10-11-2005, 08:39 AM
  4. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  5. pointer to array of objects of struct
    By undisputed007 in forum C++ Programming
    Replies: 12
    Last Post: 03-02-2004, 04:49 AM