分类: LINUX
2011-12-21 13:03:01
1. 在Eclipse中新建工程,加入helloworld源程序。源程序如下:
#include
#include
#include
#include
#include
#include
#include
static int HelloWinProc (HWND hWnd, int message, WPARAM wParam, LPARAM lParam)
{
HDC hdc;
switch (message) {
case MSG_PAINT:
hdc = BeginPaint (hWnd);
TextOut (hdc, 0, 0, "Hello, world!");
EndPaint (hWnd, hdc);
break;
case MSG_CLOSE:
DestroyMainWindow (hWnd);
PostQuitMessage (hWnd);
return 0;
}
return DefaultMainWinProc(hWnd, message, wParam, lParam);
}
static void InitCreateInfo (PMAINWINCREATE pCreateInfo)
{
pCreateInfo->dwStyle = WS_VISIBLE | WS_BORDER | WS_CAPTION;
pCreateInfo->dwExStyle = WS_EX_NONE;
pCreateInfo->spCaption = " HelloWorld " ;
pCreateInfo->hMenu = 0;
pCreateInfo->hCursor = GetSystemCursor (0);
pCreateInfo->hIcon = 0;
pCreateInfo->MainWindowProc = HelloWinProc;
pCreateInfo->lx = 0;
pCreateInfo->ty = 0;
pCreateInfo->rx = 320;
pCreateInfo->by = 240;
pCreateInfo->iBkColor = PIXEL_lightwhite;
pCreateInfo->dwAddData = 0;
pCreateInfo->hHosting = HWND_DESKTOP;
}
int MiniGUIMain (int args, const char* arg[])
{
MSG Msg;
MAINWINCREATE CreateInfo;
HWND hMainWnd;
#ifdef _LITE_VERSION
SetDesktopRect (0, 0, 800, 600);
#endif
InitCreateInfo (&CreateInfo);
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;
}
2. 配置编译选项。在Eclipse中,选择菜单“Project | Properties”,出现该工程的属性对话框。选择“C/C++ Build | settings”,继续选择“GCC C Linker | Libraries”,在Libraries (-l)中添加minigui和pthread两项。如下图。
最后,在configuration的位置,切换到Release模式,按照同样的方法配置。点击“OK”即可。
3. 编译并运行,会出现错误。
错误一:
NEWGAL: Does not find matched engine: qvfb.
Error in step 3: Can not get graphics engine information!
InitGUI failure when using /usr/local/etc/MiniGUI.cfg as cfg file.
No available video device.
解决:在终端中,进入qvfb文件夹,运行qvfb,出现对话框,设置SIZE为640*480,DEPTH为32位,重新运行程序。
错误二:重新运行后,出现如下错误
AttachSharedResource: Invalid argument
Error in step 7: Can not attach shared resource!
InitGUI failure when using /usr/local/etc/MiniGUI.cfg as cfg file.
解决:在终端中运行./mginit (位于mg-samples-1.3.1/src中)。会出现如下错误:
Error in step 2: There is already an instance of 'mginit'!
InitGUI failure when using /usr/local/etc/MiniGUI.cfg as cfg file.
此时,可以把/var/tmp中的内容
(mginit和minigui两个文件)删除,重新运行程序即可。
若出现如下提示:
LoadSharedResource: File exists
Error in step 7: Can not load shared resource!
InitGUI failure when using /usr/local/etc/MiniGUI.cfg as cfg file.
重启系统是其中一个解决问题的方法。
4. 运行程序,出现如下界面。