Results 1 to 3 of 3

Thread: [resolved] VC++ 2005 Link errors with win32api code

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2000
    Location
    Birmingham, AL
    Posts
    1,276

    Resolved [resolved] VC++ 2005 Link errors with win32api code

    I'm experimenting with a managed VC++ 2005 app to call win32api. I put #include <windows.h> in stdafx.h and call the api function from the global namespace:
    Code:
    HWND hWnd = (HWND)this->Handle.ToPointer();
    
    ::MessageBox(hWnd, L"testing win32api", L"", 0);
    The link errors are:
    Code:
    Error	1	error LNK2028: unresolved token (0A00000E) "extern "C" int __stdcall MessageBoxW(struct HWND__ *,wchar_t const *,wchar_t const *,unsigned int)" (?MessageBoxW@@$$J216YGHPAUHWND__@@PB_W1I@Z) referenced in function "extern "C" int __clrcall MessageBox(struct HWND__ *,wchar_t const *,wchar_t const *,unsigned int)" (?MessageBox@@$$J0YMHPAUHWND__@@PB_W1I@Z)	MyApp.obj	
    
    Error	2	error LNK2019: unresolved external symbol "extern "C" int __stdcall MessageBoxW(struct HWND__ *,wchar_t const *,wchar_t const *,unsigned int)" (?MessageBoxW@@$$J216YGHPAUHWND__@@PB_W1I@Z) referenced in function "extern "C" int __clrcall MessageBox(struct HWND__ *,wchar_t const *,wchar_t const *,unsigned int)" (?MessageBox@@$$J0YMHPAUHWND__@@PB_W1I@Z)	MyApp.obj
    I'm sure it's something simple I'm overlooking.
    Last edited by wey97; Oct 3rd, 2006 at 07:39 AM.

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: VC++ 2005 Link errors with win32api code

    Seems like you're not linking against the Windows libraries. Add user32.lib to your library list.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2000
    Location
    Birmingham, AL
    Posts
    1,276

    Re: VC++ 2005 Link errors with win32api code

    Quote Originally Posted by CornedBee
    Seems like you're not linking against the Windows libraries. Add user32.lib to your library list.
    Additional Dependencies in the Linker was set to "$(NOINHERIT)"

    Checking 'Inherit from parent or project defaults' imports all of the default Windows libs.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width