Closed Mario0051 closed 5 years ago
This looks like a linking problem. Can you tell me what version of SDL you have installed?
I also use mingw32-make on my Windows system, so this should work if configured properly.
I am using SDL 2.0.8.
Okay. That version should work.
Can you tell me where you have the library files installed for SDL2 on the machine?
Also, can you add the following code to the end of CMakeLists.txt
(after the line with add_dependencies(smbc codegen)
) at the root of the repo and re-run cmake? This should print out the variables that cmake finds, and help us figure out where it thinks the SDL libraries are located on your system. Ideally the value SDL2_LIBRARY
or SDL2_LIBRARIES
should be defined.
function(echo_all_cmake_variable_values)
message(STATUS “”)
get_cmake_property(vs VARIABLES)
foreach(v ${vs})
message(STATUS “${v}=’${${v}}'”)
endforeach(v)
message(STATUS “”)
endfunction()
echo_all_cmake_variable_values()
Please let me know what the output of cmake is after you add this code to CMakeLists.txt
. Hopefully this will help us figure out what is going on 😄
SDL2_LIBRARY is defined as: "C:\Users\*****\Downloads\SDL2-2.0.8\lib\x64"
On my system I see SDL2_LIBRARY
is equal to mingw32C:/TDM-GCC-64/lib/libSDL2main.aC:/TDM-GCC-64/lib/libSDL2.dll.a
. So I think in your case it needs to point to the correct library files (.lib
or .a
) and not just the directory (x64
). Something with the SDL2 detection logic must not be working properly. I have had issues with this before 😞
What library files are installed in the x64
directory? I think if you are compiling with mingw you will likely need the GNU style libraries (they should have a *.a
file extension) and not the MSVC onces (these would have a *.lib
file extension).
If you have the incorrect libraries I would download this exact file from SDL's webpage, as it should have what you need (this is SDL 2.0.8 for mingw specifically): direct link download page -- you want SDL2-devel-2.0.8-mingw.tar.gz
Hope this helps!
I do have the MinGW ones, I will start using them now. Hopefully it will work.
EDIT: I haven't tried directly linking SDL2_LIBRARY to the *.a
file.
I tried linking it and it gives me this error, even though the file exists:
G__~1.EXE: error: C:Users*****DownloadsSDL2-2.0.8x86_64-w64-mingw32liblibSDL2.dll.a: No such file or directory
That's strange. Maybe try copying the library files to the /lib folder of your MinGW installation? Personally that is where I have the SDL2 libraries installed on my system.
I have forgotten to change SDL2_INCLUDE_DIR...and I didn't need to include SDL2_LIBRARY in my cmake ..
command. It seems to compile fine now.
When I run the program, it displays nothing and crashes immediately. EDIT: Compiled from fresh code and it seems to work fine. I had to manually enter the SDL.h location inside the code but compiled flawlessly. Is it supposed to look like this?: EDIT2: There is little to no sound at all, and the sound that comes out is just popping noises. EDIT3: Made a new issue for this specific issue.
@Mario0051 , could you share your cmake file with me? I have the same problem, but still can't resolve.
Actually all you need to do is to replace the path in between the <> in the files APU.cpp, Main.cpp, and Video.hpp with where your SDL.h is located:
#include <SDL2/SDL.h>
For example:
#include <C:/Users/*****/Downloads/SDL2-2.0.9/x86_64-w64-mingw32/include/SDL2/SDL.h>
Actually all you need to do is to replace the path in between the <> in the files APU.cpp, Main.cpp, and Video.hpp with where your SDL.h is located:
#include <SDL2/SDL.h>
For example:
#include <C:/Users/*****/Downloads/SDL2-2.0.9/x86_64-w64-mingw32/include/SDL2/SDL.h>
You should NEVER hardcode local paths! Also, just use #include <SDL.h>
, if it gives you problems, you're not properly using sdl2-config
.
What do I do to fix this? I am compiling with mingw32-make.