Unresolved symbol `__imp__iob`, not `__imp___iob`
Asked Answered
M

1

6

I'm compiling a program with Visual Studio 2017 that links with the precompiled static version of libusb, available here.

When I tried to link it I got some unresolved symbols like these and the answers pointed me to legacy_stdio_definitions.lib which resolved all of the linker errors except:

unresolved external symbol __imp__iob

This page from Microsoft talks about legacy_stdio_definitions.lib and says it provides __imp___iob but doesn't mention __imp__iob (note the different number of underscores).

What's going on here?

(Also, yes mixing CRT versions is a bad idea and I should really compile libusb from source. I know.)

Maine answered 18/3, 2018 at 22:28 Comment(0)
A
5

Had the same problem with libusb on VS2018 - 32bit, this helped me:

  1. Hacky solution: Linker complains about some missing function -- so just give it to it -- such function should return the implementation defined IO function pointers. For statically linked libusb-1.0 I had to add the following to my code:

    #pragma comment(lib, "legacy_stdio_definitions.lib")
    #ifdef __cplusplus
    FILE iob[] = { *stdin, *stdout, *stderr };
    extern "C" {
        FILE * __cdecl _iob(void) { return iob; }
    }
    #endif
    
  2. Better solution: Simply recompile static libs under VS 2018 (which I assume you are also using) and follow carefully the Readme file attached.

Andesite answered 4/4, 2018 at 11:20 Comment(1)
Yeah in the end I gave up and compiled libusb myself.Maine

© 2022 - 2024 — McMap. All rights reserved.