Menu

Linker error on using "CreateCompa...

2010-03-03
2012-09-26
  • Dmitry Titov

    Dmitry Titov - 2010-03-03

    I have created the project. The project type is "Win32 DLL". There is the
    following string in my project:
    HDC hCDC = CreateCompatibleDC(hdc);
    I see following error after compiling:
    undefined reference to `CreateCompatibleDC@4'
    But if i will create the project with type "Win32 GUI" and put this string
    into it it will compiles without any errors. Why?

    How can I compile my project with type "Win32 DLL"?

     
  • Dmitry Titov

    Dmitry Titov - 2010-03-03

    I am sorry if I have put my question to the wrong section.

     
  • Edmund Tudor

    Edmund Tudor - 2010-03-04

    You need to link to gdi32.lib
    I believe this gets linked automatically when you choose Win32 GUI project,
    but not for Win32 DLL.

     
  • Dmitry Titov

    Dmitry Titov - 2010-03-04

    How I can see, what files get linked automatically to a project?

     
  • Edmund Tudor

    Edmund Tudor - 2010-03-04

    I don't know if "linked automatically" is the best way to put that. Maybe
    someone else here knows exactly how that works, I just seem to remember seeing
    somewhere long ago that GUI projects add some libraries without you having to
    explicitly link them.

     
  • Dmitry Titov

    Dmitry Titov - 2010-03-05

    The function declaration “CreateCompatibleDC” is in a file “wingdi.h”. This
    file is connected to the project as follows: “Tools-> CompilerOption->
    Directories-> CInclude” the path “C:\Dev-Cpp\include \is specified”. Here
    there is a file “wingdi.h”. The function description “CreateCompatibleDC” in
    library “libgdi32.a”. This library is to the address “C:\Dev-Cpp\lib \”. It is
    the address it is specified in compiler customisations: “Tools->
    CompilerOption-> Directories-> Libraries”.
    Specified above customisation are identical to both projects, but for the type
    project “WIN32 DLL” the compiler produces an error. For the type project
    “WIN32 GUI” compilation passes successfully.
    In a directory with the type project “WIN32 DLL” I have copied a file
    “libgdi32.a”. Also has made following customisations: “Project->
    ProjectOptions-> Parameters-> Linker” has entered a filename “libgdi32.a”.
    Compilation has passed successfully.
    Why? After all the file “libgdi32.a” should be connected to the project
    without additional customisations?

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.