GAMS-dev / gdx

Official low-level API to access GAMS Data eXchange (GDX) files with bindings to various programming languages
https://gams-dev.github.io/gdx/
Other
8 stars 0 forks source link

Error when building in WSL Ubuntu #2

Closed areleu closed 2 months ago

areleu commented 3 months ago

When building in a WSL Ubuntu instance. I pretty much built it using the commands in the CI. I get the following error:

/home/arel_eu/Work/repositories/gdx/src/rtl/stdthread.cpp:122:28: error: no matching function for call to ‘rtl::stdthread::TStdThread::~TStdThread()’
  122 |       std::thread::~thread();
      |                            ^
In file included from /home/arel_eu/Work/repositories/gdx/src/rtl/stdthread.h:45,
                 from /home/arel_eu/Work/repositories/gdx/src/rtl/stdthread.cpp:26:
/usr/include/c++/9/thread:136:5: note: candidate: ‘std::thread::~thread()’
  136 |     ~thread()
      |     ^

Full log: build_log.txt

So the thread destructor is not being found properly. I solved it by changing https://github.com/GAMS-dev/gdx/blob/31677d69e8db3501a9088fbebe51e818fa320f02/src/rtl/stdthread.cpp#L121

to std::terminate();

But I feel it is not the proper way to fix this, could it be that something is missing in the CMake configuration for Linux?

System info:

NAME="Ubuntu"
VERSION="20.04.6 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.6 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal
0x17 commented 3 months ago

Thanks for reporting @areleu! Much appreciated.

While the file in question is built as part of the CMake project, it is not actively used by the GDX library (at the moment). So the quick fix / workaround you did, should not have any adverse effects on the functionality of the resulting GDX library that you build.

I will look into reproducing and fixing the issue with the std::thread having a required parameter for the destructor. Additionally I will check if there is a way that I can adapt the CMakeLists.txt to only build the subset of modules that is actually used by the GDX library itself by default.

0x17 commented 3 months ago

I could reproduce the problem by using GCC 9. I fixed it with commit https://github.com/GAMS-dev/gdx/commit/0e66e1ca2d60fcc03156fc8b7022095e0a20d822 in develop. The fix will be included in the next GDX release (which is triggered by the next merge of develop into main). There isn't a fixed date for this but it shouldn't be more than a couple of weeks usually.

0x17 commented 2 months ago

I will look into reproducing and fixing the issue with the std::thread having a required parameter for the destructor. Additionally I will check if there is a way that I can adapt the CMakeLists.txt to only build the subset of modules that is actually used by the GDX library itself by default.

With the most recent commits in branch develop, it is now possibly to only build the library (without unit tests and examples). This speeds up the process and would've prevented the issue from this thread (which is also fixed itself).

The commands are as follows:

git clone https://github.com/GAMS-dev/gdx.git
cd gdx
git clone https://github.com/madler/zlib zlib
cmake -DNO_TESTS=ON -DNO_EXAMPLES=ON .
cmake --build .

Hence I am closing this issue now.