Mixing different versions of GCC and/or its runtime libraries may always cause troubles, but after short googling it looks like specific versions of MSYS2 also had a problem that could cause that error (for example this bug report describes that the error was fixed by updating MSYS2:
https://github.com/xmrig/xmrig/issues/448). If you choose to do so make a backup copy of your MSYS2 folder first, because the MSYS2 project does not keep older versions of their packages on their servers (in general), so it allows you to install the most recent version only in case you'd need a fresh install.
Anyways, let's assume MSYS2 is fine and have a look at the FB runtime. The FB runtime is written in C and depends on the C runtime libraries (CRT). When linking your FreeBasic program you can see fbc calling the linker with several libraries in addition to the fb runtime libraries:
ld.exe -m i386pe -o "test.exe" -subsystem console "fbextra.x" --stack 1048576,1048576 -s -L " "crt2.o" "crtbegin.o" "fbrt0.o" "test.o" "-(" -lfb -lgcc -lmsvcrt -lkernel32 -luser32 -lmingw32 -lmingwex -lmoldname -lgcc_eh "-)" "crtend.o"Some of these are part of the operating system (like msvcrt, kernel32, user32), others are shipping with the C compiler (GCC in our case; like crt*.o, gcc, mingw*) and others are part of the FreeBasic compiler (like fbrt0, fb). You can imagine that you may run into troubles when you compile your FreeBasic runtime in a different environment compared to the one you later use for linking those library to your FreeBasic application.
So what I would recommend (and I think this is also described in the wiki) is to use the same GCC version for both building the runtime library and linking your FreeBasic programs. What you need to do is to copy the libraries (and binaries) from your GCC directory to your FreeBasic build directory after you built your new runtime libraries, and use that fbc instead of copying just the runtime libraries to another (existing) FreeBasic installation. On my CI system I'm using a simple shell script like the following one (you can run that in the MSYS environment) (for 32-bit GCC 7.3.0):
Code: Select all
# Copy to C:\fbc\bin\win32:
#
# C:\mingw\bin\{ar,as,dlltool,ld}.exe
# GoRC.exe (from http://www.godevtool.com/8 or the previous FreeBASIC release) #
#
#
# Copy to C:\fbc\lib\win32:
#
# C:\mingw\lib\{crt2,dllcrt2,gcrt2}.o
# C:\mingw\lib\lib{gmon,mingw32,mingwex,moldname}.a
# C:\mingw\lib\gcc\mingw32\[version]\{crtbegin,crtend}.o
# C:\mingw\lib\gcc\mingw32\[version]\lib{gcc,supc++}.a
# C:\mingw\lib\lib{advapi32,gdi32,kernel32,msvcrt,user32,winmm,winspool}.a (rename to lib*.dll.a)
# C:\mingw\lib\libffi.a
# and any additional libraries you want to use
#
#
# Rename C:\fbc\fbc-new.exe to C:\fbc\fbc.exe, if wanted
#
basedir=/d/gcc730
version=7.3.0
mkdir bin/win32 -p
cp $basedir/mingw32/bin/gcc.exe bin/win32/
mkdir bin/i686-w64-mingw32/bin -p
cp $basedir/mingw32/libexec/gcc/i686-w64-mingw32/$version/cc1.exe bin/i686-w64-mingw32/bin/
cp $basedir/mingw32/bin/ar.exe bin/win32/
cp $basedir/mingw32/bin/as.exe bin/win32/
cp $basedir/mingw32/bin/dlltool.exe bin/win32/
cp $basedir/mingw32/bin/ld.exe bin/win32/
cp $basedir/mingw32/bin/GoRC.exe bin/win32/
mkdir lib/win32 -p
cp $basedir/mingw32/i686-w64-mingw32/lib/crt2.o lib/win32/
cp $basedir/mingw32/i686-w64-mingw32/lib/dllcrt2.o lib/win32/
cp $basedir/mingw32/i686-w64-mingw32/lib/gcrt2.o lib/win32/
cp $basedir/mingw32/i686-w64-mingw32/lib/libgmon.a lib/win32/
cp $basedir/mingw32/i686-w64-mingw32/lib/libmingw32.a lib/win32/
cp $basedir/mingw32/i686-w64-mingw32/lib/libmingwex.a lib/win32/
cp $basedir/mingw32/i686-w64-mingw32/lib/libmoldname.a lib/win32/
cp $basedir/mingw32/i686-w64-mingw32/lib/crtbegin.o lib/win32/
cp $basedir/mingw32/i686-w64-mingw32/lib/crtend.o lib/win32/
cp $basedir/mingw32/lib/gcc/i686-w64-mingw32/$version/libgcc.a lib/win32/
cp $basedir/mingw32/lib/gcc/i686-w64-mingw32/$version/libgcc_eh.a lib/win32/
cp $basedir/mingw32/lib/gcc/i686-w64-mingw32/$version/libsupc++.a lib/win32/
cp $basedir/mingw32/i686-w64-mingw32/lib/libadvapi32.a lib/win32/libadvapi32.dll.a
cp $basedir/mingw32/i686-w64-mingw32/lib/libgdi32.a lib/win32/libgdi32.dll.a
cp $basedir/mingw32/i686-w64-mingw32/lib/libkernel32.a lib/win32/libkernel32.dll.a
cp $basedir/mingw32/i686-w64-mingw32/lib/libmsvcrt.a lib/win32/libmsvcrt.dll.a
cp $basedir/mingw32/i686-w64-mingw32/lib/libuser32.a lib/win32/libuser32.dll.a
cp $basedir/mingw32/i686-w64-mingw32/lib/libwinmm.a lib/win32/libwinmm.dll.a
cp $basedir/mingw32/i686-w64-mingw32/lib/libwinspool.a lib/win32/libwinspool.dll.a
cp $basedir/mingw32/i686-w64-mingw32/lib/libffi.a lib/win32/
# required for the functions.argv test
cp $basedir/mingw32/i686-w64-mingw32/lib/libmsimg32.a lib/win32/libmsimg32.dll.a
cp $basedir/mingw32/i686-w64-mingw32/lib/libversion.a lib/win32/libversion.dll.a
cp $basedir/mingw32/i686-w64-mingw32/lib/libimm32.a lib/win32/libimm32.dll.a
#mv fbc-new.exe fbc.exe
Some other things that were mentioned in this thread: Yes, I'm using the old MSYS (the one from MinGW.org) in combination with the MinGW-w64 toolchain on my CI machine, but unfortunately I cannot remember the reason why MSYS2 didn't work there back then either. For manual builds on other machines I'm using MSYS2 nowadays and it works just fine.