Menu

Linker problems after migrating to OWLNEXT 7

2022-07-22
2022-07-22
  • Martin Cohen

    Martin Cohen - 2022-07-22

    I am migrating a (fully working) application developed under OWLNEXT 6.32.5 to OWLNEXT 7. I have had great support so far (THANK YOU!) and I have now managed to get everything to compile....Now I need to resolve the issues relating to the Linker...

    When I first got through the compile stage, I got the following linker error message:

    LINK : fatal error LNK1104: cannot open file 'kernel32.lib'

    Now I suspected I just needed to add another directory to the 'Library Directories' under my project's properties, and after checking using Window Explorer I found that there are 20 different kernel32.lib files on my C: drive. After some head scratching, I decided (guessed!) that the one to use was the one in

    C:\Program Files (x86)\Windows Kits\10\Lib\10.0.19041.0\um\x86

    ...so I added that path to the project's 'Library Directories' and then it seemed to find kernel32.lib... great...but then it said it couldn't open libcpmtd.lib ...

    So after a similar exercise I added the path ...

    C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.32.31326\lib\x86

    and after that it said it can't find libucrtd.lib

    so I added the path

    C:\Program Files (x86)\Windows Kits\10\Lib\10.0.18362.0\ucrt\x86

    And BINGO...my application builds and runs!!!!

    But, what is the story here? Why did I have to manually add all these paths?

     
    ❤️
    1

    Last edit: Martin Cohen 2022-07-22
  • Vidar Hasfjord

    Vidar Hasfjord - 2022-07-22

    Why did I have to manually add all these paths [to "kernel.lib" etc.]?

    You should not need to add all these individual paths for these basic libraries. You are probably missing the all encompassing settings for the library directories and linker input. My best advice is to study the examples and how they are set up. Find out how your project settings differ, and where they do, why they differ, and if they really need to differ. If not, copy the setup from the examples.

    Start with one of our simple examples, then if that does not cover all the settings you need, move on to the more comprehensive examples, such as Classes, and ultimately OWLMaker, which I guess is the most fully-fledged application example we have in the code base.

    Even OWLMaker has just this simple setting for "Configuration Properties | VC++ Directories | Library Directories" for all configurations:

    $(OWLNEXT_TRUNK)\lib;$(LibraryPath)

    OWLNEXT_TRUNK is an environment variable defined by me to point to my OWLNext installation, but LibraryPath is a built-in Visual Studio variable.

    In addition, OWLMaker adds the following libraries explicitly to "Configuration Properties | Linker | Input":

    wininet.lib;comsuppwd.lib;%(AdditionalDependencies) (Debug configuration)
    wininet.lib;comsuppw.lib;%(AdditionalDependencies) (Release configuration)

    The "wininet.lib" is needed for the WinINet functions OWLMaker uses to access the Internet, and "comsuppw(|d).lib" is used for some COM utility functions OWLMaker uses internally. These should not be needed for OWLNext applications in general.

    The important part for the general case is AdditionalDependencies, which in turn inherits from the toolset standard CoreLibraryDependencies, which should include the basics such as "kernel32.lib", etc. These are both built-in Visual Studio variables.

    PS. All that said, if you find that there are needed settings and changes that are not explained in our porting guides and FAQ, we very much welcome help to improve the documentation. See this sticky post, where you can contribute your findings:

    User Guide: Upgrade to OWLNext with ease (documentation, tips, FAQ, etc.)

     

    Related

    Discussion: 64acd4d0

  • Martin Cohen

    Martin Cohen - 2022-07-22

    Brilliant...thank you so much Vidar! I added $(LibraryPath) to my Library directories and I added ..\inc;$(owlnext)\include;%(AdditionalIncludeDirectories) to my Additional Include Directories (under Resources, General). I was then able to remove the long explicit paths to those lib files, and to undo the changes I made to winresrc.h (see my other topic post). I can now build and run the application, and the resource editor opens fine as well!
    AGAIN....THANK YOU!

     
    ❤️
    1
  • Vidar Hasfjord

    Vidar Hasfjord - 2022-07-22

    @martinabc wrote:

    Brilliant...thank you so much Vidar!

    Glad to help! Good to hear you sorted it out, and that you were able to upgrade to 7.0 so swiftly. I am impressed!

    I added ..\inc;$(owlnext)\include;%(AdditionalIncludeDirectories) [...] (under Resources, General)

    Note that the "..\inc" part is not needed in your project, I presume. In OWLMaker it is just old cruft referring to an obsolete path that at some point must have referred to OWLMaker's own resources, I guess. Anyway, it is no longer needed, and I have removed it now.

     
  • Martin Cohen

    Martin Cohen - 2022-07-22

    I'm impressed that you are impressed! I have been programming in C++ and OWLNEXT for many years now, and yet I still only know a fraction of what there is to know. I guess I just find out what I need to know to get my specific tasks done, but then when I do something unusual like migrate to a new version of OWLNEXT I feel like a total idiot! Your help is VERY VERY much appreciated, and your responsiveness is fantastic! (I took out the ../inc; all still works fine. Thanks.)

     
    ❤️
    1

    Last edit: Martin Cohen 2022-07-22

Anonymous
Anonymous

Add attachments
Cancel