-
-
Notifications
You must be signed in to change notification settings - Fork 265
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
c++ export is hard to compile in windows #296
Comments
It's pretty strange you want to compile w/o cmake when cmake output is explicitly what the export generates, then complain it's hard. :-) Thanks for documenting how to do it for the curious though! |
@ctrlcctrlv No, you've got it wrong. |
Oh! Sorry, I see that now. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
First of all, thanks for such a cool editor!
I tried to build in msvc 2019 and got an error:
Error LNK2019 unresolved external symbol "int __cdecl invoke_main(void)" (?invoke_main@@YAHXZ
I got tired of suffering with the CMAKE config in VS and I tried to build using MSYS2 (with mingw compiler), after agonizing over there, I ended up with a similar problem
undefined reference to 'WinMain'
in the end, it was necessary to add
#define SDL_MAIN_HANDLED
(before#include <GL/glew.h>
) to export.cpp and then it compiled!You also need to install
mingw-w64-x86_64-cmake
and don't use the default cmake from msys2 (remove it and restart ) otherwise you won't get past theCould NOT find OpenGL error (missing: OPENGL_opengl_LIBRARY OPENGL_glx_LIBRARY)
even if you installmingw64/mingw-w64-x86_64-mesa
.I was also able to build without any cmake this way:
g++.exe -mwindows export.cpp -o export.exe -lmingw32 -lsdl2 -lopengl32 -lglu32 -lglew32
I also had to comment:
glUniform4fv(glGetUniformLocation(Image_SP, "iMouse"), 1, glm::value_ptr(shaderVariable));
because it couldn't defined
shaderVariable
:error: 'shaderVariable' was not declared in this scope
.Some tips
For static build (no need lib*.dll but need put SDL2.dll and glew32.dll in exe folder):
Add in CMakeLists.txt
-static
by replacetarget_link_libraries(ShaderProject GLEW::GLEW SDL2::SDL2)
to
target_link_libraries(ShaderProject GLEW::GLEW SDL2::SDL2 -static)
Compile without console window:
Replace in CMakeLists.txt
add_executable(ShaderProject ${SOURCES})
to
add_executable(ShaderProject WIN32 ${SOURCES})
For beginners:
cmake . && cmake --build .
for configure and build by cmakeYou need to install glew sdl2 glm packages via
pacman -S packagename
(use search viapacman -Ss packagename
).The text was updated successfully, but these errors were encountered: