this is the whole code:
#include <fcntl.h>
#include <rpm/rpmlib.h>
int main(int argc, char ** argv) {
rpmdb * pdb;
//rpmReadConfigFiles(NULL, NULL, NULL, 0); deprecated
// int rpmReadConfigFiles(/*@null@*/ const char * file, /*@null@*/ const char * target)
rpmReadConfigFiles(NULL, NULL);
printf("Config files read\n");
int dbStatus = rpmdbOpen("", &pdb, O_RDONLY, 0644);
if (dbStatus) {
// error opening
printf("Error on opening RPM Database: (%d) %s\n", rpmErrorCode(), rpmErrorString());
} else {
printf("RPM Database opened!\n");
}
/* will try to get all the packages installed in the DB */
int offset;
offset = rpmdbFirstRecNum(pdb);
Header rpmHeader;
while (offset) {
rpmHeader = rpmdbGetRecord(pdb, offset);
offset = rpmdbGetNextRecNum(pdb, offset);
}
rpmdbClose(pdb);
printf("RPM Database closed!\n");
}
This is the output when compiling:
[antoranz@galileo src]$ gcc rpm4.c -o rpm4 -lrpm
rpm4.c: In function `main':
rpm4.c:31: warning: assignment makes pointer from integer without a cast
/home/antoranz/tmp/ccBAY42k.o(.text+0x91): In function `main':
: undefined reference to `rpmdbFirstRecNum'
/home/antoranz/tmp/ccBAY42k.o(.text+0xad): In function `main':
: undefined reference to `rpmdbGetRecord'
/home/antoranz/tmp/ccBAY42k.o(.text+0xc1): In function `main':
: undefined reference to `rpmdbGetNextRecNum'
collect2: ld returned 1 exit status
PS I justified the source, but it's not showing up.
PS2 Come on, guys! Help me! :'(