What does this error mean:
All the function files are included in the project and are in the header file.Code:main.obj : error LNK2001: unresolved external symbol "int __cdecl GetWord(struct _iobuf *,char *)" (?GetWord@@YAHPAU_iobuf@@PAD@Z)
What does this error mean:
All the function files are included in the project and are in the header file.Code:main.obj : error LNK2001: unresolved external symbol "int __cdecl GetWord(struct _iobuf *,char *)" (?GetWord@@YAHPAU_iobuf@@PAD@Z)
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.
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.
The problem is that the function definition can't be found. That would normally be in the cpp file. Show that.
...and?
here's one of the functions:
and it's included in the project under sourse files, GetWord.cpp.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; }
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
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.
http://www.parashift.com/c++-faq-lit...c-and-cpp.html
Look up the extern "C" stuff.
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.*