‘strcasecmp’ was not declared in this scope
I am trying to build a source code called lipiTk
I have lots of errors like this:
Documents/lipi/lipi/src/reco/shaperec/activedtw/ActiveDTWShapeRecog开发者_高级运维nizer.cpp:1222:78:
error: ‘strcasecmp’ was not declared in this scope
What should I do, there is too many cpp file in the code that gives similar errors. I do not think i can test with writing include string.h into every cpp file that gives error, might the problem be about my compiler?
I am on Ubuntu and GCC is 4.5.
My sw configuration is upper than lipitk needs as I read in manual.
I think that it may be doing
#include <string>
The errors should be fixed if you change it to
#include <strings.h>
I'm gonna guess here. "strcasecmp" is not a standard library function, however, it name follows the convention of library function, so I imagine that lipiTk was originally written using some compiler which added a bunch of non-standard extensions to it's run-time library (and declared them in the standard header files)
So, I'd guess that the problem is that your compiler has a different set of library extension --or maybe similar ones with different names -- Google tells me that "strcasecmp" does a case-insensitive string comparison, which many compilers call "stricmp" or "strcmpi" or "_stricmp". Figure out which name your compiler uses then add a #define at the top of the source file:
#define strcasecmp _stricmp
As I mentioned in comments earlier, strcasecmp is not in the C or C++ standard. However, it's defined by POSIX.1-2001 and 4.4BSD.
Assuming your system is POSIX or BSD compliant, you must include the correct header:
#include <strings.h>
You need to include the file for the function to be available in the scope - how in the world did you get so much code without the correct inclusions in it (I'm assuming its alot if you can't put that in every file once).
PS: Are you sure your ubuntu version has that function available in string.h? type:
man strcasecmp
into a bash terminal to see if its there and how to access it. That might help you find where it is at least assuming your code's right and the includes are just off from porting or something like that.
精彩评论