0
votes
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();
}

These are two projects in one solution. Additionally i've added path of prj1 as additional include siarecory of prj2. On Buliding the solution, while linking, i'm getting following error :

1>Linking... 1>main2.obj : error LNK2019: unresolved external symbol "char * __cdecl display(void)" (?display@@YAPADXZ) referenced in function _main 1>C:\Documents and Settings\469515\My Documents\NFC HAL SDK v2.2\Nfc\comps\phHalNfc\EX1\prj1\Debug\prj2.exe : fatal error LNK1120: 1 unresolved externals

Can anybody help me out with that:

1

1 Answers

1
votes

Remove this line:

#ifdef _cplusplus
extern "C" {
#endif

From CPP file.

OR add the same line to header file.