CGRU / cgru

CGRU - AFANASY
http://cgru.info/
GNU Lesser General Public License v3.0
278 stars 111 forks source link

win_build_msvc.cmd hangs #552

Closed Anti-Distinctlyminty closed 1 year ago

Anti-Distinctlyminty commented 2 years ago

Trying to build afanasy on Windows for the first time. I'm assuming that I need to have Microsoft build tools installed and then run afanasy/src/project.cmake/win_build_msvc.cmd? In any case the cmd file eventually calls /utilities/getrevision.cmd which never progresses past this line:https://github.com/CGRU/cgru/blob/540d5088cb7638d804383952b7f869bb9fbaa7a7/utilities/getrevision.cmd#L4

I then need to hit Ctrl-C a few times whereupon the message The process tried to write to a nonexistent pipe. appears.

I have tried running chcp 65001 to change the terminal encoding to UTF-8.

timurhai commented 2 years ago

Hi! Yes, on build it compiles in the current code revision. I build Afanasy on Windows periodically, it never hungs. But mey be there is some bug that can appear in some special environment case.

(just now i've tried to build again from master - everything is ok)

timurhai commented 2 years ago

As a temprorary solution, just to avoid this issue, you can set CGRU_REVISION to any string.

Anti-Distinctlyminty commented 2 years ago

Ok, I'm trying that. Currently trying to sort out the following Could not find a package configuration file provided by "Qt5Core"....

Is there a list of prerequisites somewhere that I missed?

timurhai commented 2 years ago

Latest cmake, python, qt5 - that is all, nothing special. And postgresql if you need afserver with statistics on windows.

Anti-Distinctlyminty commented 2 years ago

Ok, I managed to circumvent that issue. Now win_build_msvc.cmd seems to be running successfully, but I see no build products. My apologies as I'm not really familiar with cmake, but is it the case that all I need to do is run win_build_msvc.cmd? No loading any of the vcxproj files or anything?

I also noticed that the CMAKE_GENERATOR is set to "Visual Studio 16 2019", however the Qt installer only provides options for MSVC 2015 64-bit and MSVC 2019 64-bit. I don't know if this effects anything.

timurhai commented 2 years ago

Visual Studio 16 2019 - is a current version to compile the project, may be newer versions can, but not tested. Also Qt and Python should be compiles with the same (or compatible?) msvc versions. CMake just generates a Visual Studio project files afanasy.sln and otherts. Later afanasy.sln should be opened in Visual Studio and build.

Anti-Distinctlyminty commented 2 years ago

The Visual Studio project builds successfully, but the generated executables fail to run due to missing dll files as there is no cgru/dll folder.

I included the output from the win_build_msvc.cmd in case it is useful.

win_build_msvc.cmd output ``` project.cmake> .\win_build_msvc.cmd C:\Users\luke\Documents\cgru\afanasy\src\project.cmake>rem @echo off C:\Users\luke\Documents\cgru\afanasy\src\project.cmake>set CMAKE_GENERATOR=Visual Studio 16 2019 C:\Users\luke\Documents\cgru\afanasy\src\project.cmake>pushd ..\..\.. C:\Users\luke\Documents\cgru>call setup.cmd CGRU_VERSION 3.3.0 Adding "C:\Qt\5.15.2\msvc2019_64\bin" to PATH The system cannot find the file specified. -- Selecting Windows SDK version 10.0.22000.0 to target Windows 10.0.19043. -- The C compiler identification is MSVC 19.29.30147.0 -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe - skipped -- Detecting C compile features -- Detecting C compile features - done -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- Found PythonLibs: C:/Program Files/Python39/libs/python39.lib (found version "3.9.13") -- Found PostgreSQL: C:/Program Files/PostgreSQL/14/lib/libpq.lib (found version "14.5") PostgreSQL found. Building with SQL. Using std::regex ECMAScript regular expressions (Perl-like). -- Qt version 5.15.2 -- Configuring done -- Generating done -- Build files have been written to: C:/Users/luke/Documents/cgru/afanasy/src/project.cmake -- Selecting Windows SDK version 10.0.22000.0 to target Windows 10.0.19043. PostgreSQL found. Building with SQL. Using std::regex ECMAScript regular expressions (Perl-like). -- Qt version 5.15.2 -- Configuring done -- Generating done -- Build files have been written to: C:/Users/luke/Documents/cgru/afanasy/src/project.cmake Press any key to continue . . . ```
timurhai commented 2 years ago

Qt and Python dlls needed, also they can need other dlls too.

You can get all needed dlls from the latest CGRU windows release. If you used some updated libraries, replace that dlls with new.

Anti-Distinctlyminty commented 2 years ago

I completely started over, compiled with MSVC 2019, copied the dll folder (after checking that the DLLs were the same as the ones found in C:\Qt\5.15.2\msvc2019_64 and my Python 3.9.13 installations). Calling _afserver.cmd, 50.afstarter.cmd and 99.render.cmd all appear to work. But 10.afwatch.cmd still fails with the error

This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.`

The dll/plugins/platform/qwindows.dll is definitely present

timurhai commented 2 years ago

It supposeed that you run Keeper first. Keeper is a python + pyside small tray menu to run CGRU tools. OnwWindows it perfoms this on start: https://github.com/CGRU/cgru/blob/master/utilities/keeper/keeper.py#L13

Anti-Distinctlyminty commented 2 years ago

That did it! Thank you @timurhai. All now appears to be working :)

Anti-Distinctlyminty commented 1 year ago

Ok, I'm re-opening this as it is still causing problems and I've managed to track down the cause.

If I make a fresh clone of the repo. and run win_build_msvc.cmd located in afanasy\src\project.cmake\. This will call setup.cmd in the root, which adds %CGRU_LOCATION%\bin to path, and I believe this is the cause of the hang, because in here there is a bash script named python. So later in win_build_msvc.cmd, whencall getrevision.cmd %folder%` is called, this line:

For /F "Tokens=*" %%I in ('python getrevision.py %folder%') Do Set CGRU_REVISION=%%I

Is trying to invoke a bash script, as by that point %CGRU_LOCATION%\bin will take precedence over previous values in %PATH%. E.g. If I open a fresh cmd prompt and do the following

CD C:\Users\luke\AppData\Local\Temp\cgru
CALL setup.cmd
WHERE python
C:\Users\luke\AppData\Local\Temp\cgru\bin\python
C:\Users\luke\AppData\Local\Temp\cgru\bin\python.cmd
C:\Program Files\Python39\python.exe

The first reported python file is the bash script, so any invoking of python after calling setup.cmd will hang.

timurhai commented 1 year ago

Hi! I see, there can be some mess with python command.But I have not faced it.I copy some Python installations into the cgru/python folder.This makes cgru and cmake use Python that is in the cgru/python folder.Later I create an CGRU Windows release archives with that Python and CGRU works on the machines w/o any Python installation.setuppython.cmd setup.cmd calls any setup*.cmd files in the CGRU root folder:https://github.com/CGRU/cgru/blob/master/setup.cmd#L28

And it calls setup_python.cmd: https://github.com/CGRU/cgru/blob/master/setup_python.cmd

So I have:

C:\Users\timurhai>cd /cgru

C:\cgru>call setup.cmd
CGRU_VERSION 3.3.1
"Using CGRU Python: C:\cgru\python"

C:\cgru>where python
C:\cgru\python\python.exe
C:\cgru\bin\python
C:\cgru\bin\python.cmd
C:\Python396\python.exe
C:\Users\timurhai\AppData\Local\Microsoft\WindowsApps\python.exe

C:\cgru>python
Python 3.9.6 (tags/v3.9.6:db3ff76, Jun 28 2021, 15:26:21) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys; print(sys.prefix)
C:\cgru\python
Anti-Distinctlyminty commented 1 year ago

Indeed, copying python to the cgru root folder does indeed solve this problem. Thank you again @timurhai