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

Upgraded build system to run cmake and build on modern windows. #8

Merged
merged 26 commits into from Oct 9, 2021

Conversation

vblanco20-1
Copy link

Build system moved into CMake. To build, just run cmake and make sure to set the SDLMIXER_PATH and SDL_PATH variables so that it can find SDL.

The cmake build files default to win64. I dont have linux so i cant check what to fix to make them build on linux.

Boost removed from bullet ML, code builds on Cpp14 now. boost::shared_ptr is swapped with std::shared_ptr

BulletML embedded into the project.

Dirint swapped with a windows capable version from https://github.com/tronkko/dirent (mit license). Removes the need for minGW.

The PR only changes the build, game code is left as-is, no changes to anything.

The PR is unfinished, i want to fix it to also build linux before it should get merged.

Ive created this commit as a release, so that its possible to try the compiled version https://github.com/vblanco20-1/rrootage/releases/tag/pr0.1

@vblanco20-1
Copy link
Author

Updated: I ported everything to work on Linux (ubuntu) by using github actions. Linux version will be built automatically in actions, but i cant run it for testing myself.

@vblanco20-1
Copy link
Author

Made the scripts automatically download SDL. This makes the project 1-click-compile on windows, and on linux you just apt-get the SDL libs. Too bad git decided to un-squash the commits.

@abagames
Copy link
Owner

Do I need to install Visual Studio Community 2019 or something similar in order to build this code with CMake?

@vblanco20-1
Copy link
Author

vblanco20-1 commented Feb 21, 2021

@abagames Doesnt have to be the latest VS, 2017 would also work. To make it work you need to use the standalone cmake to generate a VS project. Its also possible to get it working on visual studio code if you have the cmake extension installed. Then you can open the project directly in Vscode and get it building.
The cmake script is configured to build in 64 bit and 32 bit.

The executable will be added to the cmake build folder you specified, and gotta copy the DLLs there manually. (the new DLLs, not the current ones on the root of the project which are old ones). The binaries will be generated under the folder build/bin/Debug/ (or Release). And SDL and mixer are downloaded under the build/libs folder, to grab the DLLs from them.

@abagames
Copy link
Owner

I am not familiar with CMake, can you tell me how to build rr.exe? I installed Build Tools for Visual Studio 2019 and ran 'cmake .' in the root directory of the repository. Some files were generated, but rr.exe does not seem to be generated.

@vblanco20-1
Copy link
Author

vblanco20-1 commented Feb 22, 2021

I generally use the cmake GUI, but if you want touse the commandline, you can use the commands that the CI pipeline in github actions use, which are:

cmake -DCMAKE_BUILD_TYPE=Release
cmake --build . --config Release

From the root folder of the project. That should compile rr.exe under the /bin/Release/folder. Should be completely automatic, dependencies like SDL are automatically installed.

If you want to use the GUI instead (to edit parameters more easily, like build folder), then you can check this part of the vulkan tutorial i wrote. The scripts used for that tutorial are similar to the ones i used here, except they install SDL automatically. https://vkguide.dev/docs/chapter-0/building_project/

Keep in mind the rr.exe will default to 64 bit build, and will need the 64 bit DLLs. The SDL dlls are autodownloaded on the "libs" folder

@abagames
Copy link
Owner

I entered the above command, but I got the following error. (It is inconvenient that the tool is localized so that messages are written in Japanese.)

libucrt.lib(_file.obj) : error LNK2005: _iob は既に barragemanager.cc.obj で定義されています。
-- snip ---
SDLmain.lib(SDL_win32_main.obj) : error LNK2019: 未解決の外部シンボル __imp_remove が関数 cleanup_output で参照されまし た
SDLmain.lib(SDL_win32_main.obj) : error LNK2019: 未解決の外部シンボル __imp_setbuf が関数 redirect_output で参照されました
SDLmain.lib(SDL_win32_main.obj) : error LNK2019: 未解決の外部シンボル __imp_freopen が関数 redirect_output で参照されま した

The following is a translation into English.

libucrt.lib(_file.obj) : error LNK2005: _iob is already defined at barragemanager.cc.obj
-- snip ---
SDLmain.lib(SDL_win32_main.obj) : error LNK2019: undefined external symbol __imp_remove is referenced at cleanup_output
SDLmain.lib(SDL_win32_main.obj) : error LNK2019: undefined external symbol __imp_setbuf is referenced at redirect_output
SDLmain.lib(SDL_win32_main.obj) : error LNK2019: undefined external symbol __imp_freopen is referenced at redirect_output

Is there anything you can think of as a solution? Do I need to do something like 'make clean'?

@vblanco20-1
Copy link
Author

@abagames I havent seen that error with libucrt.lib. How exactly are you trying to compile it? And on what windows version. Can you try using the CMake gui? In there you can select what compiler and architecture to use. Maybe if you are doing cmake through commandline by default its selecting a minGW compiler.

With CMakegui, you have to set source code folder, then build folder, and then click Configure and then Generate to create VS project.
image

@abagames
Copy link
Owner

I understood.

  1. Use cmake-gui to generate the .sln file and other necessary files in the build directory.
  2. Open the rRootage.sln file using Visual Studio Community 2019.
  3. Build it.
  4. rR.exe is generated in the bin/Release directory.
  5. Copy the dlls needed for execution from the libs directory.
  6. Copy the sounds directory and other necessary resources.
  7. Run rR.exe.

With these steps I was able to build and run rR.exe.
I would like to keep the original build method using MSYS2 in the master branch. Therefore, I will create a new branch named cmake and merge this PR into it.

@vblanco20-1
Copy link
Author

Im going to see if i can improve the cmake file a bit to make it easier. Should the .exe be generated in the root folder? That can be automatically done.

@abagames
Copy link
Owner

I think it would be easier to build and run if all the necessary exe and dll files were placed in the root folder.

@vblanco20-1
Copy link
Author

Very well ill go modify it for that

@vblanco20-1
Copy link
Author

@abagames I tried a few ways, but wasnt happy with the result due to MSVC doing MSVC things. At the end, ive added a copy command to the build script.

The executable will be created under the /bin/ folder, but after it compiles rr.exe, it will copy it into root folder automatically. It will also copy the DLLs. Only does the DLL copy on windows, on linux some of those DLLs might just be on system paths. The .exe is copied on both platforms.

Let me know if thats alright with you.

@abagames abagames changed the base branch from master to cmake March 1, 2021 10:31
@abagames
Copy link
Owner

abagames commented Mar 1, 2021

I was able to confirm that the exe and dll files are copied to the root folder in my environment. If everything is ok, I will merge this PR into the cmake branch.

@abagames
Copy link
Owner

abagames commented Mar 1, 2021

I'm also planning to add a brief description of how to build with cmake in the README.

@abagames abagames linked an issue Mar 2, 2021 that may be closed by this pull request
@abagames abagames merged commit 68de95f into abagames:cmake Oct 9, 2021
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

Successfully merging this pull request may close these issues.

Modernizing the game libraries and build (PR discussion)
2 participants