VMware {code} Community
DavidNg
Contributor
Contributor
Jump to solution

Sample Code to test VIX install

#include "vix.h"

#include <stdlib.h>

#include <stdio.h>

VixHandle hostHandle = VIX_API_VERSION;

VixHandle jobHandle = VIX_INVALID_HANDLE;
VixError err;
jobHandle = VixHost_Connect(VIX_API_VERSION,
VIX_SERVICEPROVIDER_VMWARE_SERVER,
host, // hostName
0, // hostPort
user, // userName
password, // password,
0, // options
VIX_INVALID_HANDLE, // propertyListHandle
NULL, // callbackProc
NULL); // clientData
err = VixJob_Wait(jobHandle,
VIX_PROPERTY_JOB_RESULT_HANDLE,
&hostHandle,
VIX_PROPERTY_NONE);
if (VIX_OK != err) {
// Handle the error...
Vix_ReleaseHandle(jobHandle);
VixHost_Disconnect(hostHandle);
}
printf("Connected to local host.\n");
when i compile the code
it nootify

/home/david/Development/workspace/VIXTest/Debug/../src/Connection.c:21: undefined reference to `VixHost_Connect'

/home/david/Development/workspace/VIXTest/Debug/../src/Connection.c:31: undefined reference to `VixJob_Wait'

/home/david/Development/workspace/VIXTest/Debug/../src/Connection.c:37: undefined reference to `Vix_ReleaseHandle'

/home/david/Development/workspace/VIXTest/Debug/../src/Connection.c:38: undefined reference to `VixHost_Disconnect'

I know that is mean the function is not defined.

but that should be defined as the api.......

Any can tell me how to solution the problem???

Thank

0 Kudos
1 Solution

Accepted Solutions
stanguturi
VMware Employee
VMware Employee
Jump to solution

When a user executes 'vmrun' command, vmrun checks for library location and loads all the necessary libraries in a specific order. The order in which the libraries are loaded is specified in a file named 'manifest.txt'. In your test scenario, since you are trying to connect to the remote end ESX server, the library location is /usr/lib/vmware-vix/Workstation-8.0.0-and-vSphere-5.0.0/64bit. The manifest.txt is located at /usr/lib/vmware-vix/Workstation-8.0.0-and-vSphere-5.0.0/64bit/manifest.txt.

To resolve the issue, you need to change the library load order little bit.

Open the manifest.txt file. The current order to load the libraries is as follows:

....

libgobject-2.0.so.0
libgthread-2.0.so.0

.....

Modify the order to load libgthread first before loading the libgobject. The new content should be as follows:

....

libgthread-2.0.so.0
libgobject-2.0.so.0

.....

Save the manifest.txt. Remember, all you need to do is to just change the order for gobject and gthread libraries. You don't need to make any other changes. Run 'vmrun' command. Let us know if it works.

-Thanks

Sankar.

View solution in original post

0 Kudos
7 Replies
DavidNg
Contributor
Contributor
Jump to solution

Addition Information

     I am using ubuntu 64but  .

     Before i write the porgram to try connection , I have try to use vmrun commend to connection remoterly esxi server

     but that notify Segmentation fault (core dumped) for me.

     I has try run vmrun on the gdb , the result is following:

(gdb) run

Starting program: /usr/bin/vmrun -T esx -h https://myEsXIServer/sdk -u name -p password list

[Thread debugging using libthread_db enabled]

Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

[New Thread 0x7ffff3485700 (LWP 7598)]

Program received signal SIGSEGV, Segmentation fault.

0x0000000000000000 in ?? ()

(gdb) where

#0  0x0000000000000000 in ?? ()
#1  0x00007ffff59770c1 in g_type_init_with_debug_flags ()
   from /usr/lib/vmware-vix/Workstation-8.0.0-and-vSphere-5.0.0/64bit/libgobject-2.0.so.0
#2  0x00007ffff44baf47 in gvmomi_init ()
   from /usr/lib/vmware-vix/Workstation-8.0.0-and-vSphere-5.0.0/64bit/libgvmomi.so.0
#3  0x00007ffff3d35f87 in VixInitializeGvmomi ()
   from /usr/lib/vmware-vix/Workstation-8.0.0-and-vSphere-5.0.0/64bit/libvix.so
#4  0x00007ffff3d36495 in VixVIM_InitializeHost ()
   from /usr/lib/vmware-vix/Workstation-8.0.0-and-vSphere-5.0.0/64bit/libvix.so
#5  0x00007ffff3caaeb8 in VixHost_ConnectEx ()
   from /usr/lib/vmware-vix/Workstation-8.0.0-and-vSphere-5.0.0/64bit/libvix.so
#6  0x00007ffff3cab21b in VixHost_Connect ()
   from /usr/lib/vmware-vix/Workstation-8.0.0-and-vSphere-5.0.0/64bit/libvix.so
#7  0x0000555555598963 in ?? ()
#8  0x0000555555569145 in main ()

It has any relationship for my issue?

0 Kudos
stanguturi
VMware Employee
VMware Employee
Jump to solution

When a user executes 'vmrun' command, vmrun checks for library location and loads all the necessary libraries in a specific order. The order in which the libraries are loaded is specified in a file named 'manifest.txt'. In your test scenario, since you are trying to connect to the remote end ESX server, the library location is /usr/lib/vmware-vix/Workstation-8.0.0-and-vSphere-5.0.0/64bit. The manifest.txt is located at /usr/lib/vmware-vix/Workstation-8.0.0-and-vSphere-5.0.0/64bit/manifest.txt.

To resolve the issue, you need to change the library load order little bit.

Open the manifest.txt file. The current order to load the libraries is as follows:

....

libgobject-2.0.so.0
libgthread-2.0.so.0

.....

Modify the order to load libgthread first before loading the libgobject. The new content should be as follows:

....

libgthread-2.0.so.0
libgobject-2.0.so.0

.....

Save the manifest.txt. Remember, all you need to do is to just change the order for gobject and gthread libraries. You don't need to make any other changes. Run 'vmrun' command. Let us know if it works.

-Thanks

Sankar.

0 Kudos
stanguturi
VMware Employee
VMware Employee
Jump to solution

Please check https://www.vmware.com/support/developer/vix-api/vix111_reference/intro.html#13_95619 for information about compiling programs in linux.

Sample command:

gcc -I/usr/include/vmware-vix vixapp.c -o vixapp -lvixAllProducts -ldl -lpthread

You need to specify -l option with the vix library name. Check http://bit.ly/vixapi for programming guide.



DavidNg
Contributor
Contributor
Jump to solution

I following your guide, but it not work,following is my compile code

gcc -O0 -g3 -Wall -lvixAllProducts -ldl -lpthread -I/usr/include/vmware-vix -MMD -MP -MF"src/Connection.d" -MT"src/Connection.d" -o "src/Connection.o" "../src/Connection.c"

Any idea for the issue???

0 Kudos
stanguturi
VMware Employee
VMware Employee
Jump to solution

> gcc -O0 -g3 -Wall -lvixAllProducts -ldl -lpthread -I/usr/include/vmware-vix -MMD -MP -MF"src/Connection.d" -MT"src/Connection.d" -o "src/Connection.o" "../src/Connection.c"

When you execute the above command, what error did you get?

0 Kudos
DavidNg
Contributor
Contributor
Jump to solution

Ok, now i fix the complier error, but i don't know what issue onced...

i has try

gcc -o "src/Connection.o" "../src/Connection.c"  -I/usr/include/vmware-vix

Maybe the issue that is onced by eclipse, i found only cannot compiler from the eclipse.

0 Kudos
JMills
Expert
Expert
Jump to solution

stanguturi wrote:

When a user executes 'vmrun' command, vmrun checks for library location and loads all the necessary libraries in a specific order. The order in which the libraries are loaded is specified in a file named 'manifest.txt'. In your test scenario, since you are trying to connect to the remote end ESX server, the library location is /usr/lib/vmware-vix/Workstation-8.0.0-and-vSphere-5.0.0/64bit. The manifest.txt is located at /usr/lib/vmware-vix/Workstation-8.0.0-and-vSphere-5.0.0/64bit/manifest.txt.

To resolve the issue, you need to change the library load order little bit.

Open the manifest.txt file. The current order to load the libraries is as follows:

....

libgobject-2.0.so.0
libgthread-2.0.so.0

.....

Modify the order to load libgthread first before loading the libgobject. The new content should be as follows:

....

libgthread-2.0.so.0
libgobject-2.0.so.0

.....

Save the manifest.txt. Remember, all you need to do is to just change the order for gobject and gthread libraries. You don't need to make any other changes. Run 'vmrun' command. Let us know if it works.

-Thanks

Sankar.

... -why- this needs to be done, on a > version 1.0 product is baffling.

-JMills, very curious to know what the VMware PR # is for this bug and how few digits is has. *sigh*

0 Kudos