As you know from previous post, I talked about the Virtual Disk Development Kit (VDDK) whihe is a collection of C libraries, code samples,
utilities, and documentation to help you create or access
VMware virtual disk storage. After downloading them on my ubuntu box, I gave the sample program a try to see how the thing works before I start modifiying it for my own use. Below are my steps for fixing/patching the sample program that uses the VDDK libraries.
Fixing VDDK sample program and make sure it compiles correctly
1. Install VDDK 1.1 from http://www.vmware.com/support/developer/vddk/
2. Find the sample source in /usr/share/doc/vmware-vix-disklib/sample
3. You should find the following:
root@*****:/data/vmwareproject/CODE/sampleprogram# ll /usr/share/doc/vmware-vix-disklib/sample
total 48
-r--r--r-- 1 root root 158 2009-12-04 08:02 Makefile
-r--r--r-- 1 root root 41718 2009-12-04 08:02 vixDiskLibSample.cpp
root@*****:/data/vmwareproject/CODE/sampleprogram#
4. Make sure you edit your /etc/ld.so.conf file, here is what is should look like:
root@stalker:/data/vmwareproject/CODE/sampleprogram# more /etc/ld.so.conf
include /etc/ld.so.conf.d/*.conf
include /usr/lib/vmware-vix-disklib/lib32
root@stalker:/data/vmwareproject/CODE/sampleprogram#
5. After editing the /etc/ld.so.conf file, run "ldconfig"
6. cp -r /usr/share/doc/vmware-vix-disklib/sample to /tmp
7. cd /tmp
8. run "make"
9.
There is a problem with the vixDiskLibSample.cpp file and does not
contain all the header files...here is the error you should get...
10.. Run make
Results:
root@stalker:/data/vmwareproject/CODE/sampleprogram# make
g++ -o vix-disklib-sample `pkg-config --cflags --libs vix-disklib` vixDiskLibSample.cpp
vixDiskLibSample.cpp: In function 'int PrintUsage()':
vixDiskLibSample.cpp:506: error: 'printf' was not declared in this scope
vixDiskLibSample.cpp: In function 'int main(int, char**)':
vixDiskLibSample.cpp:587: error: 'strdup' was not declared in this scope
vixDiskLibSample.cpp:606: error: 'printf' was not declared in this scope
vixDiskLibSample.cpp: In function 'int ParseArguments(int, char**)':
vixDiskLibSample.cpp:674: error: 'strcmp' was not declared in this scope
vixDiskLibSample.cpp: In function 'void DoFill()':
vixDiskLibSample.cpp:971: error: 'memset' was not declared in this scope
vixDiskLibSample.cpp: In function 'void DoDumpMetadata()':
vixDiskLibSample.cpp:1092: error: 'strlen' was not declared in this scope
vixDiskLibSample.cpp: In function 'void DumpBytes(const unsigned char*, size_t, int)':
vixDiskLibSample.cpp:1184: error: 'printf' was not declared in this scope
vixDiskLibSample.cpp:1199: error: 'printf' was not declared in this scope
make: *** [vix-disklib-sample] Error 1
11. To fix this, create a patch and execute the patch on your file. The steps below outline this for you.
root@******:/data/vmwareproject/CODE/sampleprogram# more create_patch_file.txt
Script started on Fri 04 Dec 2009 10:21:27 AM EST
root@******:/data/vmwareproject/CODE/sampleprogram#
diff -uN vixDiskLibSample.cpp vixDiskLibSample_new.cpp >
vixDiskLibSample.patch
root@@******:/:/data/vmwareproject/CODE/sampleprogram# more vixDiskLibSample.patch
--- vixDiskLibSample.cpp 2009-12-04 10:17:49.187001708 -0500
+++ vixDiskLibSample_new.cpp 2009-12-04 10:18:28.086448746 -0500
@@ -23,6 +23,9 @@
#include <string>
#include <vector>
#include <stdexcept>
+// JD Durick added this in to account for printf and memset function calls - 12/04/09
+#include <stdio.h>
+#include <string.h>
#include "vixDiskLib.h"
root@@******:/:/data/vmwareproject/CODE/sampleprogram# ll
total 104
-rw-r--r-- 1 root root 361 2009-12-04 10:21 vixDiskLibSample.patch
-rw-r--r-- 1 root root 0 2009-12-04 10:21 create_patch_file.txt
-r--r--r-- 1 root root 41843 2009-12-04 10:18 vixDiskLibSample_new.cpp
-r--r--r-- 1 root root 41718 2009-12-04 10:17 vixDiskLibSample.cpp
drwxr-xr-x 2 root root 4096 2009-12-04 10:09 new/
drwxr-xr-x 2 root root 4096 2009-12-04 10:09 orig/
-r--r--r-- 1 root root 158 2009-12-04 10:00 Makefile
root@@******:/:/data/vmwareproject/CODE/sampleprogram# patch vixDiskLibSample.cpp < vi
xDiskLibSample.patch
patching file vixDiskLibSample.cpp
You have new mail in /var/mail/root
root@@******:/:/data/vmwareproject/CODE/sampleprogram# make
g++ -o vix-disklib-sample `pkg-config --cflags --libs vix-disklib` vixDiskLibSample.cpp
root@@******:/:/data/vmwareproject/CODE/sampleprogram# exit
exit
Script done on Fri 04 Dec 2009 10:24:07 AM EST
root@@******:/:/data/vmwareproject/CODE/sampleprogram#
At this point, everything should work fine.
Recent Comments