CHMReader compile issues on Mac 
Mozilla June 8th, 2009
CHM Reader is a great extension make Firefox support .chm file, project host on:http://sourceforge.net/projects/chmreader/
When I compiled it on my OSX 10.5.7 occurred following issue:
1 2 3 | g++ -o components/mozCHMModule.os -c -fPIC -I/Users/duo/xulrunner-sdk/include -I/Users/duo/xulrunner-sdk/sdk/include components/mozCHMModule.cpp /Users/duo/xulrunner-sdk/sdk/include/nsStringAPI.h:1053: error: size of array 'arg' is negative scons: *** [components/mozCHMModule.os] Error 1 |
The line in nsStringAPI.h is PR_STATIC_ASSERT(sizeof(wchar_t) == 2), but 4-bytes is the default wide character size on macs, so we should add -fshort-wchar to compile flag options.
The other issue in link stage:
1 2 3 4 | g++ -o platform/Darwin_x86-gcc3/components/libchm.dylib -dynamiclib components/chm_lib.os components/lzx.os components/mozCHMModule.os components/mozCHMFile.os components/mozCHMUnitInfo.os components/mozCHMInputStream.os -L/Users/duo/xulrunner-sdk/lib -L/Users/duo/xulrunner-sdk/sdk/lib -lxpcom -lxpcomglue_s -lnspr4 -lplds4 -lplc4 ld: file not found: @executable_path/libsmime3.dylib collect2: ld returned 1 exit status scons: *** [platform/Darwin_x86-gcc3/components/libchm.dylib] Error 1 |
Just add -Wl,-executable_path -Wl,/path/to/gecko/sdk/bin to link flag options.
Complete svn diff result:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | Index: components/SConscript =================================================================== --- components/SConscript (revision 114) +++ components/SConscript (working copy) @@ -7,6 +7,8 @@ libs = ['xpcom', 'xpcomglue_s', 'nspr4', 'plds4', 'plc4'] +linkflags = '' + # We use firefox development files instead for geckosdk on FreeBSD if system() != 'FreeBSD': try: @@ -38,7 +40,8 @@ cpppath.append('/usr/include/nspr') elif system() == 'Darwin': - cxxflags = [] + cxxflags = ['-fshort-wchar'] + linkflags = ['-Wl,-executable_path', '-Wl,%s/bin' % geckosdk] elif system() == 'Windows': cxxflags = ['/D', 'WIN32', '/D', 'XP_WIN', '/nologo', '/MT', '/O2'] @@ -70,7 +73,7 @@ '/usr/local/lib/firefox3/sdk/lib'] env = Environment(CPPPATH = cpppath, LIBPATH = libpath, LIBS = libs, - CXXFLAGS= cxxflags) + CXXFLAGS= cxxflags, LINKFLAGS = linkflags) bxpt = Builder( action = 'xpidl -w -m typelib -Icomponents -I%s -I%s -e $TARGET $SOURCE' \ |
关于 Mozilla 的 Plugin 编译
Mozilla October 24th, 2006
最近折腾了好久, 才总算大致弄明白了如何编写一个 mozilla 的 plugin. 这玩意儿的资料也实在太少了, 相对与 Extension 和 XPCom 而言…
关于 plugin 的一些机制和原理, 可以从 Gecko_Plugin_API_Reference 获得.
在这我主要是提下怎么编译一个 Plugin(感谢 Paul 的热心帮助)
相关工具: gecko sdk 以及 mozilla source
关于 plugin 的示例我们可以在 mozilla/modules/plugin/tools/sdk/samples 里找到.
以下给出个编译 basic 的 Makefile
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | CXX = g++ CPPFLAGS += -fno-rtti \ -fno-exceptions \ -shared # Change this to point at your Gecko SDK directory. GECKO_SDK_PATH = /home/duo/gecko-sdk GECKO_DEFINES = -DMOZ_X11 -DMOZILLA_STRICT_API GECKO_INCLUDES = -I $(GECKO_SDK_PATH)/include PLUGIN_INCLUDES = -I ../../include GECKO_LDFLAGS = -L $(GECKO_SDK_PATH)/lib -rdynamic -lXi -lXext -lX11 -lm -lXt FILES = plugin.cpp ../../common/*.cpp TARGET = libpluginbasic.so build: $(CXX) -Wall -Os -o $(TARGET) $(GECKO_CONFIG_INCLUDE) $(GECKO_DEFINES) $(PLUGIN_INCLUDES) \ $(GECKO_INCLUDES) $(GECKO_LDFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(FILES) clean: rm $(TARGET) |
编译后将 libpluginbasic.so 拷贝至 .mozilla/plugins 目录下即可.
PS1: 下一步得搞定怎么写一个使用 GTK 库的 Plugin 了…继续研究 mplayer-plugin 中…
PS2: 关于 IE 浏览本 Blog 的时候 simple page 似乎会因为 coolcode 生成的高亮代码过长移动到下方…这个问题我现在也不知道怎么解决, 所以还是推荐大家用 Firefox 吧…