I see you are manually trying to have it build in 64-bit with the -m64 option. I have never used this... but a common problem that could cause your error is that a 64-bit DLL is trying to be loaded into a 32-bit process.
Three things, if you would:
- Determine if the .exe output is 32-bit or 64-bit. You can do that by following the directions here:
https://superuser.com/a/889267 Let us know what the result is.
- Can you add verbose to your build script by adding -v to your CXXFLAGS, and then post the output?
- Since it compiles fine, can you open your .exe file with the Dependency Walker?
http://www.dependencywalker.com/
One more note, I just realized:
A lot of "pre-built" binaries from websites like to pretend that Windows == Visual Studio, and that other ways to compile programs don't exist.
I'm not sure if your glew32.lib is compatible with MinGW. Maybe this link helps
https://stackoverflow.com/questions/7241047/linking-lib-files-with-mingw
You might have to build glew32 yourself!
Edit: Gonna try compiling myself with g++ to see what happens.
Edit 2: Okay I stopped trying. Since you figured it out, bump the topic if you have more questions.
In general, I always just build everything myself, usually with MSYS2. Getting libraries like FFTW3 to build without MSYS2 is a PITA.