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

c++ export is hard to compile in windows #296

Open
0x4E69676874466F78 opened this issue Sep 17, 2022 · 3 comments
Open

c++ export is hard to compile in windows #296

0x4E69676874466F78 opened this issue Sep 17, 2022 · 3 comments

Comments

@0x4E69676874466F78
Copy link

0x4E69676874466F78 commented Sep 17, 2022

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 the Could NOT find OpenGL error (missing: OPENGL_opengl_LIBRARY OPENGL_glx_LIBRARY) even if you install mingw64/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 replace
target_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 cmake
You need to install glew sdl2 glm packages via pacman -S packagename (use search via pacman -Ss packagename).

@ctrlcctrlv
Copy link
Contributor

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!

@0x4E69676874466F78
Copy link
Author

@ctrlcctrlv No, you've got it wrong.
All the problems are present and with the building through cmake. I wrote without cmake as a supplement no more.

@ctrlcctrlv
Copy link
Contributor

Oh! Sorry, I see that now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants