none
Trying to compile program --> Bitmap.obj : error LNK2019

    Question

  • Hello people. I am new here and also new to Windows programming and that's why I bought a book called Beginning Game Programming  by Michael Morrison.

    Everything went fine until I changed to 64-bit Windows 7 and upgraded my Visual c++ Express 2008 to 2010 and then installed the Windows 7 SDK. When I try to compile a game called "Brainiac" that I created using the book, I get this weird error saying:

     

    1>------ Build started: Project: Chapter 6, Configuration: Debug Win32 ------
    1>Bitmap.obj : error LNK2019: unresolved external symbol __imp__TransparentBlt@44 referenced in function "public: void __thiscall Bitmap::Draw(struct HDC__ *,int,int,int,unsigned long)" (?Draw@Bitmap@@QAEXPAUHDC__@@HHHK@Z)
    1>C:\Users\Ville\Documents\Visual Studio 2010\Projects\Chapter 6\Debug\Chapter 6.exe : fatal error LNK1120: 1 unresolved externals
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

     

    It first looked very easy to solve but I've actually struggled with it for few days already. I have read some threads where people seem to have the exactly same problem with no results. I have already this in my Linker additional libraries:  msimg32.lib;user32.lib;gdi32.lib. The weirdest part of this is that when I compile the project that I have on my book's CD as example source, it works just fine...   ??  

     

    I really hope someone knows how to fix this because I can't really progress at all with my studies right now.

    Thanks.

    Friday, July 02, 2010 1:53 AM

Answers

  • That is not the correct setting. As indicated in the link I gave, you need to be setting the Linker -> Input -> Additional Dependencies property, not the Linker -> General -> Additional Library Directories property.
    • Marked as answer by Vilde Friday, July 02, 2010 3:16 AM
    Friday, July 02, 2010 3:13 AM

All replies

  • Add /VERBOSE:LIB to your linker command line and post the output here.
    Friday, July 02, 2010 2:40 AM
  • I hope I didn't mess up or anything... Here's what it says now:

    1>------ Build started: Project: Chapter 6, Configuration: Debug Win32 ------
    1> 
    1>  Searching libraries
    1>      Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib\kernel32.lib:
    1>      Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib\user32.lib:
    1>      Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib\gdi32.lib:
    1>      Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib\winspool.lib:
    1>      Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib\comdlg32.lib:
    1>      Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib\advapi32.lib:
    1>      Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib\shell32.lib:
    1>      Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib\ole32.lib:
    1>      Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib\oleaut32.lib:
    1>      Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib\uuid.lib:
    1>      Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib\odbc32.lib:
    1>      Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib\odbccp32.lib:
    1>      Searching C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib\MSVCRTD.lib:
    1>      Searching C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib\OLDNAMES.lib:
    1>      Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib\kernel32.lib:
    1>      Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib\user32.lib:
    1>      Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib\gdi32.lib:
    1>      Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib\winspool.lib:
    1>      Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib\comdlg32.lib:
    1>      Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib\advapi32.lib:
    1>      Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib\shell32.lib:
    1>      Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib\ole32.lib:
    1>      Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib\oleaut32.lib:
    1>      Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib\uuid.lib:
    1>      Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib\odbc32.lib:
    1>      Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib\odbccp32.lib:
    1> 
    1>  Finished searching libraries
    1>Bitmap.obj : error LNK2019: unresolved external symbol __imp__TransparentBlt@44 referenced in function "public: void __thiscall Bitmap::Draw(struct HDC__ *,int,int,int,unsigned long)" (?Draw@Bitmap@@QAEXPAUHDC__@@HHHK@Z)
    1>C:\Users\Ville\documents\visual studio 2010\Projects\Chapter 6\Debug\Chapter 6.exe : fatal error LNK1120: 1 unresolved externals
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
    Friday, July 02, 2010 2:58 AM
  • msimg32.lib is not in that list, which mean's you haven't actually added it to your project's linker inputs as you said you did.
    Friday, July 02, 2010 3:03 AM
  • I really haven't got a clue why it's not in that list but I have already added it as seen from this picture: http://img338.imageshack.us/img338/4238/libraryt.png


    What could possibly be wrong..

    Friday, July 02, 2010 3:11 AM
  • That is not the correct setting. As indicated in the link I gave, you need to be setting the Linker -> Input -> Additional Dependencies property, not the Linker -> General -> Additional Library Directories property.
    • Marked as answer by Vilde Friday, July 02, 2010 3:16 AM
    Friday, July 02, 2010 3:13 AM
  • Oh yes.. I have been terribly mistaken .. Embarrasing.  Well I added it to the right place and everything works again! Thanks a lot for this, and sorry about "wasting" your time by being so absent.

    Friday, July 02, 2010 3:16 AM
  • It happens. Make sure you reset the Additional Library Directories property back to its default value.
    Friday, July 02, 2010 3:19 AM