supersuny2k
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_Even t@@PATPSH_ EventIncom ing@@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_Co nnection@@ W4PSH_Acti on@@TPSH_M essageInco ming@@PAX@ Z) referenced in function _main
QuoteHandlers.obj : error LNK2019: unresolved external symbol "void __cdecl UpdateTSFinvisionInfo(char *,class std::basic_string<char,str uct std::char_traits<char>,cla ss std::allocator<char> >,double,double)" (?UpdateTSFinvisionInfo@@Y AXPADV?$ba sic_string @DU?$char_ traits@D@s td@@V?$all ocator@D@2 @@std@@NN@ Z) referenced in function "void __cdecl FinvisionRecordHandle(stru ct PSH_SupplyObject *,void *)" (?FinvisionRecordHandle@@Y AXPAUPSH_S upplyObjec t@@PAX@Z)
C:\SourceSafe Projects\Market View\BBTV2\Debug\BBTV2.exe : fatal error LNK1120: 3 unresolved externals
Many Thanks,
Josh
Generating Code...
Linking...
mkMainC.obj : error LNK2019: unresolved external symbol "void __cdecl mainEvent(enum PSH_Event,union PSH_EventIncoming *,void *)" (?mainEvent@@YAXW4PSH_Even
mkMainC.obj : error LNK2019: unresolved external symbol "long __cdecl listHandle(struct PSH_Connection *,enum PSH_Action,union PSH_MessageIncoming,void *)" (?listHandle@@YAJPAUPSH_Co
QuoteHandlers.obj : error LNK2019: unresolved external symbol "void __cdecl UpdateTSFinvisionInfo(char
C:\SourceSafe Projects\Market View\BBTV2\Debug\BBTV2.exe
Many Thanks,
Josh
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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 ;)
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
.
>> 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 ?
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 ?
ASKER
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
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.
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.
ASKER
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
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!
ASKER
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
"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.