Error LNK2028 unresolved token / LNK2019 Unrevolved external symbol

Tech-Archive recommends: Speed Up your PC by fixing your registry



I'm trying to understand an error when compiling a C++ form project :

Error LNK2028 unresolved token...
Error LNK2019 Unrevolved external symbol ...


Here is how to understand/reproduce my problem with VS2005 :
1- Create a C++ win32 console application with the defaults parameters
2- In the header section add #include <windows.h> and add the
following code in the main() :
HWND hNotepad;
hNotepad = FindWindow(L"Notepad", 0);
3- Compile the console application
-> It compile without any error

4- Now Create a C+ Form application with the default parameters when
creating the new project.
5- In the header section add #include <windows.h> and add the
following code in the main() or somewhere else :
HWND hNotepad;
hNotepad = FindWindow(L"Notepad", 0);

** Now the compiler return errors :

Error error LNK2028: unresolved token (0A00000C) "extern "C" struct
HWND__ * __stdcall FindWindowW(wchar_t const *,wchar_t const *)" (?
FindWindowW@@$$J18YGPAUHWND__@@PB_W0@Z) referenced in function "int
__clrcall main(cli::array<class System::String ^ >^)" (?main@@$$HYMHP
$01AP$AAVString@System@@@Z) AutomationWinForm.obj

Error error LNK2019: unresolved external symbol "extern "C" struct
HWND__ * __stdcall FindWindowW(wchar_t const *,wchar_t const *)" (?
FindWindowW@@$$J18YGPAUHWND__@@PB_W0@Z) referenced in function "int
__clrcall main(cli::array<class System::String ^ >^)" (?main@@$$HYMHP
$01AP$AAVString@System@@@Z) AutomationWinForm.obj
Why?? How can this can be fixed?

Thanks again!

.



Relevant Pages

  • Re: CheckedChanged Event on Radio control is not compiling
    ... I have no idea the OP get that compiling error. ... One could verify that by create a new win form project, so to just rule out if it is because of some weird project/code file corruption. ... I have the system.windows.forms assembly included in my references and this app used to compile just fine in VS2005. ... Is it possible that the RadioButton control used is from the System.Windows.Controls namespace. ...
    (microsoft.public.vstudio.development)
  • Re: CheckedChanged Event on Radio control is not compiling
    ... I have no idea the OP get that compiling error. ... One could verify that by create a new win form project, so to just rule out if it is because of some weird project/code file corruption. ... 'System.Windows.Forms.RadioButton' does not contain a definition for 'CheckedChanged' and no extension method 'CheckedChanged' accepting a first argument of type 'System.Windows.Forms.RadioButton' could be found (are you missing a using directive or an assembly reference?) ... I have the system.windows.forms assembly included in my references and this app used to compile just fine in VS2005. ...
    (microsoft.public.vstudio.development)
  • Re: UserControl events fail to get raised in the form
    ... If I compile B, then C (which is out of dep sequence) ... > have only my form project opened, ... > run in the form at the point the user control should raise ...
    (microsoft.public.vb.bugs)
  • Re: C++0x: Scaling up on weak foundations?
    ... I think backward compatibility is a weak foundation to build upon and the ... Well I'm designing my own language. ... You should prefer to make it not compile instead of fail ... For this purpose there are standard header ...
    (comp.lang.misc)
  • Re: Forth Frustrations
    ... Traditional Forth compiles the header at the beginning and unsmudges ... data on the control-flow stack you have a colon-sys. ... compile a previous word with the same name, ... switch a compiler back and forth, ...
    (comp.lang.forth)