2011-07-27 12 views
0
enter code here 
//Prj1 

//main1.cpp 

#include "stdafx.h" 
#include <iostream> 
#include <conio.h> 
#include "head1.h" 

using namespace std; 

void main() 
{ 
cout<<display(); 
cout<<"welcome"; 
_getch(); 
} 


//head1.h 
char* display(void); 

//head1.cpp 

#include "stdafx.h" 
#ifdef _cplusplus 
extern "C" { 
#endif 

char* display(void) 
{ 
return("head1 functuion called\n"); 
} 

#ifdef _cplusplus 
} 
#endif 



//prj2 
enter code here 
//main2.cpp 

#include "stdafx.h" 
#include <iostream> 
#include <conio.h> 
#include "head1.h" 

using namespace std; 

void main() 
{ 
cout<<display(); 
cout<<"welcome prj 2"; 
getch(); 
} 

これは1つのソリューションで2つのプロジェクトです。また、prj1のパスをprj2の追加siarecoryとして追加しました。リンク中にソリューションをビルドするとエラーが発生する:未解決の外部シンボルプログラムをリンク中にエラーが発生しました:

1>リンク... > main2.obj:エラーLNK2019:未解決の外部シンボル "char * __cdecl display(void)"(?display @@ YAPADXZ) 1> C:¥Documents and Settings¥469515¥My Documents¥NFC HAL SDK v2.2¥Nfc¥comps¥phHalNfc¥EX1¥prj1¥Debug¥prj2.exe:致命的なエラーLNK1120: 1つの未解決の外部

誰もがそれで私を助けることができる:

答えて

1

この行を削除します。

#ifdef _cplusplus 
extern "C" { 
#endif 

CPPファイルから。

または同じ行をヘッダファイルに追加します。

+0

でも同じ問題が存在します。 – Durgesh

+0

exlactlyあなたは何をしましたか?両方の場所から 'extern" C "'を削除するか、両方の場所に追加しました。すべてを再構築してみてください。 – Ajay

+0

私はそれを削除し、すべてを再構築しました。それは誤りを示した。次に私は再び両方の場所に追加し、ソリューションを再構築しました。 – Durgesh