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

[Bug] loading ctypes fails on Windows #2288

Closed
petrasovaa opened this issue Mar 31, 2022 · 12 comments
Closed

[Bug] loading ctypes fails on Windows #2288

petrasovaa opened this issue Mar 31, 2022 · 12 comments
Labels
bug Something isn't working windows Microsoft Windows specific
Milestone

Comments

@petrasovaa
Copy link
Contributor

Describe the bug
I installed latest 8.1.dev standalone installer (checked the checkbox to install the microsoft libraries) and I GUI starts but with error because the grass.lib.* imports fail. So 3D view or digitizer don't work.

To Reproduce
It seems not all installations have the same problem.

System description (please complete the following information):

  • Operating System: Windows 10 Education
  • GRASS GIS version: latest main
GRASS version: 8.1.dev                                                          
Code revision: 5561ffe04                                                        
Build date: 2022-03-30                                                          
Build platform: x86_64-w64-mingw32                                              
GDAL: 3.4.2                                                                     
PROJ: 9.0.0                                                                     
GEOS: 3.10.2                                                                    
SQLite: 3.38.1                                                                  
Python: 3.9.5                                                                   
wxPython: 4.1.1                                                                 
Platform: Windows-10-10.0.19042-SP0 

Additional context
I tried to understand this little more and it seems it can find the file (e.g. lib/grasslib_raster.8.1.dll) but in Lookup class I get:

[WinError 127] The specified procedure could not be found
@petrasovaa petrasovaa added bug Something isn't working windows Microsoft Windows specific labels Mar 31, 2022
@petrasovaa petrasovaa added this to the 8.4.0 milestone Mar 31, 2022
@ninsbl
Copy link
Member

ninsbl commented May 19, 2022

I just tried with the new GRASS 8.3 (and 8.0) in OSGeo4W, and there this seems to work fine...
So this is probably limited to the standalone installer. The installer changed a bit not too ling ago. Maybe fxed there now too?

@tmszi
Copy link
Member

tmszi commented Jul 24, 2022

Similar error during compilation GRASS GIS Addons (OS MS Windows) on CVUT university server e.g.

wx.metadata:

  File "C:\Users\landamar\grass_packager\grass820\addons\wx.metadata\scripts\g.gui.cswbrowser.py", line 26, in <module>
    from mdlib.cswlib import CSWBrowserPanel, CSWConnectionPanel
  File "C:\msys64\usr\src\grass8-addons\src\gui\wxpython\wx.metadata\mdlib\cswlib.py", line 44, in <module>
    from .mdeditorfactory import ADD_RM_BUTTON_SIZE
  File "C:\msys64\usr\src\grass8-addons\src\gui\wxpython\wx.metadata\mdlib\mdeditorfactory.py", line 44, in <module>
    from . import mdutil
  File "C:\msys64\usr\src\grass8-addons\src\gui\wxpython\wx.metadata\mdlib\mdutil.py", line 31, in <module>
    from grass.pygrass.utils import get_lib_path
  File "C:\msys64\usr\src\grass820\dist.x86_64-w64-mingw32\etc\python\grass\pygrass\utils.py", line 9, in <module>
    import grass.lib.raster as libraster
  File "C:\msys64\usr\src\grass820\dist.x86_64-w64-mingw32\etc\python\grass\lib\raster.py", line 30, in <module>
    _libs["grass_raster.8.2"] = load_library("grass_raster.8.2")
  File "C:\msys64\usr\src\grass820\dist.x86_64-w64-mingw32\etc\python\grass\lib\ctypes_loader.py", line 105, in __call__
    raise ImportError("Could not load %s." % libname)
ImportError: Could not load grass_raster.8.2.

i.gravity:

C:/Users/landamar/grass_packager/grass820/addons/i.gravity/bin/i.gravity.exe: error while loading shared libraries: libgrass_raster.8.2.dll: cannot open shared object file: No such file or directory
make: *** [/c/msys64/usr/src/grass820/include/Make/Html.make:14: i.gravity.tmp.html] Error 1

and etc.

@tmszi
Copy link
Member

tmszi commented Jul 24, 2022

Seems there are some errors during compilation MS Windows GRASS GIS version on CVUT university server:

C:/msys64/usr/src/grass82/dist.x86_64-w64-mingw32/bin/test.raster3d.lib.exe: error while loading shared libraries: libgrass_gis.8.2.dll: cannot open shared object file: No such file or directory
make[3]: *** [../../../include/Make/Html.make:14: test.raster3d.lib.tmp.html] Error 1
make[3]: Target 'first' not remade because of errors.

Full compilation log.

Full error log.

@tmszi
Copy link
Member

tmszi commented Jul 24, 2022

WinGRASS-8.3.dev-56986425a-1-Setup.exe standalone installer.

Launching <wxpython> GUI in the background, please wait...
Microsoft Windows [Version 10.0.17763.1935]
(c) 2018 Microsoft Corporation. All rights reserved.

C:\Users\IEUser>wxdigit.py: Could not load grass_vector.8.3.
wxdigit.py: Could not load grass_vector.8.3.
wxnviz.py: Could not load grass_g3d.8.3.
Traceback (most recent call last):
  File "C:\Program Files\GRASS GIS 8.3\Python39\lib\site-packages\wx\core.py", line 3407, in <lambda>
    lambda event: event.callable(*event.args, **event.kw) )
  File "C:\Program Files\GRASS GIS 8.3\gui\wxpython\wxgui.py", line 95, in show_main_gui
    mainframe = GMFrame(parent=None, id=wx.ID_ANY, workspace=self.workspaceFile)
  File "C:\Program Files\GRASS GIS 8.3\gui\wxpython\main_window\frame.py", line 164, in __init__
    self.BuildPanes()
  File "C:\Program Files\GRASS GIS 8.3\gui\wxpython\main_window\frame.py", line 533, in BuildPanes
    self.statusbar = SbMain(parent=self, giface=self._giface)
  File "C:\Program Files\GRASS GIS 8.3\gui\wxpython\lmgr\statusbar.py", line 38, in __init__
    self.mask = SbMask(self.widget, self.giface)
  File "C:\Program Files\GRASS GIS 8.3\gui\wxpython\lmgr\statusbar.py", line 87, in __init__
    self.Refresh()
  File "C:\Program Files\GRASS GIS 8.3\gui\wxpython\lmgr\statusbar.py", line 120, in Refresh
    if gs.find_file(
KeyError: 'name'

@tmszi
Copy link
Member

tmszi commented Jul 25, 2022

WinGRASS-8.3.dev-56986425a-1-Setup.exe standalone installer with installed Important Microsoft Runtime DLLs.

It seems libgrass_vector.8.3.dll has missing gdal304.dll and this is reason why libgrass_vector.8.3.dll isn't loaded via Python ctypes (error mention above).

IEUser@MSEDGEWIN10 MSYS /c/Program Files/GRASS GIS 8.3/lib
$ ldd libgrass_vector.8.3.dll | grep "not found"
        gdal304.dll => not found

but gdal304.dll path is C:\Program Files\GRASS GIS 8.3\extrabin\.

Then I copy gdal304.dll into C:\Program Files\GRASS GIS 8.3\lib dir.

IEUser@MSEDGEWIN10 MSYS /c/Program Files/GRASS GIS 8.3/lib
$ ldd libgrass_vector.8.3.dll | grep gdal
        gdal304.dll => /c/Program Files/GRASS GIS 8.3/lib/gdal304.dll (0x7ffec2ab0000)

but gdal304.dll has missing dll dependency too.

IEUser@MSEDGEWIN10 MSYS /c/Program Files/GRASS GIS 8.3/extrabin
$ ldd gdal304.dll | grep "not found"
        jpeg.dll => not found
        api-ms-win-crt-runtime-l1-1-0.dll => not found
        api-ms-win-crt-string-l1-1-0.dll => not found
        api-ms-win-crt-stdio-l1-1-0.dll => not found
        api-ms-win-crt-utility-l1-1-0.dll => not found
        api-ms-win-crt-convert-l1-1-0.dll => not found
        api-ms-win-crt-time-l1-1-0.dll => not found
        api-ms-win-crt-heap-l1-1-0.dll => not found
        api-ms-win-crt-environment-l1-1-0.dll => not found
        api-ms-win-crt-locale-l1-1-0.dll => not found
        api-ms-win-crt-math-l1-1-0.dll => not found
        api-ms-win-crt-filesystem-l1-1-0.dll => not found

gdal305.dll has all dll dependency.

IEUser@MSEDGEWIN10 MSYS /c/Program Files/GRASS GIS 8.3/extrabin
$ ldd gdal305.dll | grep "not found"

If I copy this gdal305.dll into C:\Program Files\GRASS GIS 8.3\lib\ dir with name gdal304.dll, Python ctypes load libgrass_vector.8.3.dll without error (error mentioned above wxdigit.py: Could not load grass_vector.8.3) and wxGUI is launched correctly.

@ninsbl
Copy link
Member

ninsbl commented Aug 4, 2022

Maybe OSGeo4W on the build server is not updated / cleaned?

Latest GDAL runtime in OSGeo4W is 305 (there is no 304)...

All thre version of GRASS GIS (7.8, 8.2, 8.3) in OSGeo4W start nicely...

And the CI builds work fine as well...

@tmszi
Copy link
Member

tmszi commented Aug 6, 2022

Maybe OSGeo4W on the build server is not updated / cleaned?

WinGRASS is compiled/builded on CVUT server, I can't check it because I don't have access to it. Could @neteler inform @landam about this issue and #2497, please?

And the CI builds work fine as well...

Maybe would be good, start transform compiling/building process of WinGRAS into GitHub CI, if it is technically possible.

@hellik
Copy link
Member

hellik commented Aug 6, 2022

Maybe would be good, start transform compiling/building process of WinGRAS into GitHub CI, if it is technically possible.

Yes, this should be a midterm Target.

@neteler
Copy link
Member

neteler commented Aug 8, 2022

Maybe would be good, start transform compiling/building process of WinGRAS into GitHub CI, if it is technically possible.

Perhaps related to PR #1212?

@tmszi
Copy link
Member

tmszi commented Apr 30, 2023

The error still persists:

wx.metadata addon comilation log (generated Sat, 29 Apr 2023 16:01:21) error:

Traceback (most recent call last):
  File "C:\Users\landamar\grass_packager\grass820\addons\wx.metadata\scripts\t.info.iso.py", line 39, in <module>
    import grass.temporal as tgis
  File "C:\msys64\usr\src\grass820\dist.x86_64-w64-mingw32\etc\python\grass\temporal\__init__.py", line 3, in <module>
    from .core import *
  File "C:\msys64\usr\src\grass820\dist.x86_64-w64-mingw32\etc\python\grass\temporal\core.py", line 36, in <module>
    from .c_libraries_interface import CLibrariesInterface
  File "C:\msys64\usr\src\grass820\dist.x86_64-w64-mingw32\etc\python\grass\temporal\c_libraries_interface.py", line 20, in <module>
    import grass.lib.raster as libraster
  File "C:\msys64\usr\src\grass820\dist.x86_64-w64-mingw32\etc\python\grass\lib\raster.py", line 30, in <module>
    _libs["grass_raster.8.2"] = load_library("grass_raster.8.2")
  File "C:\msys64\usr\src\grass820\dist.x86_64-w64-mingw32\etc\python\grass\lib\ctypes_loader.py", line 105, in __call__
    raise ImportError("Could not load %s." % libname)
ImportError: Could not load grass_raster.8.2.

@hellik
Copy link
Member

hellik commented Apr 30, 2023

IIRC, there was recently a GDAL update in OSGeo4W. Maybe the build environment is not updated yet.

@landam

@wenzeslaus
Copy link
Member

This seems like a couple different issues from different periods. Please, create a new issue to help clarify the current situation.

@wenzeslaus wenzeslaus closed this as not planned Won't fix, can't repro, duplicate, stale May 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working windows Microsoft Windows specific
Projects
None yet
Development

No branches or pull requests

6 participants