Solved: MinGW gcc settings cannot be updated correctly

94 views Asked by At

I am using x86_64-w64-mingw32-gcc (x86_64-w64-mingw32-gcc (GCC) 10-win32 20220113) in WSL and I would like to create a .lib which can be used in MVSC in Windows.

When I use the printf function inside my lib file, it cannot be linked using MVSC.

After debugging, I found out that besides printf, the functions __imp___acrt_iob_func and __mingw_vfprintf are defined, which are MinGW specific functions.

Included Functions before setting __USE_MINGW_ANSI_STDIO to 0

According to documentation and _mingw.h the user should be able to deactivate MinGW specific extended features after setting __MINGW_FEATURES__ to 0 and they should not change directly __USE_MINGW_ANSI_STDIO to 0.

But setting __MINGW_FEATURES__ to 0 does not deactivate the MinGW specific functions. Even passing the flag -std=c11 while compiling does not solve the problem. A solution is to pass the option while calling the compiler -D__USE_MINGW_ANSI_STDIO=0. Setting the value inside the lib itself does not work.

So the current solution is:

x86_64-w64-mingw32-gcc -D__USE_MINGW_ANSI_STDIO=0  -c File.c -o File.obj 

x86_64-w64-mingw32-ar  rcs File.lib File.obj

Included Functions after setting __USE_MINGW_ANSI_STDIO to 0

  • Is that a bug or an intended behaviour?
  • Where are the functions __imp___acrt_iob_func and __mingw_vfprintf defined?
0

There are 0 answers