[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [lvm-devel] error using the lvm library in C++



On Mon, 2010-06-21 at 16:40 -0700, ben scott wrote:
> I am still running into trouble using the lvm library. Following the example 
> in lvm2app.h I tried:
> 
> 
>     dm_list *vgnames;
>     lvm_str_list *strl;
> 
>     vgnames = lvm_list_vg_names( lvm_pointer );
> 
>     dm_list_iterate_items(strl, vgnames) {
>         qDebug() << QString( strl->str );
>     }
> 
> I get this error:
> 
> masterlist.cpp:83: error: ‘typeof’ was not declared in this scope
> masterlist.cpp:83: error: expected primary-expression before ‘)’ token
> masterlist.cpp:83: error: expected primary-expression before ‘)’ token
> masterlist.cpp:83: error: expected ‘)’ before numeric constant
> masterlist.cpp:83: error: expected ‘)’ before ‘;’ token
> etc...
> 
> Is it coming from the file libdevmapper.h?
> 

Can you post your code?

Attached is a sample C++ hack that works for me with upstream lvm + dm
CVS.  Make sure you are pointing at the right header files and linking
to the correct libraries.


//
// Built on Fedora 10, upstream lvm2 git, rooted at test/api,
// with the following command:
// # g++ -I../../liblvm -I../../libdm /tmp/masterlist.cpp -llvm2app -ldevmapper -L../../liblvm -L../../libdm
// # export LD_LIBRARY_PATH=../../liblvm:../../libdm
// # ./a.out 
// Library version: 2.02.68(2)-cvs (2010-06-07)
// VG names:
// VolGroup00
// vgtest
//
#include "lvm2app.h"
#include <iostream>
using namespace std;

main()
{
	struct dm_list *list;
	struct lvm_str_list *strl;
	lvm_t libh;

	libh = lvm_init(NULL);
	if (!libh) {
		cout << "Unable to open lvm library instance\n";
		exit;
	}

	cout << "Library version: " << lvm_library_get_version() << "\n";

	list = lvm_list_vg_names(libh);
	printf("VG names:\n");
	dm_list_iterate_items(strl, list) {
		cout << strl->str << "\n";
	}
	lvm_quit(libh);
}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]