1. 程式人生 > >呼叫G2O,編譯的時候提示:error C1083: 無法開啟包括檔案: “sys/time.h”

呼叫G2O,編譯的時候提示:error C1083: 無法開啟包括檔案: “sys/time.h”

問題

在引用了G2O的專案中,編譯時提示

錯誤	81	error C1083: 無法開啟包括檔案: “sys/time.h”: No such file or directory	c:\program files\g2o\include\g2o\stuff\timeutil.h	33	1	G2OTest
檢視對應的程式碼位於C:\Program Files\g2o\include\g2o\stuff\timeutil.h中第30行
#ifdef _WINDOWS
#include <time.h>
#else
#include <sys/time.h>
#endif
其中
_WINDOWS
是沒有定義的,導致執行了錯誤了include語句。

解決方法:

1、屬性 -> 配置屬性 -> C/C++ -> 前處理器 -> 前處理器定義


2、新增_WINDOWS