Link to home
Start Free TrialLog in
Avatar of supersuny2k
supersuny2kFlag for Netherlands

asked on

Help: error LNK2019: unresolved external symbol

I had the program in a single cpp file and have moved at the functions to seperate cpp's. Since doing that I received the following error when compiling the code. Any ideas on how to resolve that?

Generating Code...
Linking...
mkMainC.obj : error LNK2019: unresolved external symbol "void __cdecl mainEvent(enum PSH_Event,union PSH_EventIncoming *,void *)" (?mainEvent@@YAXW4PSH_Event@@PATPSH_EventIncoming@@PAX@Z) referenced in function _main
mkMainC.obj : error LNK2019: unresolved external symbol "long __cdecl listHandle(struct PSH_Connection *,enum PSH_Action,union PSH_MessageIncoming,void *)" (?listHandle@@YAJPAUPSH_Connection@@W4PSH_Action@@TPSH_MessageIncoming@@PAX@Z) referenced in function _main
QuoteHandlers.obj : error LNK2019: unresolved external symbol "void __cdecl UpdateTSFinvisionInfo(char *,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,double,double)" (?UpdateTSFinvisionInfo@@YAXPADV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@NN@Z) referenced in function "void __cdecl FinvisionRecordHandle(struct PSH_SupplyObject *,void *)" (?FinvisionRecordHandle@@YAXPAUPSH_SupplyObject@@PAX@Z)
C:\SourceSafe Projects\Market View\BBTV2\Debug\BBTV2.exe : fatal error LNK1120: 3 unresolved externals

Many Thanks,

Josh
ASKER CERTIFIED SOLUTION
Avatar of Infinity08
Infinity08
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
When you moved the functions to new files did you ensure you added these files to the project so they get compiled and the resultant translation units get linked into the final binary?
al lfiles -> all files of course ;)
Avatar of supersuny2k

ASKER

Hi, Yes all files are under one project in VS 2005 and I have included all the header files.

Interestingly, if I remove the calls in the main() and one of the function which are listed in the error, the project complies

.
>> Interestingly, if I remove the calls in the main() and one of the function which are listed in the error, the project complies

That's normal ;) If you removed the unresolved symbol, the linker doesn't have to look for it ... So, it doesn't throw the error either.

Can you show all your files ?
Unfortunately, I can't but I have noticed something, if I change the functions or handlers to static if resolves the issue but cause other functions to have the same error.

Regards,

Josh
>> Unfortunately, I can't

Why is that ?

Can you at least post the relevant parts of the code. The part of the main where the function is called, the part of the header file where the function is declared, the part of the .cpp file where the function is defined, as well as the header include at the top of the main.cpp file.
Hi Infinity, I have fixed it I removed static from all the function names and it has worked....
We could have told you that if we would have known what code you used ;) We're not clairvoyant heh.
Can you still post the code I asked for to verify that the solution is good ?
>> I removed static from all the function names and it has worked
Note: The use of static in this context is considered deprecated, prefer to use unnamed namespace.
http://msdn2.microsoft.com/en-us/library/yct4x9k5.aspx
The selected answer doesn't answer the question!
Ooops... sorry select the wrong answer... my apologies - suppose to choose

"Did you add al lfiles to one project, and then rebuild the project ?

Did you include the correct header files ?"

as I was missing my header files in the end

Regards,
Josh
Cheers KB.