macos 14.2 Compile Gfortran-13.2 using gtk-4-fortran --Error linker mapping
FR54T opened this issue · 11 comments
Hi,
I have some issue with generated compile with gtk-fortran in mac, here the information i attacht:
and sory im newbie in fortran too
Steps to reproduce to compile file bazzars.f90 the behavior is:
- using bazzar.f90 on zsh and bash terminal
- gfortran bazaar.f90 $(pkg-config --cflags --libs gtk-4-fortran)
Error Information:
ld: unknown option: -R/usr/local/lib
collect2: error: ld returned 1 exit status
Cause Error investigate :
file config error at: /usr/local/lib/pkgconfig gtk-4-fortran.pc
cause error: Xlinker path :Libs: -Xlinker -R${libdir} -l${libname} on gtk-4-fortran.pc
How to resolve it? Many Thanks
Your system:
- OS version: [MacosX 14.3 64 bits]
- Terminal using: Zsh and bash
- Gtk-Fortran version: Gtk-Fortan 4.5
- Architecture: Intel X86_64
- Compiler version: [GCC 13.2.0 gfortran 13.2.0]
- GTK branch: gtk4 macos via homebrew
Additional context
trying with all option with cmake config still error.
Welcome @FR54T
have you typed the following commands?
$ export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
$ export LIBRARY_PATH=/usr/local/lib/
See https://github.com/vmagnin/gtk-fortran/wiki/Installation#macos
Welcome @FR54T
have you typed the following commands?
$ export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig $ export LIBRARY_PATH=/usr/local/lib/See https://github.com/vmagnin/gtk-fortran/wiki/Installation#macos
yes, this path already insert to path profile before iam installing gtk-fortran
A few question to try to understand the problem:
- Have you installed gtk-fortran with the command
sudo make install
? - What is the result of the command
pkg-config --cflags --libs gtk-4-fortran
? - Do you see the gtk-fortran library when typing
ls /usr/local/lib
?
Hii,
Have you installed gtk-fortran with the command sudo make install ? I has follow instruction from https://github.com/vmagnin/gtk-fortran/wiki/Installation#macos --for with sudo make install
What is the result of the command pkg-config --cflags --libs gtk-4-fortran ?
Do you see the gtk-fortran library when typing ls /usr/local/lib ? yes, heres for list gtk-fortran libs
ls /usr/local/lib
libgtk-4-fortran.4.5.0.dylib libgtk-4-fortran.a libgtk-4-fortran.dylib
heres for anaother comand $ gtk-4-fortran from terminal:
why information gtk-4-fortran version on my console.
$ gtk-4-fortran
(GTK 4.12.3 and GLib 2.78.1)
Compiled with GCC version 13.2.0 on ?, linked to GTK 4.12.4
Thanks
In Linux the end of the pkgconfig
command is:
...
-Xlinker -R/usr/local/lib -lgtk-4-fortran -lgtk-4 -lpangocairo-1.0 -lpango-1.0 -lharfbuzz -lgdk_pixbuf-2.0 -lcairo-gobject -lcairo -lgraphene-1.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0
But in your output I can not see -R/usr/local/lib
.
I will try to investigate when I have access to a macOS machine.
The <unknown>
strings in the output of your gtk-4-fortran
command is also odd. But it could be unrelated to the other problem (or not?). It comes from this line in src/gtk-fortran.f90
:
call c_f_string_copy_alloc(g_get_prgname(), name_string)
And if you run the ctest
command in the gtk-fortran/build/
directory, do the examples run?
Hi,
I Has Test , pls see the result.
But in your output I can not see -R/usr/local/lib.
Here The gtk-fortran output from my source /gtk-fortran/build/src
gtk-4-fortran.pc.zip
$ctest gtk-fortran/build/
Test project /Users/users-home/gtk-fortran/build
Start 1: gtk-4-fortran
1/41 Test #1: gtk-4-fortran .................... Passed 1.00 sec
Start 2: gtkzero_gapp
2/41 Test #2: gtkzero_gapp ..................... Passed 11.78 sec
Start 3: gtkhello
3/41 Test #3: gtkhello ......................... Passed 5.02 sec
Start 4: list_demo
4/41 Test #4: list_demo ........................ Passed 12.71 sec
Start 5: gio_demo
5/41 Test #5: gio_demo .........................Subprocess killedException: 106.05 sec
Start 6: tests
6/41 Test #6: tests ............................ Passed 0.47 sec
Start 7: tests_gtk_sup
7/41 Test #7: tests_gtk_sup .................... Passed 0.61 sec
Start 8: notebooks
8/41 Test #8: notebooks ........................ Passed 10.53 sec
Start 9: julia_pixbuf
9/41 Test #9: julia_pixbuf ..................... Passed 3.43 sec
Start 10: mandelbrot_pixbuf
10/41 Test #10: mandelbrot_pixbuf ................ Passed 2.53 sec
Start 11: mandelbrot_pixbuf_zoom
11/41 Test #11: mandelbrot_pixbuf_zoom ........... Passed 2.79 sec
Start 12: menubar
12/41 Test #12: menubar .......................... Passed 2.64 sec
Start 13: cairo-tests
13/41 Test #13: cairo-tests ...................... Passed 3.25 sec
Start 14: cairo-basics
14/41 Test #14: cairo-basics ..................... Passed 2.74 sec
Start 15: cairo-basics-click
15/41 Test #15: cairo-basics-click ............... Passed 2.04 sec
Start 16: bazaar
16/41 Test #16: bazaar ........................... Passed 3.33 sec
Start 17: pixbuf_without_gui
17/41 Test #17: pixbuf_without_gui ............... Passed 0.38 sec
Start 18: regex
18/41 Test #18: regex ............................ Passed 0.34 sec
Start 19: hl_assistant
19/41 Test #19: hl_assistant ..................... Passed 23.86 sec
Start 20: hl_choosers
20/41 Test #20: hl_choosers ...................... Passed 7.93 sec
Start 21: hl_combo
21/41 Test #21: hl_combo ......................... Passed 2.70 sec
Start 22: hl_containers
22/41 Test #22: hl_containers .................... Passed 2.47 sec
Start 23: hl_dialog
23/41 Test #23: hl_dialog ........................ Passed 4.50 sec
Start 24: hl_list1
24/41 Test #24: hl_list1 ......................... Passed 2.80 sec
Start 25: hl_list_n
25/41 Test #25: hl_list_n ........................ Passed 2.33 sec
Start 26: hl_list_renderers
26/41 Test #26: hl_list_renderers ................ Passed 5.56 sec
Start 27: hl_pbar
27/41 Test #27: hl_pbar .......................... Passed 12.39 sec
Start 28: hl_sliders
28/41 Test #28: hl_sliders ....................... Passed 2.61 sec
Start 29: hl_sliders2
29/41 Test #29: hl_sliders2 ...................... Passed 2.19 sec
Start 30: hl_textview
30/41 Test #30: hl_textview ...................... Passed 2.78 sec
Start 31: hl_tree
31/41 Test #31: hl_tree .......................... Passed 2.03 sec
Start 32: hl_cairo1
32/41 Test #32: hl_cairo1 ........................ Passed 3.30 sec
Start 33: hl_cairo_clock
33/41 Test #33: hl_cairo_clock ................... Passed 2.82 sec
Start 34: hl_cairo_viewer
34/41 Test #34: hl_cairo_viewer .................. Passed 4.46 sec
Start 35: hl_infobar
35/41 Test #35: hl_infobar ....................... Passed 12.57 sec
Start 36: hl_plplot8e
36/41 Test #36: hl_plplot8e ...................... Passed 4.29 sec
Start 37: hl_plplot17e
37/41 Test #37: hl_plplot17e .....................Subprocess abortedException: 1.57 sec
Start 38: hl_plplot17e_gto
38/41 Test #38: hl_plplot17e_gto .................Subprocess aborted***Exception: 1.40 sec
Start 39: hl_plplot30e
39/41 Test #39: hl_plplot30e ..................... Passed 3.14 sec
Start 40: hl_plplot1e
40/41 Test #40: hl_plplot1e ...................... Passed 2.37 sec
Start 41: hl_plplot4e
41/41 Test #41: hl_plplot4e ...................... Passed 7.43 sec
93% tests passed, 3 tests failed out of 41
Total Test time (real) = 289.24 sec
The following tests FAILED:
5 - gio_demo (Subprocess killed)
37 - hl_plplot17e (Subprocess aborted)
38 - hl_plplot17e_gto (Subprocess aborted)
Errors while running CTest
Output from these tests are in: /Users/users-home/gtk-fortran/build/Testing/Temporary/LastTest.log
Use "--rerun-failed --output-on-failure" to re-run the failed cases verbosely.
Test-log.zip
Thanks
I have made some tests on a macOS 12.7:
the pkg-config
does return ... -Xlinker -R/usr/local/lib -lgtk-4-fortran ...
but the -R
does not seem to be recognized by the ld
linker. But by manually replacing -R
by -L
it works.
Can you try to edit the gtk-fortran/src/gtk-fortran.pc.in
file? The last line is:
Libs: -Xlinker -R${libdir} -l${libname}
- Just replace
-R
by-L
- Then rebuild (maybe not necessary) and reinstall gtk-fortran with
sudo make install
- Retry
gfortran bazaar.f90 $(pkg-config --cflags --libs gtk-4-fortran)
On my side, I will investigate further the exact definitions of those two -R
and -L
options.
Hii, @vmagnin
Thank You. Its works now. gfortran compiling bring -- a.out now.
what kind diffrent for -R and -L explanation for base Linux and Macos on cmake process ouput ? any clue
Maybe we should use:
-Xlinker -rpath /usr/local/lib -L/usr/local/lib -lgtk-4-fortran
My understanding is that -rpath
(or -Rdirectory
) is for .so
and -L
for .a
libraries, which are both in that directory /usr/local/lib
The GNU linker ld manual:
https://sourceware.org/binutils/docs/ld/
The line Libs: -Xlinker -R${libdir} -l${libname}
is in gtk-fortran since May 2011. I must therefore investigate and discuss further with people familiar with linking problems before modifying it...
The macOS linker ld64 does not accept the GNU ld syntax -Xlinker -rpath=${libdir}
, but would accept a space instead of =
. In that case -Xlinker
must be used twice to pass each part of the option to the linker:
-Xlinker -rpath -Xlinker ${libdir}
But curiously, I had a problem with pkgconfig in Ubuntu with that syntax, the first -Xlinker
being not returned (I have instead obtained: -rpath -Xlinker /usr/local/lib
).
Happily, there is an alternative syntax with the -Wl
option that is correctly treated in all systems:
-Wl,-rpath,${libdir}
Here, there is only one option -Wl
with the different parts of the option to pass to the linker separated by commas.
Note that the -rpath
option is writting the library path directly inside the executable, as can be verified by this command:
$ readelf --dynamic a.out
Finally, I have also decided to add the missing -L
option that "add path searchdir to the list of paths that ld will search for archive [static] libraries and ld control scripts". The last line of the pkgconfig file is now therefore:
Libs: -L${libdir} -Wl,-rpath,${libdir} -l${libname}
I have pushed it in my dev branch https://github.com/vmagnin/gtk-fortran/tree/gtk4-vmagnin where I will prepare the next release (probably in May), and tested linking in macOS, Ubuntu, Fedora, FreeBSD and MSYS2/Windows10.
Fixed in gtk-fortran 4.6.0.