installation on windows MSYS2 MinGW 64bit

Discuss issues related to installing or building
giuliohome
Posts: 8
Joined: Mon Jan 17 2022 9:05 am

installation on windows MSYS2 MinGW 64bit

Post by giuliohome »

Hi all and thank you for your work.

I've installed CopperSpice on Fedora 34 using copperspice-1.7.2-fedora33-x64.tar.bz2 and tried the examples from your journal and all is fine.

I wanted to try CopperSpice also on Windows with MSYS MinGW.

Notice that I have easily installed Qt 4 there via pacman and it's ok. But when I looked at the binary here I was a bit confused.

Should I download the binary for arch or the setup MSVC?

First I tried cloning the source, but my machine was too slow and after a couple of hours of ninja I decided to interrupt it, sorry.

So I went back to binary and tried the MSVC release and the setup was apparently ok. But when I try an example, ninja shows strange errors about compiler settings not recognized... I wonder whether it is an installation issue and just in case any suggestions from you?

Code: Select all

[1/3] Building CXX object CMakeFiles/example_4.dir/main.cpp.obj
FAILED: CMakeFiles/example_4.dir/main.cpp.obj 
C:\msys64\mingw64\bin\c++.exe  -IC:/copperspice/example04/build -IC:/copperspice/example04 -isystem C:/copperspice/include -isystem C:/copperspice/include/QtCore -isystem C:/copperspice/include/QtGui -O3 -DNDEBUG /bigobj /DNOMINMAX -std=gnu++17 -MD -MT CMakeFiles/example_4.dir/main.cpp.obj -MF CMakeFiles\example_4.dir\main.cpp.obj.d -o CMakeFiles/example_4.dir/main.cpp.obj -c C:/copperspice/example04/main.cpp
c++.exe: error: /bigobj: No such file or directory
c++.exe: error: /DNOMINMAX: No such file or directory
ninja: build stopped: subcommand failed.
giuliohome
Posts: 8
Joined: Mon Jan 17 2022 9:05 am

Re: installation on windows MSYS2 MinGW 64bit

Post by giuliohome »

Now magically a new setup shows up: setup-CopperSpice-1.7.2-x64.exe without MSVC

It solved the above installation problem and now I have a build done! But my problems are not finished.
The deploy folder is missing the mingw dll, ok I have a script to put them there.
But now I still have a runtime crash!

Code: Select all

---------------------------
example_4.exe - Impossibile trovare punto di ingresso
---------------------------
Impossibile trovare il punto di ingresso __cxa_thread_atexit della procedura nella libreria di collegamento dinamico libstdc++-6.dll. 

It seems a complicated conflict... What am I supposed to do?
Last edited by giuliohome on Mon Jan 17 2022 11:17 am, edited 1 time in total.
barbara
Posts: 458
Joined: Sat Apr 04 2015 2:32 am
Contact:

Re: installation on windows MSYS2 MinGW 64bit

Post by barbara »

Thank you so much for your questions.
Should I download the binary for arch or the setup MSVC?
There is a table below the list of CopperSpice binary files which shows the details for each version.

1) Arch is a version of Linux so it will not work on Windows.

2) We have two different binaries for Windows. One is for MSVC and the other uses MinGW.
...tried the MSVC release... ninja shows strange errors about compiler settings not recognized... I wonder whether it is an installation issue and just in case any suggestions from you?
3) It sounds like you are using the MSVC binary for CopperSpice with MinGW to build the example.

If you are going to use MinGW then you need to use our setup-CopperSpice-1.7.2-x64.exe binary file.

If you want to use our MSVC binaries then you need to compile the Example with MSVC. Refer to:
https://www.copperspice.com/docs/cs_overview/sample-ks-msvc.html

Barbara
barbara
Posts: 458
Joined: Sat Apr 04 2015 2:32 am
Contact:

Re: installation on windows MSYS2 MinGW 64bit

Post by barbara »

But my problems are not finished. The deploy folder is missing the mingw dll, ok I have a script to put them there.
But now I still have a runtime crash!
There is a CMake find_library() that should automatically copy the MinGW dll files. The location of these files are found based on your PATH. Do you have /c/MinGW/bin in your path?

Please let us know what version of CMake you have installed.

We translated the error message and it seems like you copied a 32-bit version of the DLL. Make sure you are using the DLL from MinGW/bin and not from MSys.

Please let us know any other questions as you go along.

Barbara
giuliohome
Posts: 8
Joined: Mon Jan 17 2022 9:05 am

Re: installation on windows MSYS2 MinGW 64bit

Post by giuliohome »

Hi Barbara, thank you very much for your reply and for your help!
Very appreciated!

You asked the version of cmake I installed. If I open a MinGW terminal and I type the following, I see

Code: Select all

$ cmake --version
cmake version 3.21.3

CMake suite maintained and supported by Kitware (kitware.com/cmake).

Also if I write

Code: Select all

pacman -Ss cmake
among the output there are the following lines

Code: Select all

mingw64/mingw-w64-x86_64-cmake 3.21.3-1 [installed]
    A cross-platform open-source make system (mingw-w64)
When I tried Qt and I wanted to port a deploy to another machine (aside from specific Qt files) I prepared a script for MinGW dll.
It is on my github: https://github.com/giuliohome/qt-table-view/blob/main/qtdeploy/deploy02mingw.sh
I re-used it for CopperSpice and I only changed FirstApp with example_4 as below:

Code: Select all

#!/bin/bash

ldd example_4.exe | grep mingw | while read -r line ; do
    IN=$line
    arrIN=(${IN// => / })
    depLIB=${arrIN[1]}
    echo $depLIB
    cp $depLIB . 
    # mingw dependency dll copied
done
I understand that you explained CMake find_library() should do that without my script: I will study CMake, at the moment I'm ignorant about it but I guess CopperSpice is an opportunity for me to learn new, modern, important things.

Regarding the possibility that I copied the 32-bit version of the DLL (so of the libstdc++-6.dll ), aside that I didn't do it manually but via the above said script, I can check the dll architecture with the command below from MinGW terminal

Code: Select all

$ objdump -f deploy/libstdc++-6.dll

deploy/libstdc++-6.dll:     formato del file pei-x86-64
architettura: i386:x86-64, flag 0x00000133:
HAS_RELOC, EXEC_P, HAS_SYMS, HAS_LOCALS, D_PAGED
indirizzo di partenza 0x00000003be961350
I can double check it with sysinternals from a cmd:

Code: Select all

sigcheck.exe "libstdc++-6.dll"

Sigcheck v2.82 - File version and signature viewer
Copyright (C) 2004-2021 Mark Russinovich
Sysinternals - www.sysinternals.com

libstdc++-6.dll:
        Verified:       Unsigned
        Link date:      01:00 01/01/1970
        Publisher:      n/a
        Company:        n/a
        Description:    n/a
        Product:        n/a
        Prod version:   n/a
        File version:   n/a
        MachineType:    64-bit
Let me know what else can I do.
Thank you very much again

Giulio
giuliohome
Posts: 8
Joined: Mon Jan 17 2022 9:05 am

Re: installation on windows MSYS2 MinGW 64bit

Post by giuliohome »

FYI

after unzipping the example_04

this is config output

Code: Select all

$ ./do-config.sh
-- The C compiler identification is GNU 10.3.0
-- The CXX compiler identification is GNU 10.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/msys64/mingw64/bin/cc.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:/msys64/mingw64/bin/c++.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: C:/copperspice/example_04/build
build output below

Code: Select all

$ ./do-build.sh
[1/3] Building CXX object CMakeFiles/example_4.dir/main.cpp.obj
[2/3] Linking CXX executable bin\example_4.exe
[2/3] Install the project...
-- Install configuration: "Release"
-- Installing: C:/copperspice/example_04/deploy/./example_4.exe
-- Installing: C:/copperspice/example_04/deploy/./libCsCore1.7.dll
-- Installing: C:/copperspice/example_04/deploy/./libCsGui1.7.dll
-- Installing: C:/copperspice/example_04/deploy/./platforms/CsGuiWin1.7.dll
and inspection of produced exe

Code: Select all

$ ldd deploy/example_4.exe
        ntdll.dll => /c/Windows/SYSTEM32/ntdll.dll (0x76e20000)
        kernel32.dll => /c/Windows/system32/kernel32.dll (0x76d00000)
        KERNELBASE.dll => /c/Windows/system32/KERNELBASE.dll (0x7fefcec0000)
        libCsCore1.7.dll => /c/copperspice/example_04/deploy/libCsCore1.7.dll (0x64580000)
        ADVAPI32.dll => /c/Windows/system32/ADVAPI32.dll (0x7fefd670000)
        msvcrt.dll => /c/Windows/system32/msvcrt.dll (0x7fefebd0000)
        sechost.dll => /c/Windows/SYSTEM32/sechost.dll (0x7fefd880000)
        RPCRT4.dll => /c/Windows/system32/RPCRT4.dll (0x7fefeaa0000)
        libgcc_s_seh-1.dll => /mingw64/bin/libgcc_s_seh-1.dll (0x7fefaa30000)
        libwinpthread-1.dll => /mingw64/bin/libwinpthread-1.dll (0x7fefaa10000)
        ole32.dll => /c/Windows/system32/ole32.dll (0x7fefecd0000)
        GDI32.dll => /c/Windows/system32/GDI32.dll (0x7fefea30000)
        USER32.dll => /c/Windows/system32/USER32.dll (0x76c00000)
        LPK.dll => /c/Windows/system32/LPK.dll (0x7fefd1e0000)
        USP10.dll => /c/Windows/system32/USP10.dll (0x7fefd300000)
        WS2_32.dll => /c/Windows/system32/WS2_32.dll (0x7fefec70000)
        NSI.dll => /c/Windows/system32/NSI.dll (0x7fefecc0000)
        libstdc++-6.dll => /mingw64/bin/libstdc++-6.dll (0x7fed1ea0000)
giuliohome
Posts: 8
Joined: Mon Jan 17 2022 9:05 am

Re: installation on windows MSYS2 MinGW 64bit

Post by giuliohome »

I've also tried switching from GNU to Clang

Code: Select all

$ export CXX=/mingw64/bin/clang++
$ export CC=/mingw64/bin/clang
and so

Code: Select all

$ ./do-config.sh
-- The C compiler identification is Clang 12.0.1
-- The CXX compiler identification is Clang 12.0.1
but the issue remains

Code: Select all

the procedure entry point __cxa_thread_atexit could not be located in the dynamic link library libstdc++-6.dll
or using gdb in mingw

Code: Select all

During startup program exited with code 0xc0000139.
BTW the dll is the same that is working fine in Qt deploy, so I'd say it is the way it is actually called from some C++ code in CopperSpice MinGW implementation maybe... ?
giuliohome
Posts: 8
Joined: Mon Jan 17 2022 9:05 am

Re: installation on windows MSYS2 MinGW 64bit

Post by giuliohome »

After hours and hours of trials and errors

I downloaded your old binary for mingw and pointed cmake to the old GNU 7.3.0

And it works without errors!!!

Is CopperSpice supposed to be for modern C++ and crossplatform? Have you tested it with a recent version of the compiler on mingw?
giuliohome
Posts: 8
Joined: Mon Jan 17 2022 9:05 am

Re: installation on windows MSYS2 MinGW 64bit

Post by giuliohome »

It's not a matter of the gnu compiler, it's just only the libstdc++-6.dll version.
The one in /mingw64/bin is not the one that copperspice wants. I don't need to replace the whole mingw64 with an old version (that's too much and not reasonable) but only that single file (which is much more acceptable).

Why don't you include it in the binary setup for windows mingw then ? You should ship that file so that cmake finds it from cs setup, what do you think?

The problem is that your InstallMinGW.cmake finds libstdc++-6 from mingw but that lib does not work: see for example https://github.com/msys2/MINGW-packages/issues/4782 or test the current status (maybe qt did a similar thing https://stackoverflow.com/questions/47890575/why-does-qts-version-of-libstdc-6-dll-work-but-not-mingw).

Here is my quick and dirty fix of do-build.sh

Code: Select all

#!bash
cd build

ninja install 

cd ../deploy
cp $CopperSpice_DIR/libstdc++-6.dll .
cp ../deploy02mingw.sh .
./deploy02mingw.sh
./example_4
where $CopperSpice_DIR/libstdc++-6.dll is coming from your https://download.copperspice.com/toolchain/mingw/ and x86_64-7.3.0-release-posix-seh-rt_v5-rev0.7z but it is only one file!
barbara
Posts: 458
Joined: Sat Apr 04 2015 2:32 am
Contact:

Re: installation on windows MSYS2 MinGW 64bit

Post by barbara »

We run our CI on multiple platforms and test CopperSpice on these compilers.
  • gcc 7.3 to gcc 11
  • clang 7 to clang 11
  • Multiple versions of MSVC
On Windows MinGW we test on CI for the lowest supported compiler to ensure we are compatible with C++. To answer your question we also test internally using a version of MinGW 9.2 and MinGW 10.3. The dll files are different for every deployment. Sadly, some users can not update as often as others so we need to be flexible. The prebuilt binary files we supply were built with the exact versions listed in our documentation. Due to compiler ABI issues any C++ libraries you use and your application must agree.

So if you want to use MinGW 11 with MSys2, you can! However you will need to build CopperSpice from source. Since there are so many versions and vendors of MinGW it would not be practical for us to pre-build CopperSpice with maybe ten different versions of MinGW.


(2) In the "CMakeLists.txt" for these examples there is a call to "InstallMinGW.cmake". This is a function in our exported CMake configuration. This function instructs CMake to copy the MinGW dll files. This works perfectly for CMake 3.20 or less. We were informed that CMake made a breaking change to how files use the environment path, so sometimes it can not find things. Someone is looking into a resolution and will correct this.


(3) Just to reiterate, we use MSys and not MSys2. This is why your MinGW dll files are not working, the MSys2 dll files are not compatible with the binary release of CopperSpice you are using. For clarity, w recently set up an area on our download page for MinGW and MSys so all the files are located in one place.

https://download.copperspice.com/toolchain/mingw/

Thanks for all your testing, you are indeed helping us to make CopperSpice better.

Barbara
Post Reply