Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Gtk linking in VS

rmoortgat
새로운 기여자 I
590 조회수

I get the following link error:

 

Compiling with Intel® Fortran Compiler 2025.1.1 [Intel(R) 64]...
ifx /nologo /O2 /I"C:\msys64\ucrt64\include\gtk-3.0 C:\msys64\ucrt64\include\pango-1.0 C:\msys64\ucrt64\include\harfbuzz C:\msys64\ucrt64\include\cairo C:\msys64\ucrt64\include\freetype2 C:\msys64\ucrt64\include\pixman-1 C:\msys64\ucrt64\include\gdk-pixbuf-2.0 C:\msys64\ucrt64\include\libpng16 C:\msys64\ucrt64\include\webp C:\msys64\ucrt64\include\atk-1.0 C:\msys64\ucrt64\include\fribidi C:\msys64\ucrt64\include\glib-2.0" /I"C:\msys64\ucrt64\lib\glib-2.0\include" /I"D:\FORTRAN\GTK\gtk\x64\Release" /module:"x64\Release\\" /object:"x64\Release\\" /libs:dll /threads /c /Qlocation,link,"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.44.35207\bin\HostX64\x64" /Qm64 "D:\FORTRAN\GTK\MyGtkApp\Source1.f90"
D:\FORTRAN\GTK\MyGtkApp\Source1.f90(40): internal error: Please visit 'http://www.intel.com/software/products/support' for assistance.
  call gtk_init()
^
D:\FORTRAN\GTK\MyGtkApp\Source1.f90(40): catastrophic error: Internal Compiler Error: Ref module: ffe_ss_lm.c
compilation aborted for D:\FORTRAN\GTK\MyGtkApp\Source1.f90 (code 1)


MyGtkApp - 1 error(s), 0 warning(s)

Code:

program gtk_example
  use, intrinsic :: iso_c_binding
  implicit none

  ! --- Interface Block for GTK Functions ---
  interface
    ! Simplified GTK initialization as subroutine
    subroutine gtk_init() bind(c, name='gtk_init')
    end subroutine

    function gtk_window_new_c(type) bind(c, name='gtk_window_new')
      import :: c_ptr, c_int
      integer(c_int), value :: type
      type(c_ptr) :: gtk_window_new_c
    end function

    subroutine gtk_window_set_title_c(window, title) bind(c, name='gtk_window_set_title')
      import :: c_ptr, c_char
      type(c_ptr), value :: window
      character(kind=c_char), dimension(*), intent(in) :: title
    end subroutine

    subroutine gtk_widget_show_all_c(widget) bind(c, name='gtk_widget_show_all')
      import :: c_ptr
      type(c_ptr), value :: widget
    end subroutine

    subroutine gtk_main_c() bind(c, name='gtk_main')
    end subroutine

    subroutine gtk_main_quit_c() bind(c, name='gtk_main_quit')
    end subroutine
  end interface

  integer :: i, num_windows = 1
  type(c_ptr) :: window
  integer(c_int), parameter :: GTK_WINDOW_TOPLEVEL = 0
  
  ! Simple GTK initialization without status check
  call gtk_init()

  do i = 1, num_windows
    window = gtk_window_new_c(GTK_WINDOW_TOPLEVEL)
    if (.not. c_associated(window)) then
      print *, "Failed to create window"
      cycle
    end if
    
    call gtk_window_set_title_c(window, to_c_string("My GTK Window " // int_to_string(i)))
    call gtk_widget_show_all_c(window)
  enddo

  call gtk_main_c()

contains

  function to_c_string(f_string) result(c_string)
    character(len=*), intent(in) :: f_string
    character(kind=c_char, len=:), allocatable :: c_string
    integer :: i, n
    
    n = len_trim(f_string)
    allocate(character(kind=c_char, len=n+1) :: c_string)
    
    do i = 1, n
      c_string(i:i) = f_string(i:i)
    end do
    c_string(n+1:n+1) = c_null_char
  end function to_c_string

  function int_to_string(num) result(str)
    integer, intent(in) :: num
    character(:), allocatable :: str
    character(20) :: temp
    write(temp, '(I0)') num
    str = trim(temp)
  end function int_to_string

end program gtk_example

Any idea?

Thx

Roger

 

2 응답
andrew_4619
명예로운 기여자 III
545 조회수

That compiles OK (without ICE)  on 2025.1.0 on Windows

rmoortgat
새로운 기여자 I
445 조회수

Thanks! In the meantime I got it working too. However, making gtk-fortran working with VS and Intel ifx is a very bumpy path. Each time you think you're there, another dependency popping up. I wonder if it's worth the effort. After all I just need an interface for some technical structural calculations. I'm considering alternatives like there are, FLT, Qt, wxWidgets, TUI ncurses.

 

Roger

0 포인트
응답