Skip to content

Commit 4fd713e

Browse files
authored
Merge pull request #521 from MitchBradley/WindowsNativePIO
Fixes to Platformio env=native
2 parents d0beeee + d8776a3 commit 4fd713e

File tree

2 files changed

+104
-0
lines changed

2 files changed

+104
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
2+
## Steps to use LovyanGFX in Visual Studio Code + PlatformIO + SDL2 environment
3+
4+
First, install Visual Studio Code and install its PlatformIO extension.
5+
6+
---
7+
8+
### Install tools for PlatformIO `platform = native` builds
9+
10+
`Installation` Follow the installation steps from this URL
11+
https://docs.platformio.org/en/latest/platforms/native.html#installation
12+
13+
The instructions below repeat the instructions given by the URL above with additional clarifications.
14+
15+
#### For Linux
16+
17+
Use `apt` to install the basic compilation tools from a shell prompt
18+
```
19+
sudo apt update
20+
sudo apt install build-essential
21+
```
22+
23+
#### For macOS
24+
Use `xcode-select` to install xcode compilation tools from a Terminal
25+
```
26+
xcode-select --install
27+
```
28+
29+
#### For Windows
30+
Get `MSYS2` from https://www.msys2.org/ and install it. From the MSYS command window that appears after installation, run this command to install the compiler:
31+
```
32+
pacman -S mingw-w64-ucrt-x86_64-gcc
33+
```
34+
35+
Edit the Windows System Environment Variables (search the web for instructions) and add these to the System variables `Path` variable
36+
```
37+
C:\msys64\mingw32\bin
38+
C:\msys64\ucrt64\bin
39+
C:\msys64\usr\bin
40+
```
41+
42+
43+
---
44+
45+
### Install SDL2
46+
47+
Install `SDL2` per these instructions
48+
https://docs.lvgl.io/latest/en/html/get-started/pc-simulator.html#install-sdl-2
49+
50+
51+
#### For Linux
52+
53+
Install libsdl2 using apt-get
54+
55+
```
56+
sudo apt-get install libsdl2 libsdl2-dev
57+
```
58+
59+
#### For MacOS OSX
60+
61+
Install sdl2 using Homebrew
62+
```
63+
brew install sdl2
64+
```
65+
66+
#### For Windows
67+
68+
`platform = native` In the steps above, msys2 was installed, so get the SDL2-devel-x.xx.x-mingw release package from the SDL2 Github repository at
69+
https://github.com/libsdl-org/SDL/releases
70+
71+
The filename at the time these instructions were written was `SDL2-devel-2.30.0-mingw.zip`.
72+
Unzip it, open the folder inside `x86_64-w64-mingw32`, and confirm that the following four folders appear inside.
73+
- share
74+
- bin
75+
- include
76+
- lib
77+
78+
Open `C:\msys64\mingw32\` and confirm that it also contains those four folders, then add the contents of the fourfSDL2 folders to those inside `C:\msys64\mingw32\`. Typically, those four mingw32 folders are initially empty, so you can simply overwrite the mingw32 folders with the SDL2 ones.
79+
80+
---
81+
82+
### Compiling and Running the example program
83+
84+
#### Build the program
85+
86+
In VsCode, open this folder, i.e. <LovyanGFX>/examples_for_PC/PlatformIO_SDL/. The first time that you do so, PlatformIO will install a lot of packages.
87+
88+
Build the program by clicking on the checkmark icon at the bottom of the VsCode window; its tooltip is PlatformIO:Build.
89+
90+
#### Run the program
91+
92+
Run the program by starting a terminal - click on the icon at the bottom of the VsCode window whose tooltip is "PlatformIO:New Terminal" . Inside the terminal window that appears, type this command
93+
94+
```
95+
.pio/build/native/program
96+
```

examples_for_PC/PlatformIO_SDL/platformio.ini

+8
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@
88
; Please visit documentation for the other options and examples
99
; https://docs.platformio.org/page/projectconf.html
1010

11+
[platformio]
12+
default_envs = native
13+
14+
[env]
15+
lib_extra_dirs=../../
16+
1117
[env:native]
1218
platform = native
1319
build_type = debug
@@ -16,6 +22,8 @@ build_flags = -O0 -xc++ -std=c++14 -lSDL2
1622
-L"/usr/local/lib" ; for intel mac homebrew SDL2
1723
-I"${sysenv.HOMEBREW_PREFIX}/include/SDL2" ; for arm mac homebrew SDL2
1824
-L"${sysenv.HOMEBREW_PREFIX}/lib" ; for arm mac homebrew SDL2
25+
-I"C:/msys64/mingw32/include/SDL2" ; for Windows SDL2
26+
-L"C:/msys64/mingw32/lib" ; for Windows SDL2
1927

2028
[esp32_base]
2129
build_type = debug

0 commit comments

Comments
 (0)