0. MINIGUI
MiniGUI is an advanced Windowing System and Graphical User Interface (GUI) support System for embedded systems, developed by Mr. Wei Yongming in late 1998.
In 2002, Mr. Wei yongming founded Beijing Flyman Software Technology Co., LTD., which provides commercial technical support for MiniGUI and also continues to provide open source versions. Flyman software is the software enterprise that contributes the most code to the open source community in China. The last gPL-licensed version of MiniGUI was 1.6.10. Starting with MiniGUI 2.0.4, MiniGUI was rewritten to use commercial licenses.
One, installation preparation
1. Software version
Install the MINIGUI programming environment
- MINIGUI version 3.2.0
- Installation system: Ubuntu16.04
I have to say that MINIGUI installation is too complicated, so this article will comfort my 7 hour soul, sort out my setup and configuration process (from zero to running helloWorld), and provide a little guidance and help for the next generation of employees.
2. Download address
In this paper, according to official installation of MINIGUI document, document address: www.minigui.com/blog/minigu…
Please use Ubuntu 16.04 as the latest version of Ubuntu may cause all kinds of “weird” errors during installation.
Two, the preparation work before installation
Assume you have successfully installed the Ubuntu16.04 operating system
1. Install various dependent software
You need to make sure you have the following software installed. If not, run sudo apt-get install to install it.Copy the code
1) git 2) GCC /g++ 3) binutils 4) autoconf/automake 5) libtool 6) make 7) cmake 8) pkg-configCopy the code
2. Install various dependent libraries
You need to ensure that the following dependency libraries are installed. If not, run sudo apt-get install library name to install it.Copy the code
1) libgtk2.0-dev
2) libjpeg-dev
3) libpng12-dev
4) libfreetype6-dev
5) libsqlite3-dev
6) libxml2-dev
Copy the code
3. Configure a Github authentication key
You need to clone the MINIGUI installation package from Github, so you need to configure Github key authentication.
- Start by setting up an account on Github. Registration is free. Remember the email address you signed up for.
- Then on Ubuntu, run the following command:
Ssh-keygen -t rsa-c (in uppercase) Your email addressCopy the code
A message is displayed after the command is executed. The first prompt indicates the location for saving the generated public and private keys. SSH for common users and /root/. SSH for root users (the directory is hidden). The second prompt indicates the login password. Just press Enter (no password required). The third prompt indicates to confirm the password, also directly press Enter. After the public and private keys are generated, go to the. SSH directory and view the contents of id_rsa.pub. Go to Github, go to Settings in your account, hit New SSH key, and copy the id_rsa.pub content into the text box.
After the addition, run it in Ubuntussh -T [email protected]
Test whether the connection is successful. If the welcome message is displayed, the connection to Github is successful. If Permission Denied is displayed, the connection fails. The connection may fail because the public and private key configurations do not take effect. performssh-add ~/.ssh/id_rsa
Add the generated public and private keys to Github and test them again.
Download the full MINIGUI installation package
Use Git’s Clone feature to get the complete MINIGUI3.2 code file. Execute command:
git clone[email protected]: VincentWei/build - minigui - 3.2. GitCopy the code
VincentWei is the inventor and maintainer of MINIGUI.
After obtaining it, go to the Build directory
cdThe build - minigui - 3.2Copy the code
Run the FETCH script in that directory to get the full MINIGUI source code.
./fetch-all.sh
Copy the code
Wait for the download to complete.
Iv. Installation process
The following directories, unless otherwise specified, use build-MiniguI-3.2 as the base directory
1. Install the GVFB dependency library
Go to the GVFB directory. Run the following commands in sequence:
Cmake. Make sudo make installCopy the code
2. Install chipmunk dependency library
Access the 3rd-party/chipmunk-5.3.1 directory. Run the following commands in sequence:
Cmake. Make sudo make installCopy the code
3. Compile MINIGUI source code
Go to the minigui-res directory. Run the following commands in sequence:
./autogen.sh
./configure
sudo make install
Copy the code
4. Create all the code
Go back to the build-minigui-3.2 directory and run the following command:
./build-all.sh
Copy the code
Wait for build to complete.Copy the code
Verify whether the installation is successful
Wait until the build is complete. If no error message is displayed, the MINIGUI3.2 programming environment is successfully installed. We can verify that the installation was successful in two ways.
Method one:
The /usr/local/bin directory contains a program named./mguxdemo. Run the program. This program is a mobile phone-like system application written by using MINIGUI. If the program can be run without crash or error, it means that MINIGUI is successfully installed.
Method 2:
The mg-sample directory is displayed. Execute the command in this directory:
./configure
make
Copy the code
Then go to the same directory in the current directory and run the same program
./same
Copy the code
The program is an elimination mini-game.
Note: Errors may occur during compilation. Run the./build-all.sh script again.
Write helloWorld program
Next, write a HelloWorld program. The code refers to the miniGUI Programming Guide V3.0 chapter 2 of the program, but with a few minor changes (mainly the elimination of process mode to thread mode). The code is as follows:
#include<stdio.h>
#include<minigui/common.h>
#include<minigui/gdi.h>
#include<minigui/minigui.h>
#include<minigui/window.h>
#include<minigui/control.h>
static int HelloWin(HWND hwnd, int message, WPARAM wParam, LPARAM lParam)
{
HDC hdc;
switch(message)
{
case MSG_PAINT:
hdc = BeginPaint(hwnd);
TextOut(hdc,60.60."HelloWorld!");
EndPaint(hwnd,hdc);
return 0;
case MSG_CLOSE:
DestroyMainWindow(hwnd);
PostQuitMessage(hwnd);
return 0;
}
return DefaultMainWinProc(hwnd,message,wParam,lParam);
}
int MiniGUIMain(int argc, const char *argv[])
{
MSG Msg;
HWND hMainWnd;
MAINWINCREATE CreateInfo;
CreateInfo.dwStyle = WS_VISIBLE | WS_BORDER | WS_CAPTION;
CreateInfo.dwExStyle = WS_EX_NONE;
CreateInfo.spCaption = "HelloWorld";
CreateInfo.hMenu = 0;
CreateInfo.hCursor = GetSystemCursor(0);
CreateInfo.hIcon = 0;
CreateInfo.MainWindowProc = HelloWin;//
CreateInfo.lx = 0;
CreateInfo.ty = 0;
CreateInfo.rx = 240;
CreateInfo.by = 180;
CreateInfo.iBkColor = COLOR_lightwhite;
CreateInfo.dwAddData = 0;
CreateInfo.hHosting = HWND_DESKTOP;
hMainWnd = CreateMainWindow(&CreateInfo);
if(hMainWnd == HWND_INVALID)
return - 1;
ShowWindow(hMainWnd,SW_SHOWNORMAL);
while(GetMessage(&Msg, hMainWnd))
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
MainWindowThreadCleanup(hMainWnd);
return 0;
}
Copy the code
Then run GCC to compile, but be aware that you need to link to various dynamic libraries. The compile command is as follows:
gcc xxx.c -o xxx -lminigui_ths -ljpeg -lpng -lz -lpthread -lfreetype
Copy the code
Among them:
- 1) LMINigui_THS: MINIGUI runs the required libraries in thread mode. Note that this parameter must be placed first because it depends on subsequent dynamic libraries. If the compiler shows that it cannot find the library, install it as follows. When compiling with GCC, note that if library A depends on library B, A must come before B.
- 2) -LJPEG, -LPNG: jpeg and PNG format image support library
- 3) -LZ: Data compression library
- 4) -lpThread: thread library
- 5) -lfreeType: font library
The running results are as follows:
Libminigui_ths installation procedure
If you are prompted at compile time that the Minigui_THS library is missing, follow these steps to install it.
1) Obtain the GPG key of FMsoft
Since minigui_this library needs to be downloaded and installed by the official MINIGUI using apt-get, it needs to obtain their authentication in advance. Execute command:
wget -qO - http://files.fmsoft.cn/ubuntu/key/fmsoft.gpg | sudo apt-key add -
Copy the code
Note that the second option is uppercase
2) Add FMsoft to apt installation server
/etc/apt/source.list = /etc/apt/source.list
deb http://files.fmsoft.cn/ubuntu/ xenial restricted
Copy the code
Save and exit, and run commands to update the APT configuration.
sudo apt update
Copy the code
3) Download and install
Run the following command to download and install:
sudo apt install libminigui-ths-dev
Copy the code