我正在尝试编译一个相对简单的从网络上获取的应用程序。
运行make时,我遇到了以下错误:
In file included from main.cpp:2:0:
os.h: In function ‘void myOpenDir(const char*)’:
os.h:13:16: error: ‘chdir’ was not declared in this scope
文件os.h的内容如下:
#ifndef OS_H
#define OS_H
#if defined(__GNUG__)
#define INT64 long long
#define UINT64 unsigned long long
#include <dirent.h>
#define SPRTR '/'
void myOpenDir(const char* dirpath)
{
chdir(dirpath);
}
#elif defined(_MSC_VER)
#define INT64 __int64
#define UINT64 unsigned __int64
#include <direct.h>
#define SPRTR '\\'
void myOpenDir(const char* dirpath)
{
_chdir(dirpath);
}
#else
#error "Platform not supported. Need to update source code"
#endif
#endif
有人知道为什么它无法编译吗?
我也使用了g++编译器,通过g++-4.7.real -c main.cpp,但到目前为止没有成功。
g++-4.7 -Wall -g
进行编译的习惯。 - Basile Starynkevitch