0

I'm trying to setup SDL graphics for my project, and I tried to run it after I was almost complete, but then I got this error:

g++     -o dist/Debug/Cygwin-Windows/project_2_snake build/Debug/Cygwin-Windows/main.o -L../../../../../../../../../SDL2/lib -lmingw32 -lsdl2main -lsdl2
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: cannot find -lmingw32

collect2: error: ld returned 1 exit status
make[2]: *** [nbproject/Makefile-Debug.mk:63: dist/Debug/Cygwin-Windows/project_2_snake.exe] Error 1 

Can anyone could help me with this?

Additional information windows 10 i think Cygwin c++ compiler

Coolkid
  • 11
  • 2
  • Possible duplicate of [Compiling with SDL and g++ cannot find -lSDLmain etc](https://stackoverflow.com/questions/11380254/) – Remy Lebeau Nov 29 '21 at 21:23
  • I recommend a building tool like CMake, all that diffrent compiler stuff is a mess, also i don't rely much on windows ports of GNU, i use msvc instead – Rafaelplayerxd YT Nov 29 '21 at 21:24
  • Are you sure you want to be using Cygwin *and* MinGW? I barely touch Windows, but when I did, the decision was mostly either-or. (Cygwin does have some support for mixing them, but I'm not sure what exactly the use-case is). Also, check your $PATH and make sure you aren't mixing installs. – o11c Nov 29 '21 at 21:28
  • Particularly, the decision tree looked like: 1. do I need a full POSIX-like environment? If so, use cygwin. Otherwise 2a. do I need a sane compiler? If so, use mingw (probably mingw64, actually - even for 32-bit). 2b do I need to interact with non-free C++ software that was compiled with MSVC? If so, you have to use MSVC. Notably, my experience is from before WSL was a thing, and Clang-for-Windows was more hypothetical than useful. – o11c Nov 29 '21 at 21:32
  • I would love to use this mingw thing everyone is talking about but i dont know how – Coolkid Nov 29 '21 at 21:33
  • @RemyLebeau he did have the same problem but he solved it in a weird way because when i tried to do it the same way it didnt work – Coolkid Nov 29 '21 at 21:38
  • @o11c how do i check if im mixing installs? – Coolkid Nov 29 '21 at 21:39
  • 1
    `-L../../../../../../../../../SDL2/lib`... mmm. – Mike Vine Nov 29 '21 at 21:39
  • @Coolkid I'm pretty sure the main way to use mingw-w64 on Windows is by using https://www.msys2.org/ ... to check for a mixed environment, check the value of the `PATH` environment variable: `echo $PATH` in a Unix-like shell (separated by colons), or `echo %PATH%` on the Windows command prompt (separated by semicolons), and see if the directories look like they came from multiple sources - particularly, if there are multiple versions of compiler-related tools. Do you remember what website(s) you downloaded things from in the first place? Your browser downloads history may be useful. – o11c Nov 29 '21 at 21:52
  • @o11c wait are you saying that I shouldn't try to use both Cygwin and MinGW if so then what should I use to download SDL graphics because I went to this site and saw these links http://libsdl.org/download-2.0.php – Coolkid Nov 29 '21 at 22:07
  • @o11c once i download the msys2.org thing where would i run it? – Coolkid Nov 29 '21 at 22:23
  • @Coolkid generally you don't want/need to download things from random sites. Instead, install them using your package manager (for msys2, that seems to be `pacman`, as in Arch Linux) when possible, and build them from source otherwise. The only reason to link to a preexisting binary is if that library is closed source, or if its build system is extremely arcane or slow. – o11c Nov 29 '21 at 22:56
  • @o11c that's good advice and all but my teacher told me to download this program although he didn't show us how – Coolkid Nov 29 '21 at 23:26

1 Answers1

0

Your linker does not know where to find the library you are referencing.

You will have to tell it where to find it. The easiest solution would likely be to add the libs directories of the libraries you are referencing to your linker's search directories.

Karlo
  • 11
  • 3
  • so your saying add the lib file into the additional directories of linker? or the libraries part of linker? @Karlo – Coolkid Nov 29 '21 at 21:35
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Nov 29 '21 at 21:36