[SOLVED] Multiple Errors when include "gtk/gtk.bi"

Windows specific questions.
Post Reply
exagonx
Posts: 314
Joined: Mar 20, 2009 17:03
Location: Italy
Contact:

[SOLVED] Multiple Errors when include "gtk/gtk.bi"

Post by exagonx »

Hi friends, Tonight I installed FreeBASIC on Windows 7 and msys2 with GTK3, unfortunately when I compile a program that includes gtk, the following messages appear, and honestly I have no idea what it is because in the source code I also specified #libpath
On other systems the compilation works perfectly even under linux so it is not a programming error.

Code: Select all

C:\PROGRA~2\FREEBA~1\bin\win32\ld.exe: C:\Program Files\FreeBASIC\lib\win32\crt
.o: in function `check_managed_app':
R:\winlibs32-sjlj-9.3.0\mingw-w64-v7.0.0\mingw-w64-crt/crt/crtexe.c:364: undefi
ed reference to `mingw_initltsdrot_force'
C:\PROGRA~2\FREEBA~1\bin\win32\ld.exe: R:\winlibs32-sjlj-9.3.0\mingw-w64-v7.0.0
mingw-w64-crt/crt/crtexe.c:365: undefined reference to `mingw_initltsdyn_force'
C:\PROGRA~2\FREEBA~1\bin\win32\ld.exe: R:\winlibs32-sjlj-9.3.0\mingw-w64-v7.0.0
mingw-w64-crt/crt/crtexe.c:366: undefined reference to `mingw_initltssuo_force'
C:\PROGRA~2\FREEBA~1\bin\win32\ld.exe: R:\winlibs32-sjlj-9.3.0\mingw-w64-v7.0.0
mingw-w64-crt/crt/crtexe.c:367: undefined reference to `mingw_initcharmax'
C:\PROGRA~2\FREEBA~1\bin\win32\ld.exe: C:\Program Files\FreeBASIC\lib\win32\crt
.o: in function `pre_c_init':
R:\winlibs32-sjlj-9.3.0\mingw-w64-v7.0.0\mingw-w64-crt/crt/crtexe.c:141: undefi
ed reference to `mingw_app_type'
C:\PROGRA~2\FREEBA~1\bin\win32\ld.exe: C:\Program Files\FreeBASIC\lib\win32\crt
.o: in function `_tmainCRTStartup':
R:\winlibs32-sjlj-9.3.0\mingw-w64-v7.0.0\mingw-w64-crt/crt/crtexe.c:245: undefi
ed reference to `mingw_app_type'
C:\PROGRA~2\FREEBA~1\bin\win32\ld.exe: R:\winlibs32-sjlj-9.3.0\mingw-w64-v7.0.0
mingw-w64-crt/crt/crtexe.c:323: undefined reference to `mingw_app_type'
C:\PROGRA~2\FREEBA~1\bin\win32\ld.exe: C:\Program Files\FreeBASIC\lib\win32\crt
.o: in function `WinMainCRTStartup':
R:\winlibs32-sjlj-9.3.0\mingw-w64-v7.0.0\mingw-w64-crt/crt/crtexe.c:193: undefi
ed reference to `mingw_app_type'
C:\PROGRA~2\FREEBA~1\bin\win32\ld.exe: R:\winlibs32-sjlj-9.3.0\mingw-w64-v7.0.0
mingw-w64-crt/crt/crtexe.c:194: undefined reference to `__security_init_cookie'
C:\PROGRA~2\FREEBA~1\bin\win32\ld.exe: C:\Program Files\FreeBASIC\lib\win32\crt
.o: in function `mainCRTStartup':
R:\winlibs32-sjlj-9.3.0\mingw-w64-v7.0.0\mingw-w64-crt/crt/crtexe.c:221: undefi
ed reference to `mingw_app_type'
C:\PROGRA~2\FREEBA~1\bin\win32\ld.exe: R:\winlibs32-sjlj-9.3.0\mingw-w64-v7.0.0
mingw-w64-crt/crt/crtexe.c:222: undefined reference to `__security_init_cookie'
Last edited by exagonx on Mar 25, 2022 20:05, edited 1 time in total.
srvaldez
Posts: 3373
Joined: Sep 25, 2005 21:54

Re: Multiple Errors when include "gtk/gtk.bi"

Post by srvaldez »

hello exagonx
if you want to use msys2 libraries with FB then I would recommend that you install freebasic for the gcc-toolchain, goto viewtopic.php?t=31376 and under the heading FREEBASIC PACKAGES FOR A SPECIFIC GCC VERSION choose
fbc-1.09.0-win32-winlibs-gcc-9.3.0.7z | .zip archive - to be extracted into existing 32bit MinGW-w64 toolchain
fbc-1.09.0-win64-winlibs-gcc-9.3.0.7z | .zip archive - to be extracted into existing 64bit MinGW-w64 toolchain
and use that FB instead, you would probably need to compile your FB programs from the msys2-shell
exagonx
Posts: 314
Joined: Mar 20, 2009 17:03
Location: Italy
Contact:

Re: Multiple Errors when include "gtk/gtk.bi"

Post by exagonx »

@srvaldez
Thank you for your suggestion, I tryed with GCC integration but the error its identic.
srvaldez
Posts: 3373
Joined: Sep 25, 2005 21:54

Re: Multiple Errors when include "gtk/gtk.bi"

Post by srvaldez »

can you post a minimal example that produces this type of errors?

found this at https://stackoverflow.com/questions/588 ... ncy-issues
So I answer my question by myself, the case is closed.

Yes, Mingw64 uses msvcrt.

Here are some tips that could help to solve dependency problems between Mingw64 & msvcrt. The major goal is to let compiler load the correct version of MSVCRT library family.

1.Update Mingw64.

2.Check out MSVCRT_VERSION in Mingw64\include_mingw.h(or x86_64-w64-mingw32\include), make sure the version number matches your windows version, or modify it.

3.Take a look at linker option like "#cgo LDFLAGS: -Lxxx", don't mess the library path. Remove any unnecessary library path setting, let linker finds libraries itself.

Make sure everything is built with same libraries.
srvaldez
Posts: 3373
Joined: Sep 25, 2005 21:54

Re: Multiple Errors when include "gtk/gtk.bi"

Post by srvaldez »

if I were you I would build FB from source, perhaps that would help eliminate the errors because it looks to me that there may be incompatibility issues
exagonx
Posts: 314
Joined: Mar 20, 2009 17:03
Location: Italy
Contact:

Re: Multiple Errors when include "gtk/gtk.bi"

Post by exagonx »

srvaldez wrote: Mar 25, 2022 9:38 if I were you I would build FB from source, perhaps that would help eliminate the errors because it looks to me that there may be incompatibility issues
FreeBASIC 1.09 doesnt work anymore on my pc windows 10 64 bit when I Include "gtk/gtk.bi"
I tryed a fresh istallation but this is what appair:


The follow message are what appair inside the msys2 console when I try to compile a code where are included "gtk/gtk.bi"

(test.bas)

Code: Select all

#include "gtk/gtk.bi"
print "Hello"
and when i do fbc test.bas
appair this

Code: Select all

$ fbc GladeToBac.bas
C:\msys64\FreeBASIC\bin\win64\ld.exe: C:\msys64\FreeBASIC\lib\win64\crt2.o: in function `__tmainCRTStartup':
R:\winlibs64-sjlj-9.3.0\mingw-w64-v7.0.0\mingw-w64-crt/crt/crtexe.c:288: undefined reference to `__mingw_init_ehandler'
C:\msys64\FreeBASIC\bin\win64\ld.exe: C:\msys64\FreeBASIC\lib\win64\crt2.o: in function `WinMainCRTStartup':
R:\winlibs64-sjlj-9.3.0\mingw-w64-v7.0.0\mingw-w64-crt/crt/crtexe.c:194: undefined reference to `__security_init_cookie'
C:\msys64\FreeBASIC\bin\win64\ld.exe: C:\msys64\FreeBASIC\lib\win64\crt2.o: in function `mainCRTStartup':
R:\winlibs64-sjlj-9.3.0\mingw-w64-v7.0.0\mingw-w64-crt/crt/crtexe.c:222: undefined reference to `__security_init_cookie'
C:\msys64\FreeBASIC\bin\win64\ld.exe: C:\msys64\FreeBASIC\lib\win64\crt2.o:crtexe.c:(.rdata$.refptr.mingw_app_type[.refptr.mingw_app_type]+0x0): undefined reference to `mingw_app_type'
C:\msys64\FreeBASIC\bin\win64\ld.exe: C:\msys64\FreeBASIC\lib\win64\crt2.o:crtexe.c:(.rdata$.refptr.mingw_initcharmax[.refptr.mingw_initcharmax]+0x0): undefined reference to `mingw_initcharmax'
C:\msys64\FreeBASIC\bin\win64\ld.exe: C:\msys64\FreeBASIC\lib\win64\crt2.o:crtexe.c:(.rdata$.refptr.mingw_initltssuo_force[.refptr.mingw_initltssuo_force]+0x0): undefined reference to `mingw_initltssuo_force'
C:\msys64\FreeBASIC\bin\win64\ld.exe: C:\msys64\FreeBASIC\lib\win64\crt2.o:crtexe.c:(.rdata$.refptr.mingw_initltsdyn_force[.refptr.mingw_initltsdyn_force]+0x0): undefined reference to `mingw_initltsdyn_force'
C:\msys64\FreeBASIC\bin\win64\ld.exe: C:\msys64\FreeBASIC\lib\win64\crt2.o:crtexe.c:(.rdata$.refptr.mingw_initltsdrot_force[.refptr.mingw_initltsdrot_force]+0x0): undefined reference to `mingw_initltsdrot_force'

About the integration:
I don't understand why I have to download the whole msys2 package when I normally only use 10MB of GTK libraries and 15MB of Headers, basic MSYS2 measures 120MB with GTK almost 600MB

Is it possible that I can't use FreeBASIC 1.09 as I did with 1.02?
srvaldez
Posts: 3373
Joined: Sep 25, 2005 21:54

Re: Multiple Errors when include "gtk/gtk.bi"

Post by srvaldez »

exagonx, I just tried to download the z archive https://downloads.sourceforge.net/fbc/f ... z?download the FB archive to be extracted into existing 64bit MinGW-w64 toolchain and it didn't download but the zip archive works
please download the zip archive if you haven't already, but your installation into the msys2 system is wrong, looks like you got the wrong package, undo that installation and extract the zip archive not the z archive into C:\msys64 or in other words
from the zip archive bin folder copy fbc.exe to C:\msys64\mingw64\bin
from the zip archive include folder copy the freebasic folder to C:\msys64\mingw64\include
from the zip archive lib folder copy the freebasic folder to C:\msys64\mingw64\lib
then change your example to

Code: Select all

#include "gtk/gtk3.bi"
print "Hello"
notice that we include gtk3.bi
[edit]
using the msys2 libraries will also add dll dependencies to your executable, in the above example libglib-2.0-0.dll and libgobject-2.0-0.dll
exagonx
Posts: 314
Joined: Mar 20, 2009 17:03
Location: Italy
Contact:

Re: Multiple Errors when include "gtk/gtk.bi"

Post by exagonx »

srvaldez wrote: Mar 25, 2022 14:13
from the zip archive bin folder copy fbc.exe to C:\msys64\mingw64\bin
from the zip archive include folder copy the freebasic folder to C:\msys64\mingw64\include
from the zip archive lib folder copy the freebasic folder to C:\msys64\mingw64\lib
I done everything you have wrote and this is the result:

Code: Select all

Exagonx@PhenomIIx4 MSYS /GladeToBac-master/src
$ fbc GladeToBac.bas
GladeToBac.bas(47) error 23: File not found, "gtk/gtk.bi" in '#INCLUDE ONCE "gtk/gtk.bi" '                GTK3 library / GTK3 Bibliothek >'
after correction the GTK with GTK3

Code: Select all

Exagonx@PhenomIIx4 MSYS /GladeToBac-master/src
$ fbc GladeToBac.bas
GladeToBac.bas(47) error 23: File not found, "gtk/gtk3.bi" in '#INCLUDE ONCE "gtk/gtk3.bi" '                GTK3 library / GTK3 Bibliothek >'

srvaldez
Posts: 3373
Joined: Sep 25, 2005 21:54

Re: Multiple Errors when include "gtk/gtk.bi"

Post by srvaldez »

I don't know what's wrong because the folder include\freebasic\gtk from the FB zip archive has gtk.bi, gtk2.bi and gtk3.bi
if you installed it as per instructions and you are compiling via the msys2-shell it should not give that error however, if I try to compile GladeToBac.bas I get other errors, but you can get GladeToBac.exe from https://www.freebasic-portal.de/downloa ... c-190.html
maybe TJF will chime in, he is the author and should be able to help
exagonx
Posts: 314
Joined: Mar 20, 2009 17:03
Location: Italy
Contact:

Re: Multiple Errors when include "gtk/gtk.bi"

Post by exagonx »

@srvaldez
I sincerely thank you for the support you gave me and it was useful to make me understand where the problem lay.

And I apologize because the problem was caused by me, in fact all the hitch is caused by the fact that 64bit and 32bit libraries were present, I solved by reinstalling FreeBASIC 1.09.0 and completely removed msys2 and reinstalled by adding only GTK to 64 bit, In fact now FreeBASIC is independent from MSYS2 without being integrated, everything works perfectly.

the problem was in GCC because msys2 when you install GCC toolchain the version are GCC version 11 but FreeBASIC are for GCC 9.3
wallyg
Posts: 267
Joined: May 08, 2009 7:08
Location: Tucson Arizona

Re: [SOLVED] Multiple Errors when include "gtk/gtk.bi"

Post by wallyg »

I have just found this thread. I am having the same problem with GTK. I installed MSYS2 to get the gtk3 binaries many years ago and at that time everything worked great and recently decided to update MSYS2 files (obviously I now see this was a mistake). Now I am getting the same errors. I am not an MSYS2 user and used a set of commands given to me by someone else.

Will deleting the MSYS2 directory get rid of it? Then what commands can I use to add GTK only to 64-bit and be independent of MSYS2?

Thank you
Wally
exagonx
Posts: 314
Joined: Mar 20, 2009 17:03
Location: Italy
Contact:

Re: [SOLVED] Multiple Errors when include "gtk/gtk.bi"

Post by exagonx »

wallyg wrote: Jun 22, 2022 19:39
Will deleting the MSYS2 directory get rid of it? Then what commands can I use to add GTK only to 64-bit and be independent of MSYS2?

Thank you
Wally
Unfortunately GTK comes only in source code, and the only platform that compiles it for windows is msys2

install MSYS2
run MSYS2 MINGW 64
use this commands
for update: pacman -Syu
for install gtk3: pacman -S mingw-w64-x86_64-gtk3
when done rename the folder msys2 in msys2-gtk and set path for libs inside, dont install other because some program for solve dependence update gcc too and tha make the error.

If you need some tool or application from Msys2 then install in a new folder and use it separately, the GTK3 leave alone without GCC
You can update the msys2 with only GTK3 without install other tool and no problem will come (with me work fine )
wallyg
Posts: 267
Joined: May 08, 2009 7:08
Location: Tucson Arizona

Re: [SOLVED] Multiple Errors when include "gtk/gtk.bi"

Post by wallyg »

Thank you very much. I appreciate you taking the time to help.

Wally
coderJeff
Site Admin
Posts: 4313
Joined: Nov 04, 2005 14:23
Location: Ontario, Canada
Contact:

Re: [SOLVED] Multiple Errors when include "gtk/gtk.bi"

Post by coderJeff »

Continued from FreeBASIC 1.20 Development
exagonx wrote: Jun 25, 2023 15:33
coderJeff wrote: Jun 25, 2023 13:18
- C11 is a language standard
When I compile a software with GTK (MSys2 environment) with old C 9.xx Version its work fine.

But when I make a update with C version 11 then give error during compiling missing header or function but the software allready compiled with old C work fine with updated runtime.

At moment I solved keeping a not updated Msys2 for compiling and I use the latest version of GTK for run the software its work fine, I writed A post about that problem is a common issue where my suggestion of not install or update C environment in MSys2 work fine.

viewtopic.php?t=31562
exagonx wrote: Jun 23, 2022 1:14 Unfortunately GTK comes only in source code, and the only platform that compiles it for windows is msys2
I feel like this still could be a mismatch of tools.

MSYS2 is a build environment with several subsystems (https://www.msys2.org/wiki/MSYS2-introduction/):
At least 3 of them are:
- mingw32 - build system for targeting windows native 32-bit application
- mingw64 - build system for targeting windows native 64-bit application
- msys2 - build system for targeting posix like system (and I think meant only for development and building not as an end user runtime environment)

NOTE: The build environment is not a toolchain on it's own.

A toolchain is some version of gcc + binutils + libraries. Some toolchains are for a single target and some toolchains can cross-compile to multiple targets depending on command line options.

A toolchain is meant to run in some build environment and produce executables for some runtime enivornment. These two environments could be same or different depending on what toolchain is installed and what options used.

Mingw-w64 (https://www.mingw-w64.org/): is a runtime environment (https://www.mingw-w64.org) - this has all the things needed to run programs built for this run-time environment.

Winlibs (https://winlibs.com/) is a toolchain based on Mingw-w64 that runs natively on windows and builds programs that will run natively on windows.

FreeBASIC default standalone binary releases for windows (both fbc 1.09.0 and latest fbc 1.10.0) are built using WinLibs
- note that when building fbc itself, the default executable is fbc.exe, but release packages rename this to fbc32.exe and fbc64.exe

FreeBASIC (fbc) can be built in one of two ways:
- 'normal' in which case fbc.exe is expected to be installed in to the build environment (like msys2) i.e. with 'make install'. binaries, libraries, headers, will be copied to the build environment
- 'standalone' in which case fbc.exe is expected to be used from it's own directory with it's own copies of binaries and libraries. The release packages include binaries from WinLibs.

All static libraries (maybe not DLL's) need to be compiled with the same toolchain - i.e. same intended target. For example using MSYS2 as the build environment, but Winlibs as the toolchain to build gtk.

TLDR;
Ensure that freebasic (fbc) is built and installed for the intended build environment and that all libraries (gtk, libfb, etc) are built with the same toolchain for the same intended runtime environment.
Post Reply