2016-07-12 6 views
0

C++で関数を使用してDLLを作成する必要があります。 DLLを選択してプロジェクトを作成し、最初に自動的に作成されたデフォルトのサンプルサンプルを使用しました。Visual StudioでDLLをコンパイルする際のエラー

私は2つのファイル、編集:プロジェクトを構築しながら、私はエラーC2061を持って

OCR2.h

using namespace std; 


#ifdef OCR2_EXPORTS 
#define OCR2_API __declspec(dllexport) 
#else 
#define OCR2_API __declspec(dllimport) 
#endif 

// Cette classe est exportée de OCR2.dll 
class OCR2_API COCR2 { 
public: 
    COCR2(void); 
    // TODO: ajoutez ici vos méthodes. 
}; 

extern OCR2_API int nOCR2; 

OCR2_API int fnOCR2(void); 
OCR2_API bool comparer(bool latin, string lienInitial, string lienStr1, string lienStr2, string lienStr3); 

そして、私のOCR2.cpp

#include <sstream> 
#include <string> 
#include <iostream> 
#include <cstring> 
#include <fstream> 

using namespace std; 
// Il s'agit d'un exemple de variable exportée 
OCR2_API int nOCR2=0; 

// Il s'agit d'un exemple de fonction exportée. 
OCR2_API int fnOCR2(void) 
{ 
    return 42; 
} 


OCR2_API bool comparer(bool latin, string lienInitial, string lienStr1, string lienStr2, string lienStr3) 
{ 
// my function 
} 

COCR2::COCR2() 
{ 
    return; 
} 

をビジュアルスタジオ2015(説明付き):

を特定できる '文字列':「構文エラーを意味し、 "erreurデsyntaxe identificateur '文字列'"

DLLを作成するために使用した方法が正しいかどうかを知りたいのですが、はいの場合、なぜこのエラーが発生しますか?

あなたは

+0

#includeのリストに '#include" ocr2.h "'を追加してください。 –

+1

'OCR2.cpp'は' OCR2.h'を含んでいません。ヘッダーには 'std :: string'は含まれていません。 'using namespace std;'は悪い習慣です。 –

答えて

0

あなたのソースファイルへのあなたのヘッダファイルと
の#include "OCR2.h" に
の#include < string>を追加する必要がありますありがとうございました。

関連する問題