[vbox-dev] MSCOM example
flint at flint-inc.ru
flint at flint-inc.ru
Fri Jul 15 02:37:18 PDT 2011
Hi.
You also need to link with the typelib implementation from ...\mscom\lib directory.
Hi Thanks for the help, but when I tried to compile the cpp program I got the following error:
E:\vbox\mscom\samples>g++ -Wall -I e:\vbox\mscom\include helloworld.cpp -o helloworld.exe
In file included from helloworld.cpp:1:
e:\vbox\mscom\include/VirtualBox.h:19: warning: ignoring #pragma warning
helloworld.cpp: In function 'int main(int, char**)':
helloworld.cpp:26: warning: format '%x' expects type 'unsigned int', but argument 2 has type 'HRESULT'
C:\Users\AKANTH~1.ADO\AppData\Local\Temp\ccYXyN0g.o:helloworld.cpp:(.text+0x1e): undefined reference to `_imp__CoInitialize at 4'
C:\Users\AKANTH~1.ADO\AppData\Local\Temp\ccYXyN0g.o:helloworld.cpp:(.text+0x32): undefined reference to `IID_IVirtualBox'
C:\Users\AKANTH~1.ADO\AppData\Local\Temp\ccYXyN0g.o:helloworld.cpp:(.text+0x49): undefined reference to `CLSID_VirtualBox'
C:\Users\AKANTH~1.ADO\AppData\Local\Temp\ccYXyN0g.o:helloworld.cpp:(.text+0x4e): undefined reference to `_imp__CoCreateInstance at 20'
C:\Users\AKANTH~1.ADO\AppData\Local\Temp\ccYXyN0g.o:helloworld.cpp:(.text+0x74): undefined reference to `_imp__CoUninitialize at 0'
collect2: ld returned 1 exit status
It seems that the colored red are related to COM/RPC. And colored blue are realted to VBOX
For ref: the following is the cpp I'm using
-----------------------------------------------------------------------------------------------------------------------------------------
#include "VirtualBox.h"
#include <stdio.h>
int main(int argc, char *argv[])
{
HRESULT rc;
IVirtualBox *virtualBox;
do
{
/* Initialize the COM subsystem. */
CoInitialize(NULL);
/* Instantiate the VirtualBox root object. */
rc = CoCreateInstance(CLSID_VirtualBox, /* the VirtualBox base object */
NULL, /* no aggregation */
CLSCTX_LOCAL_SERVER, /* the object lives in a server process on this machine */
IID_IVirtualBox, /* IID of the interface */
(void**)&virtualBox);
if (!SUCCEEDED(rc))
{
printf("Error creating VirtualBox instance! rc = 0x%x\n", rc);
break;
}
} while (0);
CoUninitialize();
return 0;
printf("Hello, world\n");
return 0;
}
-------------------------------------------------------------------------------------------------------------------------------------------------
Thanks
Arun
On Thu, Jul 14, 2011 at 10:34 PM, Klaus Espenlaub <klaus.espenlaub at oracle.com> wrote:
On 14.07.2011 13:07, aru wrote:
Hi,
Some one please send me a mscom example to start VM or access VM.
http://www.virtualbox.org/browser/trunk/src/VBox/Main/testcase/tstVBoxAPIWin.cpp
Usually it's worth having a peek at the VirtualBox sources - if everything else fails there's VBoxManage, which uses pretty much all interfaces and methods.
There are only very few places in VirtualBox where it's an option to take shortcuts, so generally all the VirtualBox code goes through the API as well.
Klaus
Thanks
Arun
--
Bye. With best regards,
Konstantin Vlasov.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.virtualbox.org/pipermail/vbox-dev/attachments/20110715/6da9806e/attachment-0001.html
More information about the vbox-dev
mailing list