LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-21-2008, 06:11 AM   #1
chega03
LQ Newbie
 
Registered: Aug 2008
Posts: 5

Rep: Reputation: 0
Red face Problem with rpmdbOpen function


I have created the binary for the following program in RHEL5 i386 (32 bit) OS.

#include <iostream>
#include <rpm/rpmlib.h>
#include <rpm/rpmdb.h>

static rpmdb rpmDB;

int main(void)
{

rpmReadConfigFiles(NULL, NULL);
if(rpmdbOpen("", &rpmDB, RD_ONLY, 0644) != 0)
{
std::cout("not Working fine");
}
else
{
std::cout("working fine");
rpmdbClose(rpmDB);
}
return 0;
}

I used the following command to create the binary.

#gcc -o rpmtest rpmtest.cpp -L/usr/lib/rpm -lrpm -lrpmio -lrpmdb

I have copied the binary (rpmtest) to RHEL5 x86_64 (64 bit) machine.

I executed the rpmtest binary using following command.
#./rpmtest
It works fine.

After that I executed the following command.
rpm -q rpm
The problem is here. It's giving the following errors.

rpmdb: program version 4.3 does not match environment version.
error: db4 error (30974) from dbenv -> open: DB_VERSION_MISMATCH: Database environment version mismatch.
Error: can not open packages index using db3 (30974).
error: can not open packages database in /var/lib/rpm
package rpm is not installed.

So I googled more and found workaround that removing the rpm temp files and --rebuilddb will help in this. But it did not help me.

After deleting the temp (var/lib/rpm/__db*) files, I was able to run the rpm query(rpm -q rpm) without errors and the temp files created again. But this time I was not able run my program. It was giving above mentioned errors.

If the temp files created while running the program, I am not able to run the rpm commands. If the temp files created while running the rpm command, I am not able to run my program.

Could you help me in this?
 
Old 08-21-2008, 06:28 AM   #2
stuart_cherrington
Member
 
Registered: Aug 2008
Location: Get back in your Cube Unix Boy!
Distribution: rh5, oel5, debian etch, solaris
Posts: 228

Rep: Reputation: 36
Perhaps I'm missing something but you took a 32-bit compiled app and put it on a 64-bit machine and wonder why it no longer works???

Try compiling the app on thr 64-bit machine and see what happens.

Stuart.
 
Old 08-21-2008, 07:06 AM   #3
chega03
LQ Newbie
 
Registered: Aug 2008
Posts: 5

Original Poster
Rep: Reputation: 0
If i compiled it in 64 bit machine, it's working fine.

But my requirement is that I have to compile my application in 32 bit only, becase of some other dependencies. The above code is part of my application. But application is failing with the above mentioned errors, when it's trying to call the rpmdbOpen function.
 
Old 08-22-2008, 03:09 AM   #4
stuart_cherrington
Member
 
Registered: Aug 2008
Location: Get back in your Cube Unix Boy!
Distribution: rh5, oel5, debian etch, solaris
Posts: 228

Rep: Reputation: 36
Hi,

There 'might' be a compilation switch which tells the app it should be capable of running on 32 & 64-bit arch.

It's also possible that moving a 32-bit to a 64-bit system that the library files are all screwed up. Have you checked the app using ldd?

Stu.
 
Old 08-22-2008, 05:29 AM   #5
chega03
LQ Newbie
 
Registered: Aug 2008
Posts: 5

Original Poster
Rep: Reputation: 0
I checked with the ldd.

For 32 bit compilation, all the rpm libraries (.so) files linked to the /usr/lib folder. But 64 bit compilation, all the rpm libraris (.so) files linked to the /usr/lib64 folder.

chendra.
 
Old 08-22-2008, 08:35 AM   #6
stuart_cherrington
Member
 
Registered: Aug 2008
Location: Get back in your Cube Unix Boy!
Distribution: rh5, oel5, debian etch, solaris
Posts: 228

Rep: Reputation: 36
Thats to be expected, but you said you are taking your 32-bit app and putting it on a 64-bit machine, when you do this and run ldd, what do you get?
 
Old 08-27-2008, 01:01 AM   #7
chega03
LQ Newbie
 
Registered: Aug 2008
Posts: 5

Original Poster
Rep: Reputation: 0
Sorry for the delay in repsonse. I was out of station from the last 5 days.

If I run the ldd onn 32 bit excutable, I am getting the following results:

[root@kumvi10-w2k3-1 Test]# ldd rpmtest32-2
linux-gate.so.1 => (0xffffe000)
librpm-4.4.so => /usr/lib/librpm-4.4.so (0xf7f56000)
librpmio-4.4.so => /usr/lib/librpmio-4.4.so (0xf7ec0000)
librpmdb-4.4.so => /usr/lib/librpmdb-4.4.so (0xf7dab000)
libc.so.6 => /lib/libc.so.6 (0x4161e000)
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x4204d000)
libpopt.so.0 => /usr/lib/libpopt.so.0 (0x4214c000)
libselinux.so.1 => /lib/libselinux.so.1 (0x42623000)
libbeecrypt.so.6 => /usr/lib/libbeecrypt.so.6 (0xf7d6c000)
libm.so.6 => /lib/libm.so.6 (0x41776000)
libdl.so.2 => /lib/libdl.so.2 (0x4188b000)
libz.so.1 => /usr/lib/libz.so.1 (0x41eec000)
librt.so.1 => /lib/librt.so.1 (0x41880000)
libpthread.so.0 => /lib/libpthread.so.0 (0x4175d000)
libbz2.so.1 => /usr/lib/libbz2.so.1 (0xf7d5a000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x4213a000)
libsqlite3.so.0 => /usr/lib/libsqlite3.so.0 (0xf7cfb000)
libelf.so.1 => /usr/lib/libelf.so.1 (0xf7ce5000)
/lib/ld-linux.so.2 (0x41601000)
libsepol.so.1 => /lib/libsepol.so.1 (0x423a7000)
[root@kumvi10-w2k3-1 Test]#
 
Old 09-29-2008, 03:42 AM   #8
chega03
LQ Newbie
 
Registered: Aug 2008
Posts: 5

Original Poster
Rep: Reputation: 0
I compiled my program in 64 bit OS with -m32 option. Even I am getting same problem.
Please any body help me in this?
 
  


Reply

Tags
rhel5



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Compilation issue when Function is parameter in function call on LINUX sa20358 Linux - Software 2 07-24-2008 10:19 PM
strlen() function problem in C++ sajith Programming 9 01-16-2006 09:14 PM
HI, I have a problem with a function in C grupoapunte Programming 3 06-13-2005 04:53 AM
A main can be changed by a function local without passing anything to the function? ananthbv Programming 10 05-04-2004 01:31 PM
Perl exec function in linux (and system-function) nazula Programming 1 04-19-2004 12:21 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:29 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration