Showing posts with label win32. Show all posts
Showing posts with label win32. Show all posts

31 December 2010

Virtual machine as Windows service

A follow up from
Synology as Web Gateway (part one)
Once you have a virtual server up and running in Virtualbox, the question of starting it automatically in the background may be solved by the use of ServiceMan.

ServiceMan is a small win32 app i wrote as Virtualbox (3.xx) is not natively service-able. It features execution of a set of cmd lines, and on-the-fly environment variables setting. Both are needed to start a virtualbox machine (plus is able to launch many apps in one go, and support internal variables).

You need to type a cmd line to register ServiceMan as a service (it will be executed at host start).
ServiceMan -i [ServiceName]

ServiceMan will get all information from a old-fashioned ServiceMan.ini located in the executable directory. Here is mine in this case:



[General]
;this shows in services control panel
Description=ServiceMan (a virtual machine using virtualbox)

;
;From now, each section is considered to be triggered sequentially
;at host startup and shutdown
;
;We're launching a virtual server in this one
[VirtualUbuntu]

;
;Aliases : allow to define internal variables you'll be reusing later in config file
;here i'm using a portable edition of virtualbox, and need to set some paths
;
Aliases=VboxUserHome=D:\Machines\Portable-VirtualBox\data\.VirtualBox;VboxDir=D:\Machines\Portable-VirtualBox\app64

;A more conventional virtual box installation should use this
;Aliases=VboxUserHome=C:\Documents and Settings\[User Name]\.VirtualBox;VboxDir=C:\Program Files\Oracle\VirtualBox

;
;Environment variables to add to your configuration when executing cmd lines
;
EnvVars=VBOX_USER_HOME=%VboxUserHome%;VBOX_INSTALL_PATH=%VBoxDir%

;
;Working directory
;
WorkingDir=%VboxDir%

;
;we can redefine envvars for that particular service event
;with StartupEnvVars=VBOX_USER_HOME=%VboxUserHome%;VBOX_INSTALL_PATH=%VBoxDir%
;following are the command executed sequentially. It waits 1000s by default
;
;doing this should force vboxsvc to read new env vars
StartupCmd1="%VboxDir%\vboxsvc.exe" /reregserver
;it's possible to define a pause between commands (default is 1000 ms)
;StartupPause1=1000
StartupCmd2="%VboxDir%\vboxmanage.exe" list systemproperties
StartupCmd3="%VboxDir%\vboxmanage.exe" list vms
StartupCmd4="%VboxDir%\vboxheadless.exe" -startvm VirtualLinux

;
;and shutdown event: again, if we need to redefine things...
;ShutdownEnvVars=VBOX_USER_HOME=%VboxUserHome%;VBOX_INSTALL_PATH=%VBoxDir%
;ShutdownWorkingDir=%VboxDir%
;
ShutdownCmd1="%VboxDir%\vboxmanage.exe" controlvm VirtualLinux savestate

;
;you may have more than one app to launch as a service: open another section
;[AnotherSetOfCommand]
;etc, etc
;



If you need to start and stop for testing, use the service control panel or the cmd line -s / -k option.

Note that it generates a session exec log in ServiceMan directory (which, therefore, should be writable).

Download ServiceMan

30 July 2009

Clutter 1.0.0: Win32/MinGW (updated)

Personal Hack for a win32 build of clutter-1.0.0 libraries.
  • static libraries,
  • interactive.exe and the whole dll package (glib, pango, etc),
  • and a configuration package (prebuild.zip)
In there.
Basically all you need is:

Get Code::Blocks/QtCreator whatever (but a Mingw flavor): http://www.codeblocks.org/downloads/5

Get Clutter-1.0.0, and unzip-it somewhere on your hdd: http://www.clutter-project.org/sources/clutter/1.0/
Get GTK dependencies from http://www.gtk.org/download-windows.html (binaries+dev packages): pango, cairo, glib, gtk+
Get some other Mingw port from http://sourceforge.net/project/showfiles.php?group_id=7382 :
gettext, libiconv

I put all those libraries side by side with clutter-1.0.0.

Concerning mingw, it's likely that the package delivered with cb/qtcreator is outdated:
Get latest mingw API For MS Windows (http://sourceforge.net/projects/mingw/files/ , dev version) and unzip it into your mingw directory
Get latest glext.h (http://www.opengl.org/registry/api/glext.h), to update your probably old \mingw\include\GL\GLext.h.

Now some autoconf stuff:

Get And Unzip prebuild.zip (http://alimbourg.free.fr/clutter-1.0.0) into clutter-1.0.0/build/
It will create some qtcreator\ dir as it's my primary develoment platform, but rename it at will.
The configuration package uses perl (i'm using tinyperl, included in archive) to autoconfigure clutter build, generate marshaling info and glib-enum-typing header files. It makes it ready to compile.
Edit configure.pl to match your installation directories as it needs GLIB for some prebuild steps.
Then, execute configure.bat.

(Finally, it tweaks some qtcreator .pro project files to list every needed source files all the content from clutter\, clutter\COGL, clutter\Pango, clutter\json, clutter\win32: this, of course, has to be done 'by hand' for the other tools)

It's now ready to compile...

27 May 2009

QtCreator Debug Helper...

QtCreator (1.1 for now) is great tool to work with...

The whole Qt thing is, too.

I'm sharing some experience with the beast.

If you need some relevant debug infos concerning the Qt class guts, you need to instruct gdb on how to print them.

It's done via a 'debugging helper': some dll/plugin loaded by gdb on startup.

On my machine they didnt work without a rebuild after each Qt SDK every integration:

  • go to Tools->Options...->Qt4->Qt Versions,
  • check the active Qt SDK, and its path (QT_PATH).
  • *remove* the whole *QT_PATH/qtc-debugging-helper* directory via explorer
  • back to the Options Pane, select the active SDK, and press *Rebuild*
  • go to Options->Debugger->Debugging Helper, check 'Use debugging helper', uncheck 'Use debugging helper from custom location'
  • next time you debug your qt app, you should get some '43 custom... loaded' from gdb

05 March 2009

Clutter 0.9 (CodeBlocks/MinGW/Win32 build)

Do you know Clutter ?

"Clutter is an open source software library for creating fast, visually rich and animated graphical user interfaces. "

http://www.clutter-project.org/

Great Project. Really.

A bit too much intricated with gnome/gtk, not really win32 native ;), not so much pictures to display about, but... Nice and Smart code: really promising architecture.
Wanted to figure this on win32, as i'd like to create some click n play frontends for my htpc...
Good news: it's buildable on Windows/CodeBlocks (mingw) with a bit of luck and elbow grease :)

Here is a recipe:

Get Code::Blocks (Mingw flavor): http://www.codeblocks.org/downloads/5

Get Clutter0.9, and unzip-it somewhere on your hdd.

Get GTK dependencies from http://www.gtk.org/download-windows.html (binaries+dev packages): pango, cairo, glib, gtk+

Get some Mingw port from http://sourceforge.net/project/showfiles.php?group_id=7382 :
gettext, libiconv

I put all those libraries side by side with clutter-0.9.

Now some OpenGL trickeries: this is the main problem when compiling on win32 as internal OGL support is only up to 1.2, and clutter is more 1.4. So, as usual, we'll play with extensions and runtime function pointers retrieval.
Note that clutter/cogl is dealing with >1.4 extensions as well: mine is a hack concerning 'some functions 'between' OGL 1.2 and 1.4... So:

Get latest glext.h, to update your probably old \codeblocks\mingw\include\GL\GLext.h.

Create clutter-0.9.0\build\cb directory ('cb' stands for code::blocks, took the directory location from the old msvc_2k5 port).

Unzip this patch/project archive file in clutter-0.9.0\build\cb.

Run cb/prebuild.bat: it will copy some config files, create the actor-marshall.h/.c, and replace some files with a patched version (have a look into prebuild.bat as it probably wont fit with your directory configuration).

Now open code::blocks and cb\clutter.workspace: you should be ready to compile and link both clutter and interactive_d projects.

To execute interactive_d.exe: you need a bunch of dll in the running directory as the content of clutter-0.9\test\data. This is my complete build folder.

interactive_d.exe needs the name of the test to be ran, as a parameter, such as 'interactive_d.exe test-clutter-cairo-flowers'. Here is a two rows list of possible params:


test-actor-clone test-actors
test-animation test-behave
test-binding-pool test-clip
test-clutter-cairo-flowers test-cogl-multitexture
test-cogl-offscreen test-cogl-primitives
test-cogl-tex-convert test-cogl-tex-foreign
test-cogl-tex-getset test-cogl-tex-polygon
test-cogl-tex-tile test-depth
test-easing test-events
test-fbo test-fullscreen
test-grab test-layout
test-main test-model
test-multistage test-offscreen
test-paint-wrapper test-perspective
test-pixmap test-project
test-random-text test-rotate
test-scale test-score
test-script test-shader
test-stage-read-pixels test-text-field
test-text test-texture-quality
test-textures test-threads
test-unproject test-viewport

That's it for Clutter 0.9 :)
I'm going to dive more and more into it next days... And will publish my investigations in there. Stay tuned ?