Chris H Baker
Chris H Baker

Reputation: 39

error LNK2001: unresolved external symbol ___iob_func in VS2017

I am tryig to compile an application in VS2017 (C++) and I get the errors:

1>libeay32.lib(cryptlib.obj) : error LNK2001: unresolved external symbol ___iob_func
1>libeay32.lib(pem_lib.obj) : error LNK2001: unresolved external symbol ___iob_func
1>libeay32.lib(ui_openssl.obj) : error LNK2001: unresolved external symbol ___iob_func

Other posts reported on such an error are for VS2015 and refer to stdin, stdout and stderr. But those fixes have not worked for me.

Strangely, if I go to stdin in the code and (right click) go to definition it takes me to Visual Studio 11.0 include directories, not the VS2017 ones.

My error is in libeay32.lib which I can't find a C++ source for anywhere.

Has anybody else had this problem?

Upvotes: 3

Views: 12894

Answers (1)

ari
ari

Reputation: 61

I found this solution and added these lines to my VS 17 C++ project

#define stdin  (__acrt_iob_func(0))
#define stdout (__acrt_iob_func(1))
#define stderr (__acrt_iob_func(2))

FILE _iob[] = { *stdin, *stdout, *stderr };
extern "C" FILE * __cdecl __iob_func(void) { return _iob; }

This worked for me.

Upvotes: 6

Related Questions