imp____acrt_iob_func, undefined

General FreeBASIC programming questions.
srvaldez
Posts: 2109
Joined: Sep 25, 2005 21:54

imp____acrt_iob_func, undefined

Postby srvaldez » Feb 12, 2018 6:00

I have been keeping msys2 updated to the latest and today I decided to build FB from source again, everything went well until I tried to compile something, I would get the error \lib\win32/libfb.a(init.o):init.c:(.text+0x97): undefined reference to `_imp____acrt_iob_func'
fortunately I had a backup of an earlier version of msys2 and all is well again, I won't be so self-confident next time.
just the same, does anyone know the solution to this problem? google didn't help.
srvaldez
Posts: 2109
Joined: Sep 25, 2005 21:54

Re: imp____acrt_iob_func, undefined

Postby srvaldez » Feb 12, 2018 10:17

found the solution, one needs to replace the gcc libraries with the newer.
integer
Posts: 379
Joined: Feb 01, 2007 16:54
Location: usa

Re: imp____acrt_iob_func, undefined

Postby integer » Feb 12, 2018 14:01

srvaldez wrote:found the solution, one needs to replace the gcc libraries with the newer.

Where are the latest gcc libs?
and just wondering: If you kept msys current & using the latest FBC to complile the fbc, how did you miss the gcc libs?
That might provide some answers for problems I've had with compiling the compiler.
srvaldez
Posts: 2109
Joined: Sep 25, 2005 21:54

Re: imp____acrt_iob_func, undefined

Postby srvaldez » Feb 12, 2018 17:34

hello integer
yes I keep msys2 up to date, in the past I didn't bother updating all the libraries, jus the ones belonging to FB, but things changed a bit in the gcc libraries and was getting the above error, besides it's better to have updated libs.
I don't know what your gcc toolchain looks like, do you have msys2 installed as well or some other mingw distribution?
I would recommend that you install the FB package that's designed to be integrated in the toolchain, makes it easier to re-build FB.
I have both 32 and 64-bit versions in the gcc toolchain as well as standalone versions which I use most of the time.
let me know what your setup is and what you have tried.
integer
Posts: 379
Joined: Feb 01, 2007 16:54
Location: usa

Re: imp____acrt_iob_func, undefined

Postby integer » Feb 16, 2018 4:46

Thanks srvaldez.

I tried several dozen times in the past years to compile the compiler on a xp and Win7. With each failure I would erase the files and reinstall all that I believed the developer pages identified. There were a bunch of errors that made no sense. My "corrections" to those messages weren't -- and the attempt to compile the compiler puked.

Now that I have a WenTin Box (as of last year) one of my goals this year is to compile both the 32bit FBC and the 64bit FBC.
The cpu is an AMD 8-core.
I will install msys & the toolchain on the Win10.
srvaldez
Posts: 2109
Joined: Sep 25, 2005 21:54

Re: imp____acrt_iob_func, undefined

Postby srvaldez » Feb 16, 2018 20:02

hello integer
I recommend msys2 http://www.msys2.org or https://sourceforge.net/projects/msys2/ , it's actively being maintained, so much so that sometimes there are updating problems, but if you skip checking for updates on Tuesdays you probably won't run into problems.
Tuesday as you may know is systems software update day, so skip Tuesday and you should be ok.
Iczer
Posts: 50
Joined: Jul 04, 2017 18:09

Re: imp____acrt_iob_func, undefined

Postby Iczer » Apr 18, 2019 15:22

I'm run into same problem with undefined __imp___acrt_iob_func

Code: Select all

***\FreeBASIC-1.06.0-win64\lib\win64/libcurl.a(mprintf.o):(.text+0x1b58): undefined reference to `__imp___acrt_iob_func'
***\FreeBASIC-1.06.0-win64\lib\win64/libcurl.a(mprintf.o):(.text+0x1bf3): undefined reference to `__imp___acrt_iob_func'
***\FreeBASIC-1.06.0-win64\lib\win64/libcurl.a(setopt.o):(.text+0x190b): undefined reference to `__imp___acrt_iob_func'
***\FreeBASIC-1.06.0-win64\lib\win64/libcurl.a(cookie.o):(.text+0x1a0): undefined reference to `__imp___acrt_iob_func'
***\FreeBASIC-1.06.0-win64\lib\win64/libcurl.a(cookie.o):(.text+0x26e4): undefined reference to `__imp___acrt_iob_func'
***\FreeBASIC-1.06.0-win64\lib\win64/libcurl.a(url.o):(.text+0x4e9): more undefined references to `__imp___acrt_iob_func' follow


if i get fresh mingw64 (v8.1+) and copy "libstdc++.a" (am i right?) to FreeBasic "\lib\win64\" folder will it solve issue?

googled some related discussion:
https://stackoverflow.com/questions/30412951/unresolved-external-symbol-imp-fprintf-and-imp-iob-func-sdl2
caseih
Posts: 1379
Joined: Feb 26, 2007 5:32

Re: imp____acrt_iob_func, undefined

Postby caseih » Apr 18, 2019 18:11

I think you're seeing some incompatibilities between the version of Mingw or Visual Studio that compiled libcurl, and your version of the MingW compiler/linker suite. I suspect it's something to do with changes to MS C runtime. But that's as far as I've got. At a low level I think MS changed some of underlying implementation of certain C runtime routines over the last few years. This link talks about the changes: https://msdn.microsoft.com/en-us/librar ... spx#BK_CRT

Here's a discussion of this type of error: https://stackoverflow.com/questions/304 ... -func-sdl2

No idea how to resolve this from FBC though.
Iczer
Posts: 50
Joined: Jul 04, 2017 18:09

Re: imp____acrt_iob_func, undefined

Postby Iczer » Apr 18, 2019 22:57

__iob_func() function it seems provided by msvcr120.dll, but including #inclib "msvcr120" not resolve issue. I tried to declare __iob_func() like this:

Code: Select all

Declare function  __acrt_iob_func(ByVal index As UInteger) as FILE ptr
#Define stdin __acrt_iob_func(STDIN_FILENO)
#Define stdout __acrt_iob_func(STDOUT_FILENO)
#Define stderr __acrt_iob_func(STDERR_FILENO)


because ():

Code: Select all

Here's a snippet from the Visual Studio 2008 headers:

_CRTIMP FILE * __cdecl __iob_func(void);
#define stdin (&__iob_func()[0])
#define stdout (&__iob_func()[1])
#define stderr (&__iob_func()[2])

Visual Studio 2015 defines the same things:

_ACRTIMP_ALT FILE* __cdecl __acrt_iob_func(unsigned);
#define stdin (__acrt_iob_func(0))
#define stdout (__acrt_iob_func(1))
#define stderr (__acrt_iob_func(2))


maybe this should eliminate errors (but not work if actually called), but i do not know how translate it to freebasic:

Code: Select all

FILE _iob[] = {*stdin, *stdout, *stderr};

extern "C" FILE * __cdecl __iob_func(void)
{
    return _iob;
}


or this:

Code: Select all

'typedef FILE *__cdecl (*_f__acrt_iob_func)(unsigned index);
'_f__acrt_iob_func __MINGW_IMP_SYMBOL(__acrt_iob_func) = __acrt_iob_func;
'"#;
Iczer
Posts: 50
Joined: Jul 04, 2017 18:09

Re: imp____acrt_iob_func, undefined

Postby Iczer » Apr 23, 2019 15:17

I successfully get around issue by creating:

Code: Select all

#Include Once "crt.bi"

Extern "C"

Declare Function __acrt_iob_func (ByVal index As ULong) As FILE Ptr

Function __acrt_iob_func(ByVal index As ULong) As FILE Ptr
   Return @(__iob_func()[index])
End Function

Declare Function __imp___acrt_iob_func (ByVal index As ULong) As FILE Ptr

Function __imp___acrt_iob_func(ByVal index As ULong) As FILE Ptr
   Return @(__iob_func()[index])
End Function

End Extern

#Undef stdin
#Undef stdout
#Undef stderr

#Define stdin (__acrt_iob_func(STDIN_FILENO_))
#Define stdout (__acrt_iob_func(STDOUT_FILENO))
#define stderr (__acrt_iob_func(STDERR_FILENO))


Code compilibg without warnings, programm start ok, but crash on first call of curl...
Maybe stdin/stdout/stderr realisation wrong in my snippet?

Return to “General”

Who is online

Users browsing this forum: No registered users and 29 guests