Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fpm and Plplot with gtk3/4: "multiple definition of `main'" error (support needed) #284

Open
lllaxmatist opened this issue May 21, 2024 · 10 comments
Assignees
Labels

Comments

@lllaxmatist
Copy link

When try to compile project with PLplot support i get errors both on windows and on Linux.
(without inclusion of Plplot project runs perfect)

Errors on MSYS2:
lllax@LAPTOP-KVC9DPIV UCRT64 /home/FPMprojects/circle_fpm
$   fpm run --flag "$(pkg-config --cflags --libs plplot plplot-fortran)"
circle_fpm.f90                         done.
circle_fpm.exe                         failed.
[100%] Compiling...
D:/Programs/MSYS2/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: build\gfortran_B17540FEB7ADF59B\circle_fpm\app_circle_fpm.f90.o
:circle_fpm.f90:(.text+0x1254): multiple definition of `main'; D:/Programs/MSYS2/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../lib/libmingw32.a(lib64_libmingw
32_a-crtexewin.o):C:/M/B/src/mingw-w64/mingw-w64-crt/crt/crtexewin.c:23: first defined here
D:/Programs/MSYS2/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: D:/Programs/MSYS2/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2
.0/../../../../lib/libmingw32.a(lib64_libmingw32_a-crtexewin.o): in function `main':
C:/M/B/src/mingw-w64/mingw-w64-crt/crt/crtexewin.c:67:(.text.startup+0xbd): undefined reference to `WinMain'
D:/Programs/MSYS2/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: build\gfortran_0913D9F560CF5CAD\circle_fpm\libcircle_fpm.a(buil
d_dependencies_gtk-fortran_src_gtk-draw-hl.f90.o):gtk-draw-hl.f9:(.text+0x507): undefined reference to `gdk_cairo_set_source_pixbuf'
D:/Programs/MSYS2/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: build\gfortran_0913D9F560CF5CAD\circle_fpm\libcircle_fpm.a(buil
d_dependencies_gtk-fortran_src_gtk-draw-hl.f90.o):gtk-draw-hl.f9:(.text+0x663): undefined reference to `gdk_pixbuf_get_from_surface'
collect2.exe: error: ld returned 1 exit status
<ERROR> Compilation failed for object " circle_fpm.exe "
<ERROR> stopping due to failed compilation
STOP 1

If i exclude all plplot from code (comment out, only usage of plplot remain) the erors keeps in code.

p.s. :
On Linux i get different errors (ill paste it as i get to my PC in next post).

p.p.s. :
I do need only simple 2d plots, maybe there is alternative lib to use instead?

@vmagnin
Copy link
Owner

vmagnin commented May 21, 2024

Concerning using plplot with fpm and gtk-fortran see: https://github.com/vmagnin/gtk-fortran/wiki/Tutorial-5

In that tutorial, I used single quotes:

$  fpm run --flag '$(pkg-config --cflags --libs plplot plplot-fortran)'

Can you try with single quotes? (to avoid the expansion of $() before it is transmitted to the compiler)

For alternative plotting programs, see: https://github.com/vmagnin/gtk-fortran/wiki/Alternatives-to-gtk-fortran
Maybe ogpf?

@lllaxmatist
Copy link
Author

Double quotes is MSYS2 thing, because winfows dislike single ones much.

@vmagnin
Copy link
Owner

vmagnin commented May 21, 2024

MSYS2 offers you a bash environment and single/double quotes have the same behaviour as in Linux. This is what I obtain in MSYS2:

$ echo '$(pkg-config --cflags --libs plplot plplot-fortran)'
$(pkg-config --cflags --libs plplot plplot-fortran)

$ echo "$(pkg-config --cflags --libs plplot plplot-fortran)"
-ID:/Logiciels/MSYS2/ucrt64/include/plplot -ID:/Logiciels/MSYS2/ucrt64/lib/fortran/modules/plplot -ID:/Logiciels/MSYS2/ucrt64/include/pango-1.0 -ID:/Logiciels/MSYS2/ucrt64/include/cairo -ID:/Logiciels/MSYS2/ucrt64/include/pixman-1 -ID:/Logiciels/MSYS2/ucrt64/include/fribidi -ID:/Logiciels/MSYS2/ucrt64/include/harfbuzz -ID:/Logiciels/MSYS2/ucrt64/include/freetype2 -ID:/Logiciels/MSYS2/ucrt64/include/libpng16 -ID:/Logiciels/MSYS2/ucrt64/include/glib-2.0 -ID:/Logiciels/MSYS2/ucrt64/lib/glib-2.0/include -DQT_CORE_LIB -ID:/Logiciels/MSYS2/ucrt64/include/QtCore -DQT_GUI_LIB -ID:/Logiciels/MSYS2/ucrt64/include/QtGui -DQT_PRINTSUPPORT_LIB -ID:/Logiciels/MSYS2/ucrt64/include/QtPrintSupport -DQT_WIDGETS_LIB -ID:/Logiciels/MSYS2/ucrt64/include/QtWidgets -DQT_SVG_LIB -ID:/Logiciels/MSYS2/ucrt64/include/QtSvg -DHPDF_DLL -ID:/Logiciels/MSYS2/ucrt64/lib/wx/include/msw-unicode-3.2 -ID:/Logiciels/MSYS2/ucrt64/include/wx-3.2 -D_FILE_OFFSET_BITS=64 -DWXUSINGDLL -D__WXMSW__ -DUNICODE -D_UNICODE -lplplotfortran -lplplot -lpangocairo-1.0.dll -lpango-1.0.dll -lgobject-2.0.dll -lglib-2.0.dll -lintl.dll -lharfbuzz.dll -lcairo.dll -lgd.dll -lpng.dll -lz.dll -ljpeg.dll -ltcl.dll -ltk.dll -pipe -Wl,--subsystem,windows -mwindows -lwx_baseu-3.2.dll -lwx_mswu_core-3.2.dll -lhpdf.dll -lgdi32 -lcomdlg32 -lcomctl32 -lshp.dll -lfreetype.dll -lQt5Core.dll -lQt5Gui.dll -lQt5PrintSupport.dll -lQt5Widgets.dll -lQt5Svg.dll -lcsirocsa -lcsironn -lqhull -lqsastime -lstdc++.dll -LD:/Logiciels/MSYS2/ucrt64/lib/gcc/x86_64-w64-mingw32/13.2.0 -lpthread.dll -ladvapi32 -lshell32 -luser32 -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lkernel32

As you can see, nothing is evaluated in a single quotes string. With double quotes, the $(...) expression is expanded.

Be sure that on your keyboard you use the vertical single quote.

@lllaxmatist
Copy link
Author

lllaxmatist commented May 21, 2024

But with single ones i get:

`
lllax@LAPTOP-KVC9DPIV UCRT64 /home/FPMprojects/circle_fpm
$   fpm run --flag '$(pkg-config --cflags --libs plplot plplot-fortran)'
plplot_extra.f90                       failed.
gdk-auto.f90                           failed.
gdk-pixbuf-auto.f90                    failed.
glib-auto.f90                          failed.
cairo-auto.f90                         failed.
[ 19%] Compiling...
gfortran: error: unrecognized command-line option '--cflags'
gfortran: error: unrecognized command-line option '--libs'; did you mean '--libs='?
gfortran: error: unrecognized command-line option '--cflags'
gfortran: error: unrecognized command-line option '--libs'; did you mean '--libs='?
gfortran: error: unrecognized command-line option '--cflags'
gfortran: error: unrecognized command-line option '--libs'; did you mean '--libs='?
gfortran: error: unrecognized command-line option '--cflags'
gfortran: error: unrecognized command-line option '--libs'; did you mean '--libs='?
gfortran: error: unrecognized command-line option '--cflags'
gfortran: error: unrecognized command-line option '--libs'; did you mean '--libs='?
<ERROR> Compilation failed for object " build_dependencies_gtk-fortran_src_cairo-auto.f90.o "
<ERROR> Compilation failed for object " build_dependencies_gtk-fortran_src_gdk-auto.f90.o "
<ERROR> Compilation failed for object " build_dependencies_gtk-fortran_src_gdk-pixbuf-auto.f90.o "
<ERROR> Compilation failed for object " build_dependencies_gtk-fortran_src_glib-auto.f90.o "
<ERROR> Compilation failed for object " build_dependencies_gtk-fortran_src_plplot_extra.f90.o "
<ERROR> stopping due to failed compilation
STOP 1
`

@vmagnin
Copy link
Owner

vmagnin commented May 21, 2024

GFortran should not receive those flags:

gfortran: error: unrecognized command-line option '--cflags'
gfortran: error: unrecognized command-line option '--libs'; 

which are flags of the pkg-config command.
Have you installed that package?
https://packages.msys2.org/package/pkgconf?repo=msys

Does that command work?

$ pkg-config --cflags --libs plplot plplot-fortran

@lllaxmatist
Copy link
Author

lllaxmatist commented May 21, 2024

It does something (wall of text).

$ pkg-config --cflags --libs plplot plplot-fortran
-ID:/Programs/MSYS2/ucrt64/include/plplot -ID:/Programs/MSYS2/ucrt64/lib/fortran/modules/plplot -ID:/Programs/MSYS2/ucrt64/include/pango-1.0 -ID:/Programs/MSYS2/ucrt64/incl
ude/cairo -ID:/Programs/MSYS2/ucrt64/include/pixman-1 -ID:/Programs/MSYS2/ucrt64/include/fribidi -ID:/Programs/MSYS2/ucrt64/include/harfbuzz -ID:/Programs/MSYS2/ucrt64/incl
ude/freetype2 -ID:/Programs/MSYS2/ucrt64/include/libpng16 -ID:/Programs/MSYS2/ucrt64/include/glib-2.0 -ID:/Programs/MSYS2/ucrt64/lib/glib-2.0/include -DQT_CORE_LIB -ID:/Pro
grams/MSYS2/ucrt64/include/QtCore -DQT_GUI_LIB -ID:/Programs/MSYS2/ucrt64/include/QtGui -DQT_PRINTSUPPORT_LIB -ID:/Programs/MSYS2/ucrt64/include/QtPrintSupport -DQT_WIDGETS
_LIB -ID:/Programs/MSYS2/ucrt64/include/QtWidgets -DQT_SVG_LIB -ID:/Programs/MSYS2/ucrt64/include/QtSvg -DHPDF_DLL -ID:/Programs/MSYS2/ucrt64/lib/wx/include/msw-unicode-3.2
 -ID:/Programs/MSYS2/ucrt64/include/wx-3.2 -D_FILE_OFFSET_BITS=64 -DWXUSINGDLL -D__WXMSW__ -DUNICODE -D_UNICODE -lplplotfortran -lplplot -lpangocairo-1.0.dll -lpango-1.0.dl
l -lgobject-2.0.dll -lglib-2.0.dll -lintl.dll -lharfbuzz.dll -lcairo.dll -lgd.dll -lpng.dll -lz.dll -ljpeg.dll -ltcl.dll -ltk.dll -pipe -Wl,--subsystem,windows -mwindows -l
wx_baseu-3.2.dll -lwx_mswu_core-3.2.dll -lhpdf.dll -lgdi32 -lcomdlg32 -lcomctl32 -lshp.dll -lfreetype.dll -lQt5Core.dll -lQt5Gui.dll -lQt5PrintSupport.dll -lQt5Widgets.dll
-lQt5Svg.dll -lcsirocsa -lcsironn -lqhull -lqsastime -lstdc++.dll -LD:/Programs/MSYS2/ucrt64/lib/gcc/x86_64-w64-mingw32/13.2.0 -lpthread.dll -ladvapi32 -lshell32 -luser32 -
lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lkernel32

@vmagnin
Copy link
Owner

vmagnin commented May 21, 2024

So pkg-config works. Its role is to pass to the compiler and linker all those parameters and flags concerning the needed libraries installed in your system, and to save you a lot of work!

@vmagnin
Copy link
Owner

vmagnin commented May 21, 2024

I have made a test in MSYS2 with a fpm project depending on gtk-fortran and PLplot and had the same errors as you with the single quotes. It was better with double quotes, but finally the compilation failed, with the same kind of errors that occur when I try to build gtk-fortran with PLplot examples in MSYS2.

As you can see Issue #269 it started to fail somewhere in 2022 (it was working before), but I have never find a solution.

@vmagnin vmagnin added Bug Windows MS Windows specific labels May 21, 2024
@vmagnin
Copy link
Owner

vmagnin commented May 22, 2024

I have finally fixed the issue #269 on my system and can now compile programs using PLplot (with CMake in gtk-fortran).

@vmagnin
Copy link
Owner

vmagnin commented May 22, 2024

But with fpm, it still fails.

@vmagnin vmagnin changed the title Plplot with gtk3 "multiple definition of `main'" error (support needed) fpm and Plplot with gtk3/4: "multiple definition of `main'" error (support needed) May 22, 2024
@vmagnin vmagnin self-assigned this May 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants