title: can anyone create a simple libvirt program which just starts the domain
body: <p>virConnectCreateXML doest seem to work for me
  i created the following program and compiled it but it seems some linking problems or some kind of problem so i get these error</p>
  
  <pre><code>me.cpp: In function ‘int main(int, char**)’:
  me.cpp:21:45: error: ‘virConnectCreateXML’ was not declared in this scope
   dom = virConnectCreateXML(conn, xmlconfig, 0);
                                               ^
  me.cpp:24:5: error: return-statement with no value, in function returning ‘int’ [-fpermissive]
       return;
       ^
  me.cpp:26:57: error: ‘virDomainName’ was not declared in this scope
   fprintf(stderr, "Guest %s has booted", virDomainName(dom));
                                                       ^
  </code></pre>
  
  <blockquote>
    <p>Program:</p>
  </blockquote>
  
  <pre><code>    /* example ex9.c */
      /* compile with: gcc -g -Wall ex9.c -o ex9 -lvirt */
  
     #include &lt;stdio.h&gt;
    #include &lt;stdlib.h&gt;
    #include &lt;libvirt/libvirt.h&gt;
  
          int main(int argc,char *argv[]){virConnectPtr conn;
          char *host;
          conn = virConnectOpen("qemu:///system");
          if (conn == NULL) {
              fprintf(stderr, "Failed to open connection to qemu:///system\n");
              return 1;
          }         
          virDomainPtr dom;
         const char *xmlconfig = "&lt;domain type='kvm'&gt;
         &lt;name&gt;win7&lt;/name&gt;
         &lt;uuid&gt;3666e50e-c616-42eb-aec8-b7fb1ad5f8f9&lt;/uuid&gt;
         &lt;memory unit='KiB'&gt;2072576&lt;/memory&gt;
         &lt;currentMemory unit='KiB'&gt;2072576&lt;/currentMemory&gt;
         &lt;vcpu placement='static'&gt;2&lt;/vcpu&gt;
         &lt;os&gt;
           &lt;type arch='x86_64' machine='pc-i440fx-2.5'&gt;hvm&lt;/type&gt;
           &lt;boot dev='hd'/&gt;
         &lt;/os&gt;
         &lt;features&gt;
           &lt;acpi/&gt;
           &lt;apic/&gt;
           &lt;hyperv&gt;
             &lt;relaxed state='on'/&gt;
             &lt;vapic state='on'/&gt;
             &lt;spinlocks state='on' retries='8191'/&gt;
           &lt;/hyperv&gt;
           &lt;vmport state='off'/&gt;
         &lt;/features&gt;
         &lt;cpu mode='host-model'&gt;
           &lt;model fallback='allow'/&gt;
         &lt;/cpu&gt;
         &lt;clock offset='localtime'&gt;
           &lt;timer name='rtc' tickpolicy='catchup'/&gt;
           &lt;timer name='pit' tickpolicy='delay'/&gt;
           &lt;timer name='hpet' present='no'/&gt;
           &lt;timer name='hypervclock' present='yes'/&gt;
         &lt;/clock&gt;
         &lt;on_poweroff&gt;destroy&lt;/on_poweroff&gt;
         &lt;on_reboot&gt;restart&lt;/on_reboot&gt;
         &lt;on_crash&gt;restart&lt;/on_crash&gt;
         &lt;pm&gt;
           &lt;suspend-to-mem enabled='no'/&gt;
            &lt;suspend-to-disk enabled='no'/&gt;
        &lt;/pm&gt;
        &lt;devices&gt;
          &lt;emulator&gt;/usr/sbin/qemu-system-x86_64&lt;/emulator&gt;
          &lt;disk type='file' device='disk'&gt;
            &lt;driver name='qemu' type='qcow2'/&gt;
            &lt;source file='/var/lib/libvirt/images/win7.qcow2'/&gt;
            &lt;target dev='hda' bus='ide'/&gt;
            &lt;address type='drive' controller='0' bus='0' target='0' unit='0'/&gt;
          &lt;/disk&gt;
          &lt;disk type='file' device='cdrom'&gt;
            &lt;driver name='qemu' type='raw'/&gt;
            &lt;source file='/home/dravigon/win7.iso'/&gt;
            &lt;target dev='hdb' bus='ide'/&gt;
            &lt;readonly/&gt;
            &lt;address type='drive' controller='0' bus='0' target='0' unit='1'/&gt;
          &lt;/disk&gt;
          &lt;controller type='usb' index='0' model='ich9-ehci1'&gt;
            &lt;address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x7'/&gt;
          &lt;/controller&gt;
          &lt;controller type='usb' index='0' model='ich9-uhci1'&gt;
            &lt;master startport='0'/&gt;
            &lt;address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0' multifunction='on'/&gt;
          &lt;/controller&gt;
          &lt;controller type='usb' index='0' model='ich9-uhci2'&gt;
            &lt;master startport='2'/&gt;
            &lt;address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x1'/&gt;
          &lt;/controller&gt;
          &lt;controller type='usb' index='0' model='ich9-uhci3'&gt;
            &lt;master startport='4'/&gt;
            &lt;address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x2'/&gt;
          &lt;/controller&gt;
          &lt;controller type='pci' index='0' model='pci-root'/&gt;
          &lt;controller type='ide' index='0'&gt;
            &lt;address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/&gt;
          &lt;/controller&gt;
          &lt;controller type='virtio-serial' index='0'&gt;
            &lt;address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/&gt;
          &lt;/controller&gt;
          &lt;interface type='direct'&gt;
            &lt;mac address='52:54:00:56:27:95'/&gt;
            &lt;source dev='enp3s0' mode='bridge'/&gt;
            &lt;model type='rtl8139'/&gt;
            &lt;address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/&gt;
          &lt;/interface&gt;
          &lt;serial type='pty'&gt;
            &lt;target port='0'/&gt;
          &lt;/serial&gt;
          &lt;console type='pty'&gt;
            &lt;target type='serial' port='0'/&gt;
          &lt;/console&gt;
          &lt;channel type='spicevmc'&gt;
            &lt;target type='virtio' name='com.redhat.spice.0'/&gt;
            &lt;address type='virtio-serial' controller='0' bus='0' port='1'/&gt;
          &lt;/channel&gt;
          &lt;input type='tablet' bus='usb'/&gt;
          &lt;input type='mouse' bus='ps2'/&gt;
          &lt;input type='keyboard' bus='ps2'/&gt;
          &lt;graphics type='spice' autoport='yes'&gt;
            &lt;image compression='off'/&gt;
          &lt;/graphics&gt;
          &lt;sound model='ich6'&gt;
            &lt;address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/&gt;
          &lt;/sound&gt;
          &lt;video&gt;
            &lt;model type='vga' vram='16384' heads='1'/&gt;
            &lt;address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/&gt;
          &lt;/video&gt;
          &lt;redirdev bus='usb' type='spicevmc'&gt;
          &lt;/redirdev&gt;
          &lt;redirdev bus='usb' type='spicevmc'&gt;
          &lt;/redirdev&gt;
          &lt;memballoon model='virtio'&gt;
            &lt;address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/&gt;
          &lt;/memballoon&gt;
        &lt;/devices&gt;
      &lt;/domain&gt;";
      dom = virConnectCreateXML(conn, xmlconfig, 0);
      if (!dom) {
          fprintf(stderr, "Domain creation failed");
          return;
      }
      fprintf(stderr, "Guest %s has booted", virDomainName(dom));
      virDomainFree(dom);
  
  
          virConnectClose(conn);
          return 0;
      }
  </code></pre>
  
  <blockquote>
    <p>help is thanked in advance</p>
  </blockquote>