runsisi's

technical notes

stardict-3.0.1.modified

2018-12-16 runsisi#desktop

使用 gcc version 4.4.2 编译 stardict 时会报类似如下的错:

data.cpp: In destructor ‘DictBase::~DictBase()’:
data.cpp:40: error: ‘fclose’ was not declared in this scope
data.cpp: In member function ‘gchar* DictBase::GetWordData(guint32, guint32)’:
data.cpp:50: error: ‘fseek’ was not declared in this scope
data.cpp:57: error: ‘fread’ was not declared in this scope

官方的 patch 并不完整,打了之后还会报错,我重新生成了一个补丁。 注意:由于我 disable 了一些插件,所以这个补丁也有可能是不完整的,但如果你的 configure 选项和我一样的话,那应该不会有错了。

我的编译选项如下:

  1. export PKG_CONFIG=/usr/bin/pkg-config
  2. ./configure —prefix=/usr —disable-espeak —disable-festival —disable-spell —disable-gucharmap
  3. make
  4. sudo make install

patch 代码如下:

diff -rNu stardict-3.0.1.orig/src/gconf_file.cpp stardict-3.0.1.modified/src/gconf_file.cpp
--- stardict-3.0.1.orig/src/gconf_file.cpp	2007-07-10 15:16:04.000000000 +0800
+++ stardict-3.0.1.modified/src/gconf_file.cpp	2009-11-27 11:39:47.494201898 +0800
@@ -22,6 +22,8 @@
 #  include "config.h"
 #endif
 
+#include <memory>
+
 #include <glib/gi18n.h>
 
 #include "gconf_file.hpp"
diff -rNu stardict-3.0.1.orig/src/inifile.cpp stardict-3.0.1.modified/src/inifile.cpp
--- stardict-3.0.1.orig/src/inifile.cpp	2007-08-01 17:43:00.000000000 +0800
+++ stardict-3.0.1.modified/src/inifile.cpp	2009-11-27 11:39:47.616218934 +0800
@@ -25,6 +25,7 @@
 #include <vector>
 #include <cerrno>
 #include <cstring>
+#include <cstdlib>
 #include <cstdio>
 #include <glib/gi18n.h>
 #include <glib/gstdio.h>
diff -rNu stardict-3.0.1.orig/src/lib/common.cpp stardict-3.0.1.modified/src/lib/common.cpp
--- stardict-3.0.1.orig/src/lib/common.cpp	2007-09-25 10:27:24.000000000 +0800
+++ stardict-3.0.1.modified/src/lib/common.cpp	2009-11-27 11:43:21.674327937 +0800
@@ -26,6 +26,10 @@
 
 #include "common.hpp"
 
+//Added by hustsystem@gmail.com
+#include <cstring>
+#include <cstdlib>
+
 static void parse_description(const char *p, long len, std::string &description)
 {
 	description.clear();
diff -rNu stardict-3.0.1.orig/src/lib/data.cpp stardict-3.0.1.modified/src/lib/data.cpp
--- stardict-3.0.1.orig/src/lib/data.cpp	2007-09-21 09:09:52.000000000 +0800
+++ stardict-3.0.1.modified/src/lib/data.cpp	2009-11-27 11:43:56.270328223 +0800
@@ -27,6 +27,9 @@
 #include "data.hpp"
 #include "getuint32.h"
 
+//Added by hustsystem@gmail.com
+#include <cstring>
+#include <cstdio>
 
 DictBase::DictBase()
 {
diff -rNu stardict-3.0.1.orig/src/lib/http_client.cpp stardict-3.0.1.modified/src/lib/http_client.cpp
--- stardict-3.0.1.orig/src/lib/http_client.cpp	2007-09-06 16:29:30.000000000 +0800
+++ stardict-3.0.1.modified/src/lib/http_client.cpp	2009-11-27 11:44:33.378327841 +0800
@@ -5,6 +5,9 @@
 #include "http_client.h"
 #include "sockets.hpp"
 
+//Added by hustsystem@gmail.com
+#include <cstring>
+
 sigc::signal<void, HttpClient *, const char *> HttpClient::on_error_;
 sigc::signal<void, HttpClient *> HttpClient::on_response_;
 
diff -rNu stardict-3.0.1.orig/src/lib/pluginmanager.cpp stardict-3.0.1.modified/src/lib/pluginmanager.cpp
--- stardict-3.0.1.orig/src/lib/pluginmanager.cpp	2007-10-10 11:26:45.000000000 +0800
+++ stardict-3.0.1.modified/src/lib/pluginmanager.cpp	2009-11-27 11:45:07.352201818 +0800
@@ -2,6 +2,9 @@
 #include "file.hpp"
 #include <string>
 
+//Added by hustsystem@gmail.com
+#include <cstring>
+
 StarDictPluginBaseObject::StarDictPluginBaseObject(const char *filename, GModule *module_, plugin_configure_func_t configure_func_):
 	plugin_filename(filename), module(module_), configure_func(configure_func_)
 {
diff -rNu stardict-3.0.1.orig/src/lib/stardict_client.cpp stardict-3.0.1.modified/src/lib/stardict_client.cpp
--- stardict-3.0.1.orig/src/lib/stardict_client.cpp	2007-10-31 16:32:11.000000000 +0800
+++ stardict-3.0.1.modified/src/lib/stardict_client.cpp	2009-11-27 11:45:46.502328751 +0800
@@ -31,6 +31,10 @@
 
 #include "stardict_client.hpp"
 
+//Added by hustsystem@gmail.com
+#include <cstdlib>
+#include <cstdio>
+
 #define PROTOCOL_VERSION "0.3"
 
 #define CODE_HELLO                   220 /* text msg-id */
diff -rNu stardict-3.0.1.orig/src/lib/treedict.cpp stardict-3.0.1.modified/src/lib/treedict.cpp
--- stardict-3.0.1.orig/src/lib/treedict.cpp	2007-09-21 09:09:52.000000000 +0800
+++ stardict-3.0.1.modified/src/lib/treedict.cpp	2009-11-27 11:46:13.400328166 +0800
@@ -30,6 +30,9 @@
 
 #include "treedict.hpp"
 
+//Added by hustsystem@gmail.com
+#include <cstring>
+
 GtkTreeStore *TreeDict::model=NULL;
 
 TreeDict::TreeDict()
diff -rNu stardict-3.0.1.orig/src/pangoview.cpp stardict-3.0.1.modified/src/pangoview.cpp
--- stardict-3.0.1.orig/src/pangoview.cpp	2007-09-25 15:11:48.000000000 +0800
+++ stardict-3.0.1.modified/src/pangoview.cpp	2009-11-27 11:39:47.646204660 +0800
@@ -22,6 +22,8 @@
 #  include "config.h"
 #endif
 
+#include <cstring>
+
 #include "gtktextviewpango.h"
 #include "utils.h"
 #include "skin.h"//for SkinCursor definition
diff -rNu stardict-3.0.1.orig/src/prefsdlg.cpp stardict-3.0.1.modified/src/prefsdlg.cpp
--- stardict-3.0.1.orig/src/prefsdlg.cpp	2007-10-30 16:14:07.000000000 +0800
+++ stardict-3.0.1.modified/src/prefsdlg.cpp	2009-11-27 11:39:47.674267936 +0800
@@ -21,6 +21,8 @@
 #  include "config.h"
 #endif
 
+#include <cstdlib>
+
 #include <glib/gi18n.h>
 #include <glib/gstdio.h>
 
diff -rNu stardict-3.0.1.orig/src/readword.cpp stardict-3.0.1.modified/src/readword.cpp
--- stardict-3.0.1.orig/src/readword.cpp	2007-07-10 15:16:04.000000000 +0800
+++ stardict-3.0.1.modified/src/readword.cpp	2009-11-27 11:39:47.793667947 +0800
@@ -3,6 +3,7 @@
 #endif
 
 #include <cstring>
+#include <cstdlib>
 #include <string>
 
 #include <glib/gi18n.h>
diff -rNu stardict-3.0.1.orig/src/sigc++/signal.h stardict-3.0.1.modified/src/sigc++/signal.h
--- stardict-3.0.1.orig/src/sigc++/signal.h	2007-07-10 15:16:01.000000000 +0800
+++ stardict-3.0.1.modified/src/sigc++/signal.h	2009-11-27 11:39:47.835203532 +0800
@@ -18,7 +18,7 @@
   //Compilers, such as older versions of SUN Forte C++, that do not allow this also often
   //do not allow a typedef to have the same name as a class in the typedef's definition.
   //For Sun Forte CC 5.7 (SUN Workshop 10), comment this out to fix the build.
-  #define SIGC_TYPEDEF_REDEFINE_ALLOWED 1
+//  #define SIGC_TYPEDEF_REDEFINE_ALLOWED 1
 #endif
 
 namespace sigc {
diff -rNu stardict-3.0.1.orig/src/utils.cpp stardict-3.0.1.modified/src/utils.cpp
--- stardict-3.0.1.orig/src/utils.cpp	2007-10-22 10:25:02.000000000 +0800
+++ stardict-3.0.1.modified/src/utils.cpp	2009-11-27 11:39:47.887815246 +0800
@@ -22,6 +22,8 @@
 #  include "config.h"
 #endif
 
+#include <cstring>
+
 #include <glib.h>
 #include <glib/gi18n.h>
 #include <cstdlib>
diff -rNu stardict-3.0.1.orig/src/x11_iskeyspressed.hpp stardict-3.0.1.modified/src/x11_iskeyspressed.hpp
--- stardict-3.0.1.orig/src/x11_iskeyspressed.hpp	2007-07-10 15:16:04.000000000 +0800
+++ stardict-3.0.1.modified/src/x11_iskeyspressed.hpp	2009-11-27 11:39:47.889203901 +0800
@@ -1,6 +1,8 @@
 #ifndef _X11_ISKEYSPRESSED_HPP_
 #define _X11_ISKEYSPRESSED_HPP_
 
+#include <memory>
+
 #include <gdk/gdkx.h>
 #include <X11/keysym.h>
 #include <gtk/gtk.h>
diff -rNu stardict-3.0.1.orig/stardict-plugins/stardict-dictdotcn-plugin/stardict_dictdotcn.cpp stardict-3.0.1.modified/stardict-plugins/stardict-dictdotcn-plugin/stardict_dictdotcn.cpp
--- stardict-3.0.1.orig/stardict-plugins/stardict-dictdotcn-plugin/stardict_dictdotcn.cpp	2007-10-10 17:28:29.000000000 +0800
+++ stardict-3.0.1.modified/stardict-plugins/stardict-dictdotcn-plugin/stardict_dictdotcn.cpp	2009-11-27 11:39:47.940202911 +0800
@@ -1,6 +1,6 @@
 #include "stardict_dictdotcn.h"
 #include <glib/gi18n.h>
-#include <string>
+#include <cstring>
 #include <list>
 
 #ifdef _WIN32
diff -rNu stardict-3.0.1.orig/stardict-plugins/stardict-espeak-tts-plugin/stardict_espeak.cpp stardict-3.0.1.modified/stardict-plugins/stardict-espeak-tts-plugin/stardict_espeak.cpp
--- stardict-3.0.1.orig/stardict-plugins/stardict-espeak-tts-plugin/stardict_espeak.cpp	2007-09-19 16:27:18.000000000 +0800
+++ stardict-3.0.1.modified/stardict-plugins/stardict-espeak-tts-plugin/stardict_espeak.cpp	2009-11-27 11:39:48.035213942 +0800
@@ -1,4 +1,5 @@
 #include "stardict_espeak.h"
+#include <cstring>
 #include <espeak/speak_lib.h>
 #include <glib/gi18n.h>
 
diff -rNu stardict-3.0.1.orig/stardict-plugins/stardict-gucharmap-plugin/stardict_gucharmap.cpp stardict-3.0.1.modified/stardict-plugins/stardict-gucharmap-plugin/stardict_gucharmap.cpp
--- stardict-3.0.1.orig/stardict-plugins/stardict-gucharmap-plugin/stardict_gucharmap.cpp	2007-08-31 15:10:41.000000000 +0800
+++ stardict-3.0.1.modified/stardict-plugins/stardict-gucharmap-plugin/stardict_gucharmap.cpp	2009-11-27 11:39:48.047327983 +0800
@@ -1,7 +1,8 @@
 #include "stardict_gucharmap.h"
 #include <glib/gi18n.h>
 #include <gucharmap/gucharmap.h>
-#include <string>
+#include <cstring>
+#include <cstdlib>
 
 static char *build_dictdata(char type, const char *definition)
 {
diff -rNu stardict-3.0.1.orig/stardict-plugins/stardict-html-parsedata-plugin/stardict_html_parsedata.cpp stardict-3.0.1.modified/stardict-plugins/stardict-html-parsedata-plugin/stardict_html_parsedata.cpp
--- stardict-3.0.1.orig/stardict-plugins/stardict-html-parsedata-plugin/stardict_html_parsedata.cpp	2007-09-13 15:51:55.000000000 +0800
+++ stardict-3.0.1.modified/stardict-plugins/stardict-html-parsedata-plugin/stardict_html_parsedata.cpp	2009-11-27 11:39:48.097636052 +0800
@@ -1,4 +1,6 @@
 #include "stardict_html_parsedata.h"
+#include <cstring>
+#include <cstdlib>
 #include <glib/gi18n.h>
 
 #ifdef _WIN32
diff -rNu stardict-3.0.1.orig/stardict-plugins/stardict-man-plugin/stardict_man.cpp stardict-3.0.1.modified/stardict-plugins/stardict-man-plugin/stardict_man.cpp
--- stardict-3.0.1.orig/stardict-plugins/stardict-man-plugin/stardict_man.cpp	2007-09-19 16:30:54.000000000 +0800
+++ stardict-3.0.1.modified/stardict-plugins/stardict-man-plugin/stardict_man.cpp	2009-11-27 11:39:48.099254344 +0800
@@ -1,6 +1,6 @@
 #include "stardict_man.h"
 #include <glib/gi18n.h>
-#include <string>
+#include <cstring>
 
 static const StarDictPluginSystemInfo *plugin_info = NULL;
 static bool need_prefix;
diff -rNu stardict-3.0.1.orig/stardict-plugins/stardict-powerword-parsedata-plugin/stardict_powerword_parsedata.cpp stardict-3.0.1.modified/stardict-plugins/stardict-powerword-parsedata-plugin/stardict_powerword_parsedata.cpp
--- stardict-3.0.1.orig/stardict-plugins/stardict-powerword-parsedata-plugin/stardict_powerword_parsedata.cpp	2007-10-25 16:16:37.000000000 +0800
+++ stardict-3.0.1.modified/stardict-plugins/stardict-powerword-parsedata-plugin/stardict_powerword_parsedata.cpp	2009-11-27 11:39:48.101204662 +0800
@@ -1,4 +1,5 @@
 #include "stardict_powerword_parsedata.h"
+#include <cstring>
 #include <glib/gi18n.h>
 
 #ifdef _WIN32
diff -rNu stardict-3.0.1.orig/stardict-plugins/stardict-qqwry-plugin/stardict_qqwry.cpp stardict-3.0.1.modified/stardict-plugins/stardict-qqwry-plugin/stardict_qqwry.cpp
--- stardict-3.0.1.orig/stardict-plugins/stardict-qqwry-plugin/stardict_qqwry.cpp	2007-11-02 16:41:26.000000000 +0800
+++ stardict-3.0.1.modified/stardict-plugins/stardict-qqwry-plugin/stardict_qqwry.cpp	2009-11-27 11:39:48.102204231 +0800
@@ -1,7 +1,8 @@
 #include "stardict_qqwry.h"
 #include <glib/gi18n.h>
 #include <glib/gstdio.h>
-#include <string>
+#include <cstring>
+#include <cstdlib>
 
 #ifdef _WIN32
 #include <windows.h>
diff -rNu stardict-3.0.1.orig/stardict-plugins/stardict-spell-plugin/stardict_spell.cpp stardict-3.0.1.modified/stardict-plugins/stardict-spell-plugin/stardict_spell.cpp
--- stardict-3.0.1.orig/stardict-plugins/stardict-spell-plugin/stardict_spell.cpp	2007-09-19 16:29:21.000000000 +0800
+++ stardict-3.0.1.modified/stardict-plugins/stardict-spell-plugin/stardict_spell.cpp	2009-11-27 11:39:48.138202174 +0800
@@ -1,4 +1,5 @@
 #include "stardict_spell.h"
+#include <cstring>
 #include <glib.h>
 #include <glib/gi18n.h>
 #include <enchant.h>
diff -rNu stardict-3.0.1.orig/stardict-plugins/stardict-update-info-plugin/stardict_update_info.cpp stardict-3.0.1.modified/stardict-plugins/stardict-update-info-plugin/stardict_update_info.cpp
--- stardict-3.0.1.orig/stardict-plugins/stardict-update-info-plugin/stardict_update_info.cpp	2007-09-19 16:34:36.000000000 +0800
+++ stardict-3.0.1.modified/stardict-plugins/stardict-update-info-plugin/stardict_update_info.cpp	2009-11-27 11:41:43.556203213 +0800
@@ -1,6 +1,9 @@
 #include "stardict_update_info.h"
 #include <glib/gi18n.h>
 
+//Added by hustsystem@gmail.com
+#include <cstdlib>
+
 #ifdef _WIN32
 #include <windows.h>
 #endif
diff -rNu stardict-3.0.1.orig/stardict-plugins/stardict-wiki-parsedata-plugin/stardict_wiki2xml.cpp stardict-3.0.1.modified/stardict-plugins/stardict-wiki-parsedata-plugin/stardict_wiki2xml.cpp
--- stardict-3.0.1.orig/stardict-plugins/stardict-wiki-parsedata-plugin/stardict_wiki2xml.cpp	2007-07-10 15:16:15.000000000 +0800
+++ stardict-3.0.1.modified/stardict-plugins/stardict-wiki-parsedata-plugin/stardict_wiki2xml.cpp	2009-11-27 11:39:48.162232324 +0800
@@ -1,5 +1,6 @@
 #include "stardict_wiki2xml.h"
 #include "WIKI2XML.h"
+#include <cstring>
 #include <glib.h>
 
 std::string wiki2xml(std::string &str)
diff -rNu stardict-3.0.1.orig/stardict-plugins/stardict-wiki-parsedata-plugin/stardict_wiki_parsedata.cpp stardict-3.0.1.modified/stardict-plugins/stardict-wiki-parsedata-plugin/stardict_wiki_parsedata.cpp
--- stardict-3.0.1.orig/stardict-plugins/stardict-wiki-parsedata-plugin/stardict_wiki_parsedata.cpp	2007-08-31 14:41:21.000000000 +0800
+++ stardict-3.0.1.modified/stardict-plugins/stardict-wiki-parsedata-plugin/stardict_wiki_parsedata.cpp	2009-11-27 11:39:48.163230566 +0800
@@ -1,5 +1,6 @@
 #include "stardict_wiki_parsedata.h"
 #include "stardict_wiki2xml.h"
+#include <cstring>
 #include <glib/gi18n.h>
 
 #ifdef _WIN32
diff -rNu stardict-3.0.1.orig/stardict-plugins/stardict-wordnet-plugin/court_widget.cpp stardict-3.0.1.modified/stardict-plugins/stardict-wordnet-plugin/court_widget.cpp
--- stardict-3.0.1.orig/stardict-plugins/stardict-wordnet-plugin/court_widget.cpp	2007-10-18 09:36:22.000000000 +0800
+++ stardict-3.0.1.modified/stardict-plugins/stardict-wordnet-plugin/court_widget.cpp	2009-11-27 11:39:48.250505904 +0800
@@ -1,4 +1,5 @@
 #include "court_widget.h"
+#include <cstring>
 #include <math.h>
 #include <list>
 
diff -rNu stardict-3.0.1.orig/stardict-plugins/stardict-wordnet-plugin/stardict_wordnet.cpp stardict-3.0.1.modified/stardict-plugins/stardict-wordnet-plugin/stardict_wordnet.cpp
--- stardict-3.0.1.orig/stardict-plugins/stardict-wordnet-plugin/stardict_wordnet.cpp	2007-10-15 11:32:04.000000000 +0800
+++ stardict-3.0.1.modified/stardict-plugins/stardict-wordnet-plugin/stardict_wordnet.cpp	2009-11-27 11:39:48.252202907 +0800
@@ -1,5 +1,6 @@
 #include "stardict_wordnet.h"
 #include "court_widget.h"
+#include <cstring>
 #include <glib/gi18n.h>
 
 #ifdef _WIN32
diff -rNu stardict-3.0.1.orig/stardict-plugins/stardict-wordnet-plugin/stardict_wordnet_parsedata.cpp stardict-3.0.1.modified/stardict-plugins/stardict-wordnet-plugin/stardict_wordnet_parsedata.cpp
--- stardict-3.0.1.orig/stardict-plugins/stardict-wordnet-plugin/stardict_wordnet_parsedata.cpp	2007-10-10 17:39:10.000000000 +0800
+++ stardict-3.0.1.modified/stardict-plugins/stardict-wordnet-plugin/stardict_wordnet_parsedata.cpp	2009-11-27 11:39:48.253207924 +0800
@@ -1,4 +1,5 @@
 #include "stardict_wordnet_parsedata.h"
+#include <cstring>
 #include <glib/gi18n.h>
 
 #ifdef _WIN32
diff -rNu stardict-3.0.1.orig/stardict-plugins/stardict-xdxf-parsedata-plugin/stardict_xdxf_parsedata.cpp stardict-3.0.1.modified/stardict-plugins/stardict-xdxf-parsedata-plugin/stardict_xdxf_parsedata.cpp
--- stardict-3.0.1.orig/stardict-plugins/stardict-xdxf-parsedata-plugin/stardict_xdxf_parsedata.cpp	2007-08-31 14:41:54.000000000 +0800
+++ stardict-3.0.1.modified/stardict-plugins/stardict-xdxf-parsedata-plugin/stardict_xdxf_parsedata.cpp	2009-11-27 11:39:48.269328479 +0800
@@ -1,4 +1,5 @@
 #include "stardict_xdxf_parsedata.h"
+#include <cstring>
 #include <glib/gi18n.h>
 
 #ifdef _WIN32
diff -rNu stardict-3.0.1.orig/tests/t_config_file.cpp stardict-3.0.1.modified/tests/t_config_file.cpp
--- stardict-3.0.1.orig/tests/t_config_file.cpp	2007-07-10 15:16:04.000000000 +0800
+++ stardict-3.0.1.modified/tests/t_config_file.cpp	2009-11-27 11:39:48.354233544 +0800
@@ -8,6 +8,7 @@
 #include <cstring>
 #include <iterator>
 #include <iostream>
+#include <memory>
 #include <gtk/gtk.h>
 
 #include "config_file.hpp"
diff -rNu stardict-3.0.1.orig/tests/t_xml.cpp stardict-3.0.1.modified/tests/t_xml.cpp
--- stardict-3.0.1.orig/tests/t_xml.cpp	2007-07-10 15:16:04.000000000 +0800
+++ stardict-3.0.1.modified/tests/t_xml.cpp	2009-11-27 11:39:48.356203068 +0800
@@ -5,6 +5,7 @@
 #include <glib.h>
 #include <cstdlib>
 #include <string>
+#include <cstring>
 
 
 static void xml_decode(const char *str, std::string& decoded)