Bug 364820 - No Link to libstdc++ on MSYS on Windows (And Linking Issues)
Summary: No Link to libstdc++ on MSYS on Windows (And Linking Issues)
Status: RESOLVED WORKSFORME
Alias: None
Product: extra-cmake-modules
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: 5.23.0
Platform: Other Microsoft Windows
: NOR normal
Target Milestone: ---
Assignee: Alex Merry
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-06-27 15:57 UTC by ahuszagh
Modified: 2022-11-23 05:16 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description ahuszagh 2016-06-27 15:57:50 UTC
Environment:

MSYS2, a Unix-like subsystem for Windows using a .dll rather than .so to allow the creation of binaries for deployment.

Packages installed:
    pacman -Sy cmake
    pacman -Sy mingw-w64-x86_64-qt5-static

Build Issues:
After installing cmake-extra-modules, which occurs without issues, I then issued the following command, which completes successfully:

```
cmake .. \
      -DCMAKE_BUILD_TYPE=debug \
      -DCMAKE_INSTALL_PREFIX=/mingw64
```

Then, I issued:

```make VERBOSE=1```

This raises a large number of errors stating:
    undefined reference to `operator new`

This would demonstrate that libstdc++ is not in the linking path for the build command. I tried editing the CMakeLists.txt with the following:

if (MSYS)
    set(cmake_cxx_flags, "${cmake_cxx_flags} -lstdc++")
endif()

Although this does add libstdc++ to the linking path, it does not solve the issue, since -lstdc++ is not added to the end of the linking path. Manually running all the failed Makefile commands, with "-lstdc++" appended to the end allows KArchive to compile fine.

Other Issue:
After installing, I have to issue "ln -s /path/to/libKF5Archive.so /path/to/libKF5Archive.dll", since KArchive also incorrectly assumes I am using a Unix build system. Although the library is in fact a DLL, I cannot delete either the .so or the .dll (if I use a redundant copy) without having linking issues.

Reproducible: Always

Steps to Reproduce:
1. Install MSYS2
2. Install cmake and Qt5 from pacman via `pacman -Sy cmake mingw-w64-x86_64-qt5-static`
3. Install cmake-extra-modules
4. Clone karchive, cmake and build

Actual Results:  
Produces a long ttraceback stating:

undefined reference to `operator new`

Expected Results:  
Expected it to compile without issue. The software should link to libstdc++.
Comment 1 Justin Zobel 2022-10-22 00:00:17 UTC
Thank you for reporting this bug in KDE software. As it has been a while since this issue was reported, can we please ask you to see if you can reproduce the issue with a recent software version?

If you can reproduce the issue, please change the status to "CONFIRMED" when replying. Thank you!
Comment 2 ahuszagh 2022-10-24 15:17:21 UTC
I'm unable to build this currently due to a seeming issue with finding MPR, which seems to be related to attempting to use static Qt5:
https://bugreports.qt.io/browse/QTBUG-38913?focusedCommentId=269437&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel

Just below to describe what I'm using.

```bash
# first synchronize the database
pacman -Syu
# then install the necessary development packages
pacman -Sy cmake  mingw-w64-x86_64-gcc mingw-w64-x86_64-qt5-static base-devel  mingw-w64-x86_64-python-sphinx
# then clone, make our build directory, etc.
git clone https://github.com/KDE/extra-cmake-modules
cd extra-cmake-modules
mkdir build && cd build
cmake .. \
      -DCMAKE_BUILD_TYPE=debug \
      -DCMAKE_INSTALL_PREFIX=/mingw64
```

I'll see if I can a working example using shared Qt5.
Comment 3 Bug Janitor Service 2022-11-08 05:10:17 UTC
Dear Bug Submitter,

This bug has been in NEEDSINFO status with no change for at least
15 days. Please provide the requested information as soon as
possible and set the bug status as REPORTED. Due to regular bug
tracker maintenance, if the bug is still in NEEDSINFO status with
no change in 30 days the bug will be closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

If you have already provided the requested information, please
mark the bug as REPORTED so that the KDE team knows that the bug is
ready to be confirmed.

Thank you for helping us make KDE software even better for everyone!
Comment 4 Bug Janitor Service 2022-11-23 05:16:42 UTC
This bug has been in NEEDSINFO status with no change for at least
30 days. The bug is now closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

Thank you for helping us make KDE software even better for everyone!