LCM Setup (Windows) - AmyPhung/virtual-control-room GitHub Wiki
-
Java Note: Tested and Updated By Ever
- Download and run jdk-8u261-windows-x64.exe from https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html. You may have to make a Java account to download the file, but at least it's free.
- Open up a Command Prompt
- Set
JAVA_HOMEenvironment variable toC:\Program Files\Java\jdk1.8.0_261-
set JAVA_HOME=C:\Program Files\Java\jdk1.8.0_261(for current session) -
setx JAVA_HOME "C:\Program Files\Java\jdk1.8.0_261"(for every subsequent session)
-
- Add
C:\Program Files\Java\jdk1.8.0_261\jre\bin,C:\Program Files\Java\jdk1.8.0_261\jre\bin\server,C:\Program Files\Java\jdk1.8.0_261\binto thePATHenvironment variable-
set PATH=C:\Program Files\Java\jdk1.8.0_261\bin;C:\Program Files\Java\jdk1.8.0_261\jre\bin\server;C:\Program Files\Java\jdk1.8.0_261\jre\bin;%PATH%(for current session) -
setx PATH "C:\Program Files\Java\jdk1.8.0_261\bin;C:\Program Files\Java\jdk1.8.0_261\jre\bin\server;C:\Program Files\Java\jdk1.8.0_261\jre\bin;%PATH%"(for every subsequent session
-
- Set
-
Python Note: Tested and updated by Amy (new setup)
- Install Anaconda Python from https://www.anaconda.com/products/individual
- Add path to Anaconda Python executable to PATH environment variable (default is
%USERPROFILE%\Anaconda3)
set PATH=C:\%USERPROFILE%\Anaconda3;%PATH%setx PATH "C:\%USERPROFILE%\Anaconda3;%PATH%"
- Open Anaconda Prompt
- Upgrade pip package manager by running
python -m pip install --upgrade pip - Install pyjnius package by running
pip install pyjnius
- Upgrade pip package manager by running
-
Install Visual Studio
- Download the Windows Visual Studio Community 2019 from this link
- Check unity hub when downloading
- Install “Desktop Development with C++”

- Download the Windows Visual Studio Community 2019 from this link
-
Setup GLib for Windows (reference).
- Install
msys2-x86_64-20180531.exefrom https://www.msys2.org/ - Run MSYS2 by opening it from the start menu or running C:\msys64\msys2_shell.cmd

- In the MSYS window, run
pacman -S mingw-w64-x86_64-gtk3 
- Open a Command Prompt
- Add
C:\msys64\mingw64\libto PATH environment variable- Sets path permanently, but not for current session
setx PATH "C:\msys64\mingw64\lib;%PATH%"
- Sets path for current session, but not permanently
set PATH=C:\msys64\mingw64\lib;%PATH%
- Sets path permanently, but not for current session
- Add
C:\msys64\mingw64\binto PATH environment variable- Sets path permanently, but not for current session
setx PATH "C:\msys64\mingw64\bin;%PATH%"
- Sets path for current session, but not permanently
set PATH=C:\msys64\mingw64\bin;%PATH%
- Sets path permanently, but not for current session
- After these steps, you should see these values when you run the command
echo %PATH%
- Install
-
Install CMake
- Download
cmake-3.18.3-win64-x64.msifrom https://cmake.org/download/ - Add CMake to system path for all users

- Download
-
LCM
- Clone this repository (can be a temporary location, like the Downloads folder) https://github.com/AmyPhung/lcm
- Note: This repository was forked because the original one won't build without edits to the source code
- If git isn't installed, download it from here https://gitforwindows.org/
- Configure in CMake
- Open CMake (cmake-gui) (Can open this by pressing the windows key and searching for "CMake"
- Point “Where is the source code” to the ...\lcm-1.4.0 (e.g.
C:/Users/aphung/Downloads/lcm-1.4.0) - Point “Where to build the binaries” to ...\lcm-1.4.0\build (e.g.
C:/Users/aphung/Downloads/lcm-1.4.0/build) (it should not yet exist, manually write it into the box) - Click "Configure" and use the default options (Specify “Visual Studio 16 2019” as the generator and use default native compilers). There will be errors, this is normal - we will fix them in a bit!
- EXCEPT if you get an error saying that
No CMAKE_C_COMPILER could be found, orNo CMAKE_CXX_COMPILER could be found. This error looks like the following.
To fix this, you'll want to go back to your Visual Studio Installer, uncheck and recheck "Desktop Development with c++" and reinstall Visual Studio. Then try clicking "Configure" again.
- Point “Where is the source code” to the ...\lcm-1.4.0 (e.g.
- Modify the settings (reference)
- Check the "Advanced" box in the upper section of the CMake GUI
- Change these values
-
GLIB2_GLIBCONFIG_INCLUDE_DIRtoC:/msys64/mingw64/lib/glib-2.0/include -
GLIB2_GLIB_INCLUDE_DIRtoC:/msys64/mingw64/include/glib-2.0 -
GLIB2_GLIB_LIBRARYtoC:/msys64/mingw64/lib/libglib-2.0.dll.a -
GLIB2_GLIB_RUNTIMEtoC:/msys64/mingw64/bin/libglib-2.0-0.dll - Uncheck
LCM_ENABLE_PYTHON - Uncheck
LCM_ENABLE_TESTS
-

- Click “Configure” again
- Once “Configuring Done” appears
- Scroll down in the list of CMake options and uncheck “LCM_ENABLE_TESTS”
- Click “Configure” again - There should be no more red boxes at this point
- Click “Generate”
- Note: There might be some CMake warnings, but as long as it says
Configuring donein the bottom it should be ok
- Note: There might be some CMake warnings, but as long as it says
- Open CMake (cmake-gui) (Can open this by pressing the windows key and searching for "CMake"
- Build lcm in Visual Studio 2019
- Open ...\lcm-1.4.0\build\lcm.sln (can be done by clicking “Open Project” in CMake. Find it manually if "Open Project" opens the file in a different version of Visual Studio)

- Set solution configuration to “Release”

- Build solution

- Install lcm
- Close and reopen Visual Studio 2019 as administrator

- Open
...\lcm-1.4.0\build\lcm.sln - Build the “INSTALL” project
- Right click the INSTALL project → Project Only → Build Only INSTALL
- This will install the built binaries into
C:\Program Files (x86)\lcm 
- If everything builds successfully, you should see it complete with no errors
- Add
C:\Program Files (x86)\lcm\binto the system PATH environment variablesetx PATH "C:\Program Files (x86)\lcm\bin;%PATH%"set PATH=C:\Program Files (x86)\lcm\bin;%PATH%
- Clone this repository (can be a temporary location, like the Downloads folder) https://github.com/AmyPhung/lcm
Ensure that all paths are properly added - if this error pops up, instead of adding the paths through the command line, open the environment variable editor on the computer and add the paths manually

CMake Error at CMakeLists.txt:3 (project):
Generator
Visual Studio 16 2019
could not find any instance of Visual Studio.
- Open Visual Studio
- Go to Tools -> Get Tools and Features
- In the "Workloads" tab enable "Desktop development with C++"
- Click Modify at the bottom right
Could NOT find GLib2_glib (missing: GLIB2_GLIB_LIBRARY)
CMake Error at C:/Program Files/CMake/share/cmake-3.18/Modules/FindPackageHandleStandardArgs.cmake:165 (message):
Could NOT find GLib2 (missing: GLIB2_GLIB_LIBRARY glib)
Call Stack (most recent call first):
C:/Program Files/CMake/share/cmake-3.18/Modules/FindPackageHandleStandardArgs.cmake:458 (_FPHSA_FAILURE_MESSAGE)
cmake/FindGLib2.cmake:114 (find_package_handle_standard_args)
CMakeLists.txt:10 (find_package)
(Note that you can set these in cmake-gui also. You will need to check the 'advanced' check box to see them, however.)
-DGLIB2_GLIBCONFIG_INCLUDE_DIR:PATH=C:/msys64/mingw64/lib/glib-2.0/include \
-DGLIB2_GLIB_INCLUDE_DIR:PATH=C:/msys64/mingw64/include/glib-2.0 \
-DGLIB2_GLIB_LIBRARY:FILEPATH=C:/msys64/mingw64/lib/libglib-2.0.dll.a \
-DGLIB2_GLIB_RUNTIME:FILEPATH=C:/msys64/mingw64/bin/libglib-2.0-0.dll \
Need to make these edits https://github.com/lcm-proj/lcm/issues/256
In lcm/windows/WinPorting.cpp, include winsock2.h before Mswsock.h, i.e., replace
#include <Mswsock.h>
#include <stdio.h>
#include <winsock2.h>
with
#include <stdio.h>
#include <winsock2.h>
#include <Mswsock.h>
In lcmgen/emit_go.c, replace
#include <unistd.h>
#ifdef WIN32
#define __STDC_FORMAT_MACROS // Enable integer types
#endif
with
#ifndef WIN32
#include <unistd.h>
#endif
#ifdef WIN32
#define F_OK 0 /* Test for existence. */
#define __STDC_FORMAT_MACROS // Enable integer types
#endif
In the CMake GUI, uncheck LCM_ENABLE_GO, LCM_ENABLE_LUA, LCM_ENABLE_TESTS. Hopefully I won't need those. I didn't spend too much time troubleshooting.
Build in Release. (I don't have the debug Python library python36_d.lib.)
Or use this repository which fixes them: https://github.com/AmyPhung/lcm
(Note: using gvsbuild instructions to work with Visual Studio. Follow the [gvsbuild instructions] here's a few install notes + Follow these instructions to set-up (https://github.com/wingtk/gvsbuild) + Install MSYS2 (https://www.msys2.org/) + Note: I had MSYS2 already installed but it wouldn't update properly for me so I reinstalled it + pacman -Syu + Install Python 3.6 + Note: I already had this installed + If you get really weird errors when running the pacman commands, try rebooting your computer, deleting the MSYS folder, and reinstalling.
cd C:\gtk-build\github\gvsbuild
Use install command for 64-bit system and Visual Studio 2019 python .\build.py build -p x64 --vs-ver 19 gtk3
GLib (Run-time, dev) gettext-runtime (Run-time)
