LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 01-02-2007, 07:43 AM   #1
tatchan
LQ Newbie
 
Registered: Dec 2006
Posts: 4

Rep: Reputation: 0
Shared library problem - really need your help!


Hi all,
First, I am sorry for double post in this forum, but I just want to express my problem in more detail so that somebody can help.

I've got a problem that I would really appreciate your help. I spent last week trying to build my project on SUSE Linux but did not succeed. I built it with the IDEs : Kdevelop and Eclipse - using "managed/auto make" C++ project. The only thing outside the project that I have to link is the XML parser shared library libxerces-c.so. The Build was ok (compiled and linked) but the Run failed. It was not able to enter even the first line of code inside function main.

It seems to me that the shared library was well recognized at the Build time but was unable to locate/load at run time.
I already google for the issue and asked on some forums and all I got is some think like: It might be a bug of linux kernel 2.6.18 or gdb 6.5 or both. That's why I tried to build the program on several version of SUSE (version 9.3; 10.0; 10.1; 10.2 - which have the linux kernels from 2.6.13 to 2.6.19 and gdb from 6.3 to 6.5 or so) but was not able to solve the problem.
I also tried to build the shared library manually instead of using existing one provided with SUSE. Building the library was ok but the problem remains.

Running the program on debug mode showed the following errors (the debug stopped before going inside the main):

in Eclipse:
....
A syntax error in expression, near `-console'.
Failed to read a valid object file image from memory.
Stopped due to shared library event
[Thread debugging using libthread_db enabled]
warning: Lowest section in /usr/lib/libicudata.so.34 is .hash at 000000b4
[New Thread -1225189680 (LWP 434]
Stopped due to shared library event
[Switching to Thread -1225189680 (LWP 434]
...

in Kdevelop:
...
(gdb) break /home/son/work_space/nicemona03/src/nicemona.cpp:41
Breakpoint 1 at 0x8078a20: file /home/son/work_space/nicemona03/src/nicemona.cpp, line 41.
(gdb) run
Failed to read a valid object file image from memory.

(gdb) backtrace
Stopped due to shared library event
#0 0xb7f0ac70 in _dl_debug_state () from /lib/ld-linux.so.2
#1 0xb7eff6f6 in dl_main () from /lib/ld-linux.so.2
....
 
Old 01-02-2007, 04:03 PM   #2
jim mcnamara
Member
 
Registered: May 2002
Posts: 964

Rep: Reputation: 36
What is the output of:
Code:
ldd <your executable filename goes here>
when you run the ldd command from the Linux prompt?
 
Old 01-04-2007, 04:11 PM   #3
tatchan
LQ Newbie
 
Registered: Dec 2006
Posts: 4

Original Poster
Rep: Reputation: 0
Hi Jim,
Thanks alot for your reply. Now I found and solved the problem. I was so stupid that I didn't look thoroughly at the backtrack to see that it was a prolem of static constructors and destructors.

The problem is that I initialized a static const member variable by assigning it to value of another static const. It seems that the compliler is not clever enough to say that it is not allowed (no error, no warning).

Btw, here is the problem. The following program was built ok but was unable to run and debug shows the "stopped due to shared library events" although there is no shared library at all:

#include <string>
#include <iostream>
using namespace std;

class a
{
static const string STR1;
static const string STR2;
};

const string a::STR1 = a::STR2;
const string a::STR2 = "a string";

int main ()
{
cout << "I am running" << endl;
return 0;
}
 
Old 01-04-2007, 04:47 PM   #4
tuxdev
Senior Member
 
Registered: Jul 2005
Distribution: Slackware
Posts: 2,012

Rep: Reputation: 115Reputation: 115
The order of creation/initialization of static stuff is undefined. Which means all bets are off if you try to do that. I don't get the error you get with g++. It just segfaults while trying to construct one of the statics.

On a slightly unrelated note, I strongly discourage use of Xerces, especially the C++ version. I've personally had to deal with a memory leak from improper implementation of a memory pool technique. Fortunately, they wrapped all their allocations through an object, so I could forcefully clean up memory from under all remaining objects.
 
Old 01-04-2007, 04:49 PM   #5
Digital Surgeon
Member
 
Registered: Nov 2004
Location: Canada
Distribution: Ubuntu 7.10 - Gutsy Gibbon(Desktop Edition)
Posts: 184

Rep: Reputation: 30
Possible reason

Hi,
Dont know too much bout shared libraries. But sounds like your ram is invalid in a memory sector. You can run several scans from the ubcd but its almost impossible to detect. there several million locations...good luck. I'd find an alternate place to compile your program then troubleshoot it
 
  


Reply



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
shared library problem nhatkhang Programming 2 11-28-2006 07:15 AM
shared library problem jdb04 Linux - Newbie 2 06-11-2006 01:03 AM
Problem: creating a shared library allomeen Programming 3 02-09-2006 07:03 PM
Shared library creation ...... Problem... Plz Help.. rajsun Programming 2 03-31-2005 11:09 AM
shared library problem with rpm nate1002 Linux - Software 0 02-13-2004 02:52 PM

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

All times are GMT -5. The time now is 10:49 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