MiniGui 编译hello.c 文件成功!记载一下!
MiniGui 版本v3.0 和 2 编译 差异 是极其的大!
源文件代码 :
#include <stdio.h> #include <minigui/common.h> #include <minigui/minigui.h> #include <minigui/gdi.h> #include <minigui/window.h> static int HelloWinProc(HWND hWnd, int message, WPARAM wParam, LPARAM lparam){ HDC hdc; switch (message){ case MSG_PAINT: hdc = BeginPaint(hWnd); TextOut(hdc, 60 , 60 , "duanYuLei!" ); EndPaint(hWnd, hdc); return 0 ; case MSG_CLOSE: DestroyMainWindow(hWnd); PostQuitMessage(hWnd); return 0 ; } return DefaultMainWinProc(hWnd, message, wParam, lparam);} int MiniGUIMain( int argc, char const *argv[]){ MSG Msg; HWND hMainWnd; MAINWINCREATE CreateInfo; #ifdef _MGRM_PROCESSES JoinLayer(NAME_DEF_LAYER, "HelloWorld" , 0 , 0 ); #endif 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 = HelloWinProc; CreateInfo.lx = 0 ; CreateInfo.ty = 0 ; CreateInfo.rx = 240 ; = 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 ;} #ifndef _MGRM_PROCESSES#include <minigui/dti.c> #endif
照着官方文档编译都会失败。原来官方文档都不全面!
正确编译规则:
编译选项:
gcc HelloWorld.c -lminigui_ths -lpthread -lpng -ljpeg -lz -ldl -o (filename)
无线程
gcc –o helloworld helloworld.c –lminigui_procs –ljpeg –lpng –lz -ldl
PS:开始画MiniGui 界面!
图片: