![]() |
#1 | |
Guru
![]() ![]() ![]() ![]() ![]() ![]() Posts: 976
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; } Quote:
Last edited by ericshliao; 12-06-2008 at 10:09 PM. |
|
![]() |
![]() |
![]() |
#2 |
Addicted to Porting
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,697
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.
|
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Guru
![]() ![]() ![]() ![]() ![]() ![]() Posts: 976
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; } |
![]() |
![]() |
![]() |
#4 |
Guru
![]() ![]() ![]() ![]() ![]() ![]() Posts: 976
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); "-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. |
![]() |
![]() |
![]() |
#5 |
Guru
![]() ![]() ![]() ![]() ![]() ![]() Posts: 976
Karma: 687
Join Date: Nov 2007
Device: Dell X51v; iLiad v2
|
I added a line after dlopen():
Code:
printf ("Error: %s\n", dlerror()); |
![]() |
![]() |
Advert | |
|
![]() |
#6 |
Guru
![]() ![]() ![]() ![]() ![]() ![]() Posts: 976
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. |
![]() |
![]() |
![]() |
#7 |
Addicted to Porting
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,697
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.
|
![]() |
![]() |
![]() |
#8 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,442
Karma: 300001
Join Date: Sep 2006
Location: Belgium
Device: PRS-500/505/700, Kindle, Cybook Gen3, Words Gear
|
Quote:
Code:
const std::string pluginPath = std::string(LIBDIR) + "/zlibrary/ui"; |
|
![]() |
![]() |
![]() |
#9 |
Guru
![]() ![]() ![]() ![]() ![]() ![]() Posts: 976
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. |
![]() |
![]() |
![]() |
#10 |
Guru
![]() ![]() ![]() ![]() ![]() ![]() Posts: 976
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.
|
![]() |
![]() |
![]() |
#11 |
Guru
![]() ![]() ![]() ![]() ![]() ![]() Posts: 976
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.
|
![]() |
![]() |
![]() |
|
![]() |
||||
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 |