Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Readers > More E-Book Readers > iRex > iRex Developer's Corner

Notices

Reply
 
Thread Tools Search this Thread
Old 12-06-2008, 07:53 PM   #1
ericshliao
Guru
ericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enough
 
Posts: 973
Karma: 687
Join Date: Nov 2007
Device: Dell X51v; iLiad v2
FBReader 0.8.17 problem

I have built FBReader 0.8.17 for iLiad.
It works in Scratchbox enviroment but fialed on iLiad.
I added some notification into its source code and found where it failed. But I can't figure why.

This is the main entrance in "main.cpp"
Code:
int main(int argc, char **argv) {
	printf("1\n");//my personal addon
	if (!ZLibrary::init(argc, argv)) {
		printf("!ZLibrary::init\n");
		return 1;
	}
	printf("2\n");//my personal addon
	ZLibrary::run(new FBReader(argc == 1 ? std::string() : argv[1]));
	printf("3\n");//my personal addon
	ZLibrary::shutdown();
	return 0;
}

"ZLibrary.cpp" called by "main.cpp"
Code:
bool ZLibrary::init(int &argc, char **&argv) {
#ifdef ZLSHARED
	const std::string pluginPath = std::string(LIBDIR) + "/zlibrary/ui";

	void *handle = 0;
	printf("11\n");//my personal addon
	fflush(stdout);
	if ((argc > 2) && std::string("-zlui") == argv[1]) {
		handle = dlopen((pluginPath + "/zlui-" + argv[2] + ".so").c_str(), RTLD_NOW);
		argc -= 2;
		argv += 2;
	}
	printf("12\n");//my personal addon
	fflush(stdout);
	if (handle == 0) {
		DIR *dir = opendir(pluginPath.c_str());
		if (dir == 0) {
			return false;
		}
		std::vector<std::string> names;
		const dirent *file;
		struct stat fileInfo;
		while ((file = readdir(dir)) != 0) {
			const std::string shortName = file->d_name;
			if ((shortName.substr(0, 5) != "zlui-") ||
					!ZLStringUtil::stringEndsWith(shortName, ".so")) {
				continue;
			}
			const std::string fullName = pluginPath + "/" + shortName;
			stat(fullName.c_str(), &fileInfo);
			if (!S_ISREG(fileInfo.st_mode)) {
				continue;
			}
			names.push_back(fullName);
		}
		closedir(dir);
	printf("13\n");//my personal addon
fflush(stdout);
		std::sort(names.begin(), names.end());
		for (std::vector<std::string>::const_iterator it = names.begin();
				 (it != names.end()) && (handle == 0); ++it) {
			handle = dlopen(it->c_str(), RTLD_NOW);
		}

		if (handle == 0) {
			return false;
		}
	}
	dlerror();
	printf("14\n");//my personal addon
fflush(stdout);
	void (*initLibrary)();
	*(void**)&initLibrary = dlsym(handle, "initLibrary");
	if (dlerror() != 0) {
		return false;
	}
#endif /* ZLSHARED */
	printf("15\n");
fflush(stdout);
	initLibrary();
	printf("16\n");//my personal addon
fflush(stdout);
	if (ZLibraryImplementation::Instance == 0) {
		return false;
	}
	printf("17\n");//my personal addon
fflush(stdout);
	ZLibraryImplementation::Instance->init(argc, argv);
	return true;
}
When I execute FBReader in mrxvt on iLiad, I got output:
Quote:
1
!ZLibrary::init
Then FBReader stopped. And ZLibrary::init didn't output anything. (The reasone that ZLibrary::init() didn't output anything was caused by my forgetting to update lib file. ZLibrary::init() did executed to printf("13\n") and returned false.)

Last edited by ericshliao; 12-06-2008 at 10:09 PM.
ericshliao is offline   Reply With Quote
Old 12-06-2008, 09:02 PM   #2
Adam B.
Addicted to Porting
Adam B. is a jewel in the roughAdam B. is a jewel in the roughAdam B. is a jewel in the roughAdam B. is a jewel in the roughAdam B. is a jewel in the roughAdam B. is a jewel in the roughAdam B. is a jewel in the roughAdam B. is a jewel in the roughAdam B. is a jewel in the roughAdam B. is a jewel in the roughAdam B. is a jewel in the rough
 
Adam B.'s Avatar
 
Posts: 1,695
Karma: 7194
Join Date: Oct 2006
Location: Indianapolis, IN
Device: iRex iLiad, Nokia 770, Samsung i760
Change "RTLD_NOW" to "RTLD_LAZY". This bug took me forever to hunt down.
Adam B. is offline   Reply With Quote
 
Enthusiast
Old 12-06-2008, 09:59 PM   #3
ericshliao
Guru
ericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enough
 
Posts: 973
Karma: 687
Join Date: Nov 2007
Device: Dell X51v; iLiad v2
Changing RTLD_NOW to RTLD_LAZY seems not work. Still the same situation.
But your suggestion did help me to identify that it has something to do with dlop(). Because ZLibrary::init() executed the following and return false:
Code:
		std::sort(names.begin(), names.end());
		for (std::vector<std::string>::const_iterator it = names.begin();
				 (it != names.end()) && (handle == 0); ++it) {
			handle = dlopen(it->c_str(), RTLD_LAZY);
		}

		if (handle == 0) {
			return false;
		}
ericshliao is offline   Reply With Quote
Old 12-06-2008, 10:35 PM   #4
ericshliao
Guru
ericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enough
 
Posts: 973
Karma: 687
Join Date: Nov 2007
Device: Dell X51v; iLiad v2
More info for developers:
When I execute fbreader in Scrachbox, it will execute to
Code:
handle = dlopen(it->c_str(), RTLD_NOW);
the first parameter passed to dlopen is:
"-prefix-/fbreader/lib/zlibrary/ui/zlui-gtk.so"
and dlopen() will return a non-zero value. Then fbreader will continue. On iLiad, dlopen returned 0 to handle, henceforth fbreader stopped.

Added:
I have changed RTLD_NOW to RTLD_LAZY, still the same problem.
ericshliao is offline   Reply With Quote
Old 12-06-2008, 10:48 PM   #5
ericshliao
Guru
ericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enough
 
Posts: 973
Karma: 687
Join Date: Nov 2007
Device: Dell X51v; iLiad v2
I added a line after dlopen():
Code:
printf ("Error: %s\n", dlerror());
Then I found I don't have "libgio-2.0.so.0". It seems the real cause.
ericshliao is offline   Reply With Quote
Old 12-07-2008, 03:40 AM   #6
ericshliao
Guru
ericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enough
 
Posts: 973
Karma: 687
Join Date: Nov 2007
Device: Dell X51v; iLiad v2
The difference between RTLD_NOW and RTLD_LAZY is whether libs are checked in the begining. When I have fixed all needed libs, it is a good idea to use RTLD_LAZY to save some execution time.
Currently, I am still looking for what lib is needed to run fbreader on iLiad, using RTLD_NOW will tell me what lib is missing in the begining.

Last edited by ericshliao; 12-07-2008 at 03:42 AM.
ericshliao is offline   Reply With Quote
Old 12-07-2008, 11:34 AM   #7
Adam B.
Addicted to Porting
Adam B. is a jewel in the roughAdam B. is a jewel in the roughAdam B. is a jewel in the roughAdam B. is a jewel in the roughAdam B. is a jewel in the roughAdam B. is a jewel in the roughAdam B. is a jewel in the roughAdam B. is a jewel in the roughAdam B. is a jewel in the roughAdam B. is a jewel in the roughAdam B. is a jewel in the rough
 
Adam B.'s Avatar
 
Posts: 1,695
Karma: 7194
Join Date: Oct 2006
Location: Indianapolis, IN
Device: iRex iLiad, Nokia 770, Samsung i760
If you're using the VMware image or Antartica's toolchain, you can you the libtool.sh script to generate the necessary libraries.
Adam B. is offline   Reply With Quote
Old 12-07-2008, 07:56 PM   #8
igorsk
Wizard
igorsk reads XML... blindfoldedigorsk reads XML... blindfoldedigorsk reads XML... blindfoldedigorsk reads XML... blindfoldedigorsk reads XML... blindfoldedigorsk reads XML... blindfoldedigorsk reads XML... blindfoldedigorsk reads XML... blindfoldedigorsk reads XML... blindfoldedigorsk reads XML... blindfoldedigorsk reads XML... blindfolded
 
Posts: 3,443
Karma: 52235
Join Date: Sep 2006
Location: Belgium
Device: PRS-500/505/700, Kindle, Cybook Gen3, Words Gear
Quote:
Originally Posted by ericshliao View Post
More info for developers:
When I execute fbreader in Scrachbox, it will execute to
Code:
handle = dlopen(it->c_str(), RTLD_NOW);
the first parameter passed to dlopen is:
"-prefix-/fbreader/lib/zlibrary/ui/zlui-gtk.so"
and dlopen() will return a non-zero value. Then fbreader will continue. On iLiad, dlopen returned 0 to handle, henceforth fbreader stopped.
This path is not right. To check where it comes from, look at the first line of the function:
Code:
const std::string pluginPath = std::string(LIBDIR) + "/zlibrary/ui";
So most likely configure step didn't work right and LIBDIR variable was not set correctly.
igorsk is offline   Reply With Quote
Old 12-07-2008, 08:34 PM   #9
ericshliao
Guru
ericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enough
 
Posts: 973
Karma: 687
Join Date: Nov 2007
Device: Dell X51v; iLiad v2
Thanx. I'll try the libtool.sh.

The path is ok. That "-prefix-" is not real input parameter to dlopen(). Just for temporary convenience for discussion.

Added:
In fact, I have all the needed lib ready in my compile environment. The problem is how to identify which one is really needed (using ldd might generate a list) and some required config for individual lib.

I can enter FBReader GUI, but all characters are represented by weired rectangle. It seems some required config for Pango is missing.

Last edited by ericshliao; 12-08-2008 at 12:25 AM.
ericshliao is offline   Reply With Quote
Old 12-19-2008, 01:20 PM   #10
ericshliao
Guru
ericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enough
 
Posts: 973
Karma: 687
Join Date: Nov 2007
Device: Dell X51v; iLiad v2
The pango config on iLilad is for older version, not compatible to newer version. I have solved it now.Page-flipbar on iLiad is working for FBReader, too. Now, the only issue is how to control led light properly.
ericshliao is offline   Reply With Quote
Old 12-25-2008, 05:20 PM   #11
ericshliao
Guru
ericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enough
 
Posts: 973
Karma: 687
Join Date: Nov 2007
Device: Dell X51v; iLiad v2
I am facing another problem with dlopen(). To control iLiad led light from FBReader, I tried to add erIpcStartClient() into FBReader source code. The compilation is ok. At run time, FBreader only looks for erIpcStartClient() in "/lib/zlibrary/ui/zlui-gtk.so", and of course, there is not such function in that shared object.
ericshliao is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with grays fbreader 0.9.2 on Pocketbook 360: readerreader PocketBook 6 09-01-2010 04:42 AM
iLiad FBReader 0.10.7 Problem Fellball iRex Developer's Corner 15 06-03-2009 11:03 PM
little problem with fbreader Escaflowne iRex 1 02-05-2008 05:10 PM
iLiad Little problem with fbreader Escaflowne iRex Developer's Corner 8 01-16-2008 01:30 AM
FBReader fixes character encoding problem jbenny News 1 10-18-2007 10:50 PM


All times are GMT -4. The time now is 06:13 AM.


MobileRead.com is a privately owned, operated and funded community.