Showing posts with label Win32 Console Application. Show all posts
Showing posts with label Win32 Console Application. Show all posts

Tuesday, September 3, 2013

Visual Studio CPP Building Error: " error LNK2028: unresolved token (0A000102) "extern "C" int __stdcall "

If you face the same problem with me about this error, please try this ones.
I'm using Visual Studio Ultimate 2012 with C++ CLR Console Application.

This is the Compiler error message:

1>------ Build started: Project: ConsoleApplication1, Configuration: Debug Win32 ------
1>ConsoleApplication1.obj : error LNK2028: unresolved token (0A000102) "extern "C" int __stdcall McOpenDriver(char const *)" (?McOpenDriver@@$$J14YGHPBD@Z) referenced in function "int __cdecl main(int,char * * const)" (?main@@$$HYAHHQAPAD@Z)
1>ConsoleApplication1.obj : error LNK2019: unresolved external symbol "extern "C" int __stdcall McOpenDriver(char const *)" (?McOpenDriver@@$$J14YGHPBD@Z) referenced in function "int __cdecl main(int,char * * const)" (?main@@$$HYAHHQAPAD@Z)
1>c:\users\laboptics\documents\visual studio 2012\Projects\ConsoleApplication1\Debug\ConsoleApplication1.exe : fatal error LNK1120: 2 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
========== Deploy: 0 succeeded, 0 failed, 0 skipped ==========







This error indicated that the compiler need to linked the program with the necessary windows library. The program cannot execute "extern "C" int __stdcall McOpenDriver(char const *)" because this is an extern C command and need to be linked with the imported library, in this case I'll using "multicam.lib" library.

Select from the menu:  "Project -> Properties " ( Alt+F7 )

In the property pages in the tree on the left select: Configuration Properties -> Linker -> Input

In the right hand pane check:  Additional Dependencies























It should contain these library already:
  • kernel32.lib 
  • user32.lib
  • gdi32.lib
  • winspool.lib
  • comdlg32.lib
  • advapi32.lib
  • shell32.lib
  • ole32.lib
  • oleaut32.lib
  • uuid.lib
  • odbc32.lib
  • odbccp32.lib
but  "int __stdcall McOpenDriver(char const *) " requires multicam.lib.


Now fill the " Additional Dependencies" tab with the required library:
        multicam.lib; %(AdditionalDependencies)