gazebosim / gazebo-classic

Gazebo classic. For the latest version, see https://github.com/gazebosim/gz-sim
http://classic.gazebosim.org/
Other
1.18k stars 480 forks source link

General guide on building gazebo from source on Windows 11 #3390

Closed WillyTuring closed 2 months ago

WillyTuring commented 2 months ago

Hi you guys,

I am developing our custom UI for interacting with 6 dof robotic arm based on Gazebo in wsl2 on Windows11; the primary part is almost finished, now we want to migrate the application to the native Windows OS, since we have done a few modifications on the gazebo source code, we want to build the application from source as well on Windows rather than using Conda or direct gazebo installation with "vcpkg install --triplet=x64-windows gazebo".

The problem we have encountered is that since the CMakeLists.txt file from "https://github.com/gazebosim/gazebo-classic/tree/gazebo11" is intended for the build up on Unix-like system with such as pkg-config tool etc; we have changed a lot to suit the CMake on Windows, but still run into a lot of dependencies problem like Dart package, profiler, tcmalloc just to name a few.

Now my question is that has anyone who has built it from source on Windows, will it work? Is there any general guidance on how to do that? Any suggestions would be really appreciated, thanks in advance.

WillyTuring commented 2 months ago

"That is strange, can you report which packages in not installing .pc files, i.e. where those files are expected to be installed and what files are installed?" ——I want to see a lof of them as you can see from the screenshot above.

But i only tested ogre package. Under "E:\19.gazebo_project\gazebo\installed\x64-windows\lib", we could find ogre*.lib; but under "E:\19.gazebo_project\gazebo\installed\x64-windows\lib\pkgconfig" there is no corresponding .pc files.

WillyTuring commented 2 months ago

No, what do i mean is that the installation for standard cmake library is correct(aka .lib files are being installed correctly); but not the corresponding .pc file, they weren't being installed correctly during the installation process.

traversaro commented 2 months ago

Under "E:\19.gazebo_project\gazebo\installed\x64-windows\lib", we could find ogre*.lib; but under "E:\19.gazebo_project\gazebo\installed\x64-windows\lib\pkgconfig" there is no corresponding .pc files.

Is the folder E:\19.gazebo_project\gazebo\installed\x64-windows\lib\pkgconfig totally empty or just some .pc files are missing? Which .pc files are missing?

WillyTuring commented 2 months ago

pkgconfig_list.txt

I am going to be away from the laptop for a while, gonna come back soon.

WillyTuring commented 2 months ago

@traversaro Any update thoughts?

WillyTuring commented 2 months ago

Man... I still can not figure out the solution, when did you guys past the CI/CD test on Windows build from source with vcpkg?

talregev commented 2 months ago

I can tell you the command we do on the ci. It will do everything from the beginning, so you might want to give him different installed that it will not delete your exist one.

Before that, can you type:

vcpkg list ogre

I want to see the ogre that install on you. (the installed folder should be inside vcpkg folder that vcpkg will find the packages)

Tip, when you share your status with image, please share with the command itself, also copy the text to the comment itself with the image you already share. it will help for searching and point you the things inside the text.

I hope I can help you.

The commands that run on the ci and works:

git clone https://github.com/gazebosim/gazebo-classic
cd gazebo-classic
git clone vcpkg
vcpkg\bootstrap-vcpkg.bat
"C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Visual Studio 2022\Visual Studio Tools\VC\x64 Native Tools Command Prompt for VS 2022.lnk"
cd <path to your gazebo repo>
        cmake . -G Ninja -B build ^
            -DCMAKE_BUILD_TYPE=Release ^
            -DCMAKE_TOOLCHAIN_FILE=vcpkg\scripts\buildsystems\vcpkg.cmake ^
            -DVCPKG_MANIFEST_DIR=deps\vcpkg\manifest ^
            -DVCPKG_OVERLAY_TRIPLETS=deps\vcpkg\triplets ^
            -DVCPKG_INSTALLED_DIR=%CD%\vcpkg\installed ^
            -DVCPKG_TARGET_TRIPLET=x64-windows-release ^
            -DVCPKG_HOST_TRIPLET=x64-windows-release ^
            -DVCPKG_INSTALL_OPTIONS=--clean-after-build ^
            -DUSE_EXTERNAL_TINYXML=ON ^
            -DUSE_EXTERNAL_TINYXML2=ON ^
            -DUSE_EXTERNAL_TINY_PROCESS_LIBRARY=ON ^
            -DGZ_PROTOBUF_USE_CMAKE_CONFIG=ON ^
            -DCMAKE_INSTALL_PREFIX=%CD%\vcpkg\installed\x64-windows-release

Then it install vcpkg dependencies, after that, it will compile gazebo.

Good luck!

WillyTuring commented 2 months ago

Sorry sometimes the text is just too long, if so next time i will upload in the format of .txt file.

command: .\vcpkg.exe list --x-install-root=E:\19.gazebo_project\gazebo\installed image package_list.txt

talregev commented 2 months ago

you are using latest ogre. it will not compile with classic gazebo. In the manifest we lock it to 1.12.9 https://github.com/gazebosim/gazebo-classic/blob/e4b4d0fb752c7e43e34ab97d0e01a2a3eaca1ed4/deps/vcpkg/manifest/vcpkg.json#L143

We also lock the qwt version. Also we lock it by hash, so it also not install the latest version of libs. it install the latest until that hash.

Note if you try to update or add libs things might be break. Try to compile gazebo without modifications to manifest or without adding and change the libs after you install in manifest mode. After you succeed with compile gazebo then start to do your experiment. But again, things may break.

For install the old ogre, you will need to install it with manifest mode with the commands I write you before. You can use the first guide I write for you. But don't update the ports or add new things. try first compile gazebo. First please copy the manifest as is without modifications.

WillyTuring commented 2 months ago

1.Here is the vcpkg.json file; i think i haven't changed anything. vcpkg.json

2.Here is the command. "E:\19.gazebo_project\gazebo>E:\19.gazebo_project\vcpkg\vcpkg.exe install --x-manifest-root=E:\19.gazebo_project\gazebo --x-install-root=E:\19.gazebo_project\gazebo\installed --host-triplet=x64-windows --clean-after-build"

3.Here is the installation output install_out.txt image

talregev commented 2 months ago

try this command first, and show the results:

vcpkg install  --x-manifest-root=..\deps\vcpkg\manifest --x-install-root=installed --host-triplet=x64-windows --clean-after-build

If first command not failed show this:

vcpkg list ogre

It should show you ogre 1.12.9

WillyTuring commented 2 months ago

"--x-manifest-root=..\deps\vcpkg\manifest" ——But there is no manifest file in this directory.

talregev commented 2 months ago

"--x-manifest-root=..\deps\vcpkg\manifest" ——But there is no manifest file in this directory.

adapt the command on your pc.

WillyTuring commented 2 months ago

E:\19.gazebo_project\vcpkg\vcpkg.exe install --x-manifest-root=E:\19.gazebo_project\gazebo --x-install-root=E:\19.gazebo_project\gazebo\installed --host-triplet=x64-windows --clean-after-build

I think this command it is "E:\19.gazebo_project\vcpkg\vcpkg.exe install --x-manifest-root=E:\19.gazebo_project\gazebo --x-install-root=E:\19.gazebo_project\gazebo\installed --host-triplet=x64-windows --clean-after-build"

talregev commented 2 months ago

E:\19.gazebo_project\vcpkg\vcpkg.exe install --x-manifest-root=E:\19.gazebo_project\gazebo --x-install-root=E:\19.gazebo_project\gazebo\installed --host-triplet=x64-windows --clean-after-build

I think this command it is "E:\19.gazebo_project\vcpkg\vcpkg.exe install --x-manifest-root=E:\19.gazebo_project\gazebo --x-install-root=E:\19.gazebo_project\gazebo\installed --host-triplet=x64-windows --clean-after-build"

ok. try this.

Note: My commands is over gazebo classic repo after you clone it, and also clone vcpkg repo and you are inside it. On gazebo classic repo, the manifest is on that folder. https://github.com/gazebosim/gazebo-classic/tree/gazebo11/deps/vcpkg/manifest

I need to go. I will not be available always.

WillyTuring commented 2 months ago

E:\19.gazebo_project\vcpkg\vcpkg.exe install --x-manifest-root=E:\19.gazebo_project\gazebo --x-install-root=E:\19.gazebo_project\gazebo\installed --host-triplet=x64-windows --clean-after-build

I think this command it is "E:\19.gazebo_project\vcpkg\vcpkg.exe install --x-manifest-root=E:\19.gazebo_project\gazebo --x-install-root=E:\19.gazebo_project\gazebo\installed --host-triplet=x64-windows --clean-after-build"

ok. try this.

Note: My commands is over gazebo classic repo after you clone it, and also clone vcpkg repo and you are inside it. On gazebo classic repo, the manifest is on that folder. https://github.com/gazebosim/gazebo-classic/tree/gazebo11/deps/vcpkg/manifest

I need to go. I will not be available always.

That's what i did; then i got error with boost-corotine stated here

1.Here is the vcpkg.json file; i think i haven't changed anything. vcpkg.json

2.Here is the command. "E:\19.gazebo_project\gazebo>E:\19.gazebo_project\vcpkg\vcpkg.exe install --x-manifest-root=E:\19.gazebo_project\gazebo --x-install-root=E:\19.gazebo_project\gazebo\installed --host-triplet=x64-windows --clean-after-build"

3.Here is the installation output install_out.txt image

talregev commented 2 months ago

That's what i did; then i got error with boost-corotine stated here

In your output, you show the cmake command and not the vcpkg install.

You don't follow exactly as my guide ... and I still try to help you ...

WillyTuring commented 2 months ago

install_out.txt Really sorry, i sent the wrong file.

talregev commented 2 months ago

what in this file? E:\19.gazebo_project\vcpkg\buildtrees\boost-coroutine\install-x64-windows-dbg-out.log

WillyTuring commented 2 months ago

image It is looking for vc140; whereas our installation is "boost_context-vc144-mt.lib"

talregev commented 2 months ago

I am not sure. Will you try from scratch and do it like this?

git clone https://github.com/gazebosim/gazebo-classic
cd gazebo-classic
git clone https://github.com/microsoft/vcpkg
cd vcpkg
bootstrap-vcpkg.bat
vcpkg install  --x-manifest-root=..\deps\vcpkg\manifest --x-install-root=installed --host-triplet=x64-windows --clean-after-build

try not modify the commands I will be available later today or tomorrow.

WillyTuring commented 2 months ago

We finally come into the "cmake --build build" phase now.

But we got some unusual errors with runtime libraries; here is the error file: build_Errors.txt

traversaro commented 2 months ago

If you are compiling againt x64-windows vcpkg triplet, you need to compile Gazebo with BUILD_SHARED_LIBS set to ON.

talregev commented 2 months ago

the cmake command you do, is incorrect. It should be as in the guide. Before you run the correct command. Please show and verify that you install the correct ogre. vcpkg list ogre. Then delete the build folder. This step is very important.

Then run it like that:

"C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Visual Studio 2022\Visual Studio Tools\VC\x64 Native Tools Command Prompt for VS 2022.lnk"
cd <path to your gazebo repo>
        cmake . -G Ninja -B build ^
            -DCMAKE_BUILD_TYPE=Release ^
            -DCMAKE_TOOLCHAIN_FILE=vcpkg\scripts\buildsystems\vcpkg.cmake ^
            -DVCPKG_OVERLAY_TRIPLETS=deps\vcpkg\triplets ^
            -DVCPKG_INSTALLED_DIR=%CD%\vcpkg\installed ^
            -DVCPKG_TARGET_TRIPLET=x64-windows^
            -DVCPKG_HOST_TRIPLET=x64-windows^
            -DVCPKG_INSTALL_OPTIONS=--clean-after-build ^
            -DUSE_EXTERNAL_TINYXML=ON ^
            -DUSE_EXTERNAL_TINYXML2=ON ^
            -DUSE_EXTERNAL_TINY_PROCESS_LIBRARY=ON ^
            -DGZ_PROTOBUF_USE_CMAKE_CONFIG=ON ^
            -DCMAKE_INSTALL_PREFIX=%CD%\vcpkg\installed\x64-windows
WillyTuring commented 2 months ago

the cmake command you do, is incorrect. It should be as in the guide. Before you run the correct command. Please show and verify that you install the correct ogre. vcpkg list ogre. Then delete the build folder. This step is very important.

Then run it like that:

"C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Visual Studio 2022\Visual Studio Tools\VC\x64 Native Tools Command Prompt for VS 2022.lnk"
cd <path to your gazebo repo>
        cmake . -G Ninja -B build ^
            -DCMAKE_BUILD_TYPE=Release ^
            -DCMAKE_TOOLCHAIN_FILE=vcpkg\scripts\buildsystems\vcpkg.cmake ^
            -DVCPKG_OVERLAY_TRIPLETS=deps\vcpkg\triplets ^
            -DVCPKG_INSTALLED_DIR=%CD%\vcpkg\installed ^
            -DVCPKG_TARGET_TRIPLET=x64-windows^
            -DVCPKG_HOST_TRIPLET=x64-windows^
            -DVCPKG_INSTALL_OPTIONS=--clean-after-build ^
            -DUSE_EXTERNAL_TINYXML=ON ^
            -DUSE_EXTERNAL_TINYXML2=ON ^
            -DUSE_EXTERNAL_TINY_PROCESS_LIBRARY=ON ^
            -DGZ_PROTOBUF_USE_CMAKE_CONFIG=ON ^
            -DCMAKE_INSTALL_PREFIX=%CD%\vcpkg\installed\x64-windows

I have done the configuration with "cmake ." command; we are at the last step to actually compile the program.

Here is the ogre library: image

talregev commented 2 months ago

I think you did the configuration wrong. Can you delete the build folder and re do the configuration then compile?

talregev commented 2 months ago

I always did with configuration release: cmake --build build --config Release As in the ci.

WillyTuring commented 2 months ago

I finally have it build without error, the result is from command "cmake --build build --config Release": image

But there is a new problem which is we can not open gazebo.exe program successfully. When trying to open it up, we just got error pop up says "Program can not start normally 0xc0000142"

WillyTuring commented 2 months ago

I think the problem is related to the dll files when linking.

talregev commented 2 months ago

set PATH="%PATH%;\vcpkg\installed\x64-windows\bin"

WillyTuring commented 2 months ago

Nope it doesn't work

set PATH="%PATH%;\vcpkg\installed\x64-windows\bin"

I found out the actual .dll are located all over the place: image

talregev commented 2 months ago

There is a bat file that add these folders of the dlls to the path. Can you do it manually and check?

WillyTuring commented 2 months ago

There is a bat file that add these folders of the dlls to the path. Can you do it manually and check?

We haven't changed that to the setup.bat file yet cause that requires the re-configure with "cmake ." command i think.

I tried manually set up the path though: image The error persists no change.

talregev commented 2 months ago

Do you see the splash screen?

talregev commented 2 months ago

gazebo --verbose

WillyTuring commented 2 months ago

image Something like that, then pops up the error with information "Program can not start normally 0xc0000142; click enter to close it".

WillyTuring commented 2 months ago

--verbose didn't print out anything..

talregev commented 2 months ago

gazebo --help? gazebo -v? I forget how to show verbose. I remember something like that ... I am not sure what I did

WillyTuring commented 2 months ago

--verbose is the correct command; but just didn't print out anything in our case currently.

talregev commented 2 months ago

separate them in 2 terminals: gzserver.exe --verbose gzclient.exe --verbose

WillyTuring commented 2 months ago

image No luck yet.

talregev commented 2 months ago

So I am not sure what to do.

talregev commented 2 months ago

You can build it in debug mode, and start debug it.

WillyTuring commented 2 months ago

So I am not sure what to do.

Me neither, kind of stuck now...no clue about moving forward.

talregev commented 2 months ago

Can you share the image of the error msg?

talregev commented 2 months ago

Ha! you missing the install step.

talregev commented 2 months ago
      cmake --install build --config Release
talregev commented 2 months ago

Did you give it in the configure this line? -DCMAKE_INSTALL_PREFIX=%CD%\vcpkg\installed\x64-windows

WillyTuring commented 2 months ago

Did you give it in the configure this line? -DCMAKE_INSTALL_PREFIX=%CD%\vcpkg\installed\x64-windows

Yessir. image

      cmake --install build --config Release

I did install with exact command.

talregev commented 2 months ago

Now run the gazebo from vcpkg\installed\x64-windows-release\bin\gazebo --verbose