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]: errors while trying to generate MinGW makefile with CMake on windows #31

Open
1 of 3 tasks
Blargian opened this issue Dec 18, 2022 · 5 comments
Open
1 of 3 tasks
Labels
bug Something isn't working needs triage This issue needs a manteiner revision

Comments

@Blargian
Copy link
Contributor

Blargian commented Dec 18, 2022

Describe you problem:

Windows users may need to use MinGW with CMake to compile the program. When generating a makefile for the sorting-visualizer using mingw32-make the following errors are thrown:

\sorting-visualizer\src\SortController.cpp: In member function 'void SortController::_startSort(int)':
\sorting-visualizer\src\SortController.cpp:144:71: error: no matching function for call to 'std::thread::thread(void (SortController::*)(), SortController*)'
  144 |         _animThread = std::thread(&SortController::checkSortAnim, this);
      |                                                                       ^
In file included from C:/mingw64/lib/gcc/x86_64-w64-mingw32/12.2.0/include/c++/thread:43,
                 from \sorting-visualizer\src\SortController.h:10,
                 from \sorting-visualizer\src\SortController.cpp:1:
C:/mingw64/lib/gcc/x86_64-w64-mingw32/12.2.0/include/c++/bits/std_thread.h:156:5: note: candidate: 'std::thread::thread(std::thread&&)'
  156 |     thread(thread&& __t) noexcept
      |     ^~~~~~
C:/mingw64/lib/gcc/x86_64-w64-mingw32/12.2.0/include/c++/bits/std_thread.h:156:5: note:   candidate expects 1 argument, 2 provided
C:/mingw64/lib/gcc/x86_64-w64-mingw32/12.2.0/include/c++/bits/std_thread.h:120:5: note: candidate: 'std::thread::thread()'
  120 |     thread() noexcept = default;
      |     ^~~~~~
C:/mingw64/lib/gcc/x86_64-w64-mingw32/12.2.0/include/c++/bits/std_thread.h:120:5: note:   candidate expects 0 arguments, 2 provided
\sorting-visualizer\src\SortController.cpp: In member function 'void SortController::startSort(int)':
\sorting-visualizer\src\SortController.cpp:165:81: error: no matching function for call to 'std::thread::thread(void (SortController::*)(int), SortController*, int&)'
  165 |         _sortingThread = std::thread(&SortController::_startSort, this, sortType);
      |                                                                                 ^
C:/mingw64/lib/gcc/x86_64-w64-mingw32/12.2.0/include/c++/bits/std_thread.h:156:5: note: candidate: 'std::thread::thread(std::thread&&)'
  156 |     thread(thread&& __t) noexcept
      |     ^~~~~~
C:/mingw64/lib/gcc/x86_64-w64-mingw32/12.2.0/include/c++/bits/std_thread.h:156:5: note:   candidate expects 1 argument, 3 provided
C:/mingw64/lib/gcc/x86_64-w64-mingw32/12.2.0/include/c++/bits/std_thread.h:120:5: note: candidate: 'std::thread::thread()'
  120 |     thread() noexcept = default;
      |     ^~~~~~
C:/mingw64/lib/gcc/x86_64-w64-mingw32/12.2.0/include/c++/bits/std_thread.h:120:5: note:   candidate expects 0 arguments, 3 provided
mingw32-make[2]: *** [CMakeFiles\sorting-visualizer.dir\build.make:121: CMakeFiles/sorting-visualizer.dir/src/SortController.cpp.obj] Error 1
mingw32-make[1]: *** [CMakeFiles\Makefile2:82: CMakeFiles/sorting-visualizer.dir/all] Error 2
mingw32-make: *** [Makefile:90: all] Error 2

Steps to reproduce (optional):

  • clone the directory on windows using git clone https://github.com/alesbe/sorting-visualizer && cd sorting-visualizer
  • install CMake version 3.25.1
  • navigate to the root directory of the above cloned repository on local machine
  • Set up gcc and g++ compilers using (installation path may vary):

CMake -DCMAKE_C_COMPILER="C:/mingw64/bin/gcc.exe"
CMake DCMAKE_CXX_COMPILER="C:/mingw64/bin/g++.exe"

  • run CMake -G "MinGW Makefiles"
  • Build files get written to /sorting-visualizer
  • run mingw32-make
  • errors above occur at this point

Additional info (optional):

Running Windows 11
gcc.exe (x86_64-win32-sjlj-rev0, Built by MinGW-W64 project) 12.2.0
g++.exe (x86_64-win32-sjlj-rev0, Built by MinGW-W64 project) 12.2.0

OS

  • : Windows
  • : Mac OS
  • : Linux
@Blargian Blargian added bug Something isn't working needs triage This issue needs a manteiner revision labels Dec 18, 2022
@Blargian
Copy link
Contributor Author

@alesbe i'm fairly new to development in C++ so quite possible I'm just making some newbie mistake somewhere. Thought it might be good to create this issue anyway for any other users who may run into issues trying to get sorting-visualizer to work on windows. I'll keep looking into it.

@alesbe
Copy link
Owner

alesbe commented Dec 18, 2022

Thanks for reporting the bug!

When I was developing this, I was using Linux with CMake, I've never used CMake in Windows so I don't know what is causing the error...

Anyways, I'll look into it right now. There should be an easier way to compile the project in Windows, like the install.sh for Linux.

Here is a guide from SFML to compile it using CMake. I will try to fix it and after that, I will make an installation script for Windows. I'll keep you updated!

@Blargian
Copy link
Contributor Author

Blargian commented Dec 19, 2022

Thanks for the link. I tried this morning following along with the tutorial. Was able to generate the makefile successfully but get the same errors when trying to build - it gets 66% of the way through. I suspect that maybe it has to do with mingw not having a version of GCC which supports threading or the c++11 standard by default.

I will try use a C++11 compiler for windows like MinGW-Builds rather than MinGW and see if that helps.

@Blargian
Copy link
Contributor Author

@alesbe I was able to get it working on windows so I think this reported bug isn't actually a bug, just a configuration issue on my side. Once I installed MinGW-Builds and used their included version of g++ compiler rather than the one included with MinGW I was able to build without errors.

@alesbe
Copy link
Owner

alesbe commented Dec 22, 2022

That's so interesting! Thanks for your interest :)

I still can't compile the project on windows. Did you installed MinGW-Builds from here?

Also, a new algorithm was added to the project, you might want to pull the changes before implementing anything! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs triage This issue needs a manteiner revision
Projects
None yet
Development

No branches or pull requests

2 participants