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@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@20'
C:\Users\AKANTH~1.ADO\AppData\Local\Temp\ccYXyN0g.o:helloworld.cpp:(.text+0x74):
undefined reference to `_imp__CoUninitialize@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 <[email protected]>
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._______________________________________________
vbox-dev mailing list
[email protected]
http://vbox.innotek.de/mailman/listinfo/vbox-dev