Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. 'get_osfhandle': identifier not found

'get_osfhandle': identifier not found

Scheduled Pinned Locked Moved C / C++ / MFC
c++visual-studiocomlinuxhelp
4 Posts 3 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • _ Offline
    _ Offline
    _Flaviu
    wrote on last edited by
    #1

    I've found in a C function, from a Linux library a function: get_osfhandle:

    handle = get_osfhandle(fd);

    And it is declared up in the C file like this:

    HANDLE get_osfhandle(int); /* from msvcrt.dll */

    but I got a link error:

    error LNK2019: unresolved external symbol "void * __cdecl get_osfhandle(int)" (?get_osfhandle@@YAPAXH@Z) referenced in function ...

    I commented that line, HANDLE get_osfhandle(int);, and without this declaration, I got the error from post subject. Of course, I have included io.h header, like msdn said: _get_osfhandle | Microsoft Docs[^] But I got the same errors. I have tried to include , seem to be useless ... how to overcome this error ?

    L 1 Reply Last reply
    0
    • _ _Flaviu

      I've found in a C function, from a Linux library a function: get_osfhandle:

      handle = get_osfhandle(fd);

      And it is declared up in the C file like this:

      HANDLE get_osfhandle(int); /* from msvcrt.dll */

      but I got a link error:

      error LNK2019: unresolved external symbol "void * __cdecl get_osfhandle(int)" (?get_osfhandle@@YAPAXH@Z) referenced in function ...

      I commented that line, HANDLE get_osfhandle(int);, and without this declaration, I got the error from post subject. Of course, I have included io.h header, like msdn said: _get_osfhandle | Microsoft Docs[^] But I got the same errors. I have tried to include , seem to be useless ... how to overcome this error ?

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Microsoft have helpfully changed the name, it is now _get_osfhandle (with a leading underscore), as defined in io.h.

      L 1 Reply Last reply
      0
      • L Lost User

        Microsoft have helpfully changed the name, it is now _get_osfhandle (with a leading underscore), as defined in io.h.

        L Offline
        L Offline
        leon de boer
        wrote on last edited by
        #3

        There are very clear and compelling reasons they had to do it when they embedded linux in the windows API via WSL2. Windows then effectively has both the linux and windows functions available and it needs to know which you are wanting to call which is down to what app you are compiling a linux one or a windows one. Compatibility | Microsoft Docs[^] If you aren't aware of WSL2 in Windows 10 it's time to meet to meet it :-) Trying the New WSL 2. It's Fast! (Windows Subsystem for Linux) ― Scotch.io[^]

        In vino veritas

        L 1 Reply Last reply
        0
        • L leon de boer

          There are very clear and compelling reasons they had to do it when they embedded linux in the windows API via WSL2. Windows then effectively has both the linux and windows functions available and it needs to know which you are wanting to call which is down to what app you are compiling a linux one or a windows one. Compatibility | Microsoft Docs[^] If you aren't aware of WSL2 in Windows 10 it's time to meet to meet it :-) Trying the New WSL 2. It's Fast! (Windows Subsystem for Linux) ― Scotch.io[^]

          In vino veritas

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          Yes, I was well aware of that. I have been using WSL for some time, but maybe I should upgrade to WSL2. Thanks for the link.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups