2016-09-27 88 views
0

我下載了所謂的Miguel_2D_unwrapper.cpp一個C++文件在: http://read.pudn.com/downloads199/sourcecode/graph/texture_mapping/938065/phase%20unwraping/Miguel_2D_unwrapper.cpp__.htmMatlab的符合C++文件錯誤:致命錯誤C1083:無法打開包含文件:「stdafx.h中」

當我嘗試使用Matlab的C++代碼(只需鍵入:MEX Miguel_2D_unwrapper_with_mask.cpp在Matlab命令),一個錯誤彈出:

fatal error C1083: Cannot open include file: 'stdafx.h': No such file or directory.

當我嘗試用//#評論的 「stdafx.h中」 包括 「stdafx.h中」,另一個錯誤啪啪up:

Error using mex LINK : error LNK2001: unresolved external symbol mexFunction
Miguel_2D_unwrapper.lib : fatal error LNK1120: 1 unresolved externals.

我使用Microsoft Windows SDK 7.1(C++)與用於C++語言編譯的「Microsoft Visual C++ 2015 Professional」結合使用。

有人可以讓我解決這個問題嗎?謝謝!

+1

也許你應該下載整個RAR檔案,而不僅僅是單個文件。 –

+1

此外,雖然您可能能夠使用MATLAB準備數據,然後通過該例程運行該文件,但不會將該文件設置爲MEX功能執行。 –

+0

我已經在Matlab中的當前文件夾中擁有整個存檔。我按照該算法的作者之一的建議,在matlab中運行C++代碼。代碼應該能夠在Matlab中成功編譯 – jingweimo

回答

1

您的.cpp文件使用多個頭文件,stdafx.h就是其中之一。該頭文件通常由Visual Studio IDE創建,不屬於標準庫和Windows SDK的一部分。你可以嘗試從您的CPP文件中刪除以下行:

#include "stdafx.h" 

,並與實際的stdafx.h內容,在大多數情況下,是替代它:

#pragma once 

#include "targetver.h" 

#include <stdio.h> 
#include <tchar.h> 

另一種選擇是創建一個stdafx .h請自行填寫文件,填寫上述內容並將其放在cpp文件所在的文件夾中。

+0

我曾嘗試通過(//#include「stdafx.h」)評論#include「stdafx.h」,但這會導致另一個錯誤:使用mex的錯誤 LINK:錯誤LNK2001 :無法解析的外部符號mexFunction Miguel_2D_unwrapper.lib:致命錯誤LNK1120:1個未解析的外部事件。我對C++不是很熟悉。最好的是在matlab中執行代碼。 – jingweimo

+0

@jingweimo答案解決了如何解決'無法打開包含文件:'stdafx.h''錯誤的問題。至於其他錯誤,你應該問一個單獨的問題。 – 2016-09-28 10:24:58

相關問題