2010年12月28日

在 ubuntu 9.10 安裝 gretl 1.9.3x - 有關 gnuplot 的問題

如果覺得自行 compile 麻煩的話, 不妨試試 [在 ubuntu 10.04 安裝 gretl 1.9.3x - 有關 gnuplot 的問題] 這一篇的方法

gretl 網站的原始方法
這個步驟是成功的: see Install Gnuplot 4.4.0 on Ubuntu Linux
sudo apt-get install libwxgtk2.8-dev libpango1.0-dev libreadline5-dev libx11-dev libxt-dev texinfo libgd2-xpm-dev

Then we download and compile gnuplot (run each command/line in a terminal)
  • wget http://sourceforge.net/projects/gnuplot/files/gnuplot/4.4.0/gnuplot-4.4.0.tar.gz/download
  • tar xzf gnuplot-4.4.0.tar.gz
  • mkdir build && cd build
  • ../gnuplot-4.4.0/configure --with-readline=gnu
  • make
  • sudo make install
Compile 後, gnuplot 的子目錄位置是:
/usr/local/bin/gnuplot


用 gnuplot for gretl 的方法, 但是有錯誤(在執行 gretl 時):
/opt/gnuplot/bin/gnuplot: /usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.14' not found (required by /opt/gnuplot/bin/gnuplot)


另外有成功地 compile gnuplot, 在安裝以下的 packages 之後 (參見):
sudo apt-get install automake checkinstall libwxgtk2.8-dev libpango1.0-dev libreadline5-dev libx11-dev libxt-dev texinfo libgd2-xpm-dev  liblua5.1-dev

另見 gnuplot 4.4.2@sourceforge

再執行:

./prepare
./configure --with-readline=gnu --with-lua


*from http://gretl.sourceforge.net/gnuplot_for_gretl.html

Build from source

Note that for this to succeed you will need to have the "devel" packages for GTK+ and Xorg installed.
export CVSROOT=:pserver:anonymous@gnuplot.cvs.sourceforge.net:/cvsroot/gnuplot
 cvs login
 cvs -z3 checkout gnuplot
Just hit Enter when asked for a password. Then
sh ./prepare
 ./configure --prefix=/opt/gnuplot
 make
 sudo make install
The choice of installing to /opt/gnuplot is designed to avoid collisions with gnuplot as installed by your Linux distro.

Packaged binary

If you would prefer to try a pre-built binary, use the following commands to download and install the package.
cd /tmp
 wget http://ricardo.ecn.wfu.edu/pub/gretl/gnuplot-4.5-i586-3.tar.gz
 cd / 
 sudo tar xvfz /tmp/gnuplot-4.5-i586-3.tar.gz
 rm /tmp/gnuplot-4.5-i586-3.tar.gz
Note that this package installs into /opt/gnuplot.

Using the new gnuplot

In gretl, go to Tools/Preferences/General/Programs and change the "gnuplot" entry to read
/opt/gnuplot/bin/gnuplot

* see also Compiling GNUPLOT from CVS with Ubuntu

2010年12月20日

Better RSS Widget for Wordpress

*source: Better RSS Widget
Better RSS Widget 這個 wordpress 的外掛還滿好用的, 它可以將 RSS 放在 sidebar 或正文 (post) 當中, 不過放在 sidebar 好像會讓網頁開啟變慢...

short code 的用法
[better-rss feed=http://careercycu.wordpress.com/feed/ show_date=1 show_summary=1 excerpt=100 items=5]
參見 Support 討論頁

2010年12月15日

控制 wordpress 文章的中文摘要 (expert) 字數

在 function.php 中加入以下的 php 碼

[code]
function utf8_trim($str) {

    $len = strlen($str);

    for ($i=strlen($str)-1; $i>=0; $i-=1){
        $hex .= ' '.ord($str[$i]);
        $ch = ord($str[$i]);
        if (($ch & 128)==0) return(substr($str,0,$i));
        if (($ch & 192)==192) return(substr($str,0,$i));
    }
    return($str.$hex);
}
function mul_excerpt ($excerpt) {
     $myexcerpt = substr($excerpt,0,500);
     return utf8_trim($myexcerpt) . '... ';
}

add_filter('the_excerpt', 'mul_excerpt');
add_filter('the_excerpt_rss', 'mul_excerpt');
[/code]

wordpress 要怎樣才會有 特色圖片

有時裝上某些 theme 會有 "設定特色圖片" (thumbnail) 但有些沒有...
在 主題編輯器下 (theme editor) 的 function.php 中加入下列一行 PHP 指令, 即會跑出 "設定特色圖片" 選項了!

add_theme_support('post-thumbnails');

2010年12月14日

Wordpress 安裝外掛或主題時, 資料夾權限問題

前一篇發現了 Wordpress 安裝外掛或主題時, 資料夾權限問題, 變成要另裝 vsFTP 才能上傳的問題, 在 WordPress搬家注意事項之資料夾、權限設定, 這篇文章得到更方便的解決方法:


開啟 wordpress 根目錄下的「wp-config.php」文件,在最後一行上添加下方代碼。

/** 設定新主機資料夾權限 **/
if(is_admin()) {
add_filter('filesystem_method', create_function('$a', 'return "direct";' ));
define( 'FS_CHMOD_DIR', 0751 );
}

即可!

2010年12月11日

安裝 wordpress 在 ubuntu 10.04

上次發現將 wordpress 安裝在 ubuntu 10.04 上, 媒體檔案上傳時,就可以用中文檔名 (在 windows 平台上不行),但要安裝佈景主題 (theme) 或外掛 (plugin) 時,竟要輸入 “Connection Information“ :

Hostname:127.0.0.1
FTP Username:
FTP Password:
Connection Type:
等資訊。這在安裝在 windows 平台時是沒見過的。看起來是要 ubuntu 上裝一個 FTP server。
在 Google 一番之後,我安裝了 vsftp, 並修改了 /etc/vsftpd.conf 這個預設的資訊檔, 裡面多半採用預設值即可,只有一個特別要注意的是

#local_umask=022

要特別加上 # 號,否則會出現:

Could not create directory. /var/www/wp-content/XXX ...

這種問題。本以為是目錄權限設定不好,但弄了很久,才猜到可能是上述的 FTP 上傳後 unmask 的問題,加上#之後,果然就正常了!

註:
1. vsFTP 帳號用原來的 ubuntu 帳號即可
2. 重新啟動 vsFTP 的指令:

sudo /etc/init.d/vsftpd start
3. 其它參考指令
netstat -ntulp |grep 21
netstat -ntulp |more
sudo /etc/init.d/apache2 restart

4. /etc/vsftpd.conf 檔中的重要內容
listen=YES
anonymous_enable=NO
local_enable=YES
write_enable=YES
#local_umask=022
#anon_upload_enable=YES
#anon_mkdir_write_enable=YES
dirmessage_enable=YES
use_localtime=YES
xferlog_enable=YES
#connect_from_port_20=YES
#chown_uploads=YES
#chown_username=whoever
secure_chroot_dir=/var/run/vsftpd/empty
pam_service_name=vsftpd
rsa_cert_file=/etc/ssl/private/vsftpd.pem

2010年12月10日

Apache 2 - sites.available 的設定

以下本來是試 Apache::ASP 和 mono,看可否在 ubuntu + apache 之下,跑以前寫的 asp 程式。但是發現它們多是適用 asp.net 的架構, 而不是最早以前 IIS 下的簡單 asp 語法。
看來是要忍痛放棄 IIS 了...

<VirtualHost *:80>
RewriteEngine On
RewriteOptions Inherit
ServerAdmin webmaster@localhost

DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>

ErrorLog /var/log/apache2/error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog /var/log/apache2/access.log combined

Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>

Alias /asp_web "/home/XXX/asp_web/"
<Directory "/home/XXX/asp_web/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
SetHandler mono
DirectoryIndex index.aspx default.asp index.asp index.htm index.html

</Directory>

</VirtualHost>

轉程式碼, 參見 HTML encoder

2010年11月10日

Wordpress MU 的設定

程式名稱:WordPress MU
官方網站:http://mu.wordpress.org/
程式下載:按這裡
備註事項:從WordPress3.0起整合於WordPress,所以直接下載WordPress。
假設你己裝好 Apache, PHP5, mySQL
  註: 要開始設定 WP, 首先要連上的網址是:
       http://xx.xx.xx.xx/wp-admin/
       才會啟動以上的設定程序

1. 要先安裝 WP 的單人版 (可參見: 如何架設安裝WordPress部落格?)
2. 裝好後, 修改 WP 目錄中的 wp-config.php, 在以下
    /* That’s all, stop editing! Happy blogging. */
    的上方加入一行:
define('WP_ALLOW_MULTISITE', true);
請另在「/var/www/wp-content」目錄下新建一個資料夾「blogs.dir」並設定資料夾屬性為「777」,讓用戶可上傳檔案。

3. 重新整理部落格後台,點擊左方【工具】 (Tools)→「網誌網路」(Network),進入後請將網誌網路的標題和聯絡信箱設定好,並點擊﹝安裝﹞(Install)。
  重新安裝一次 WP 時, 要刪除原在在 mySQL 中已建好的 schema (資料庫), 再重新建 schema)

4.  在剛剛改過的 wp-config.php 中相同的位置, 加入以下:
即在這一行 define('WP_ALLOW_MULTISITE', true); 的下方, 加入
define( 'MULTISITE', true );
define( 'SUBDOMAIN_INSTALL', false ); $base = '/';
define( 'DOMAIN_CURRENT_SITE', 'xxx.xxx.xxx' );
define( 'PATH_CURRENT_SITE', '/' );
define( 'SITE_ID_CURRENT_SITE', 1 );
define( 'BLOG_ID_CURRENT_SITE', 1 );
 5. 在 wp-config.php 相同的子目錄下,新增一個 .htaccess 檔, 再貼上
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
# uploaded files
RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]
# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule  ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule  ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]
6. 這樣應該就可以啟動 Wordpress MU 了, 如果子網站無法連結, 應該是 Apache 的 rewrite 功能未開啟

7. 開啟 Apache 的 rewrite 功能
先啟動 rewrite 模組, 在終端機中下指令:
sudo a2enmod rewrite
(在 ubuntu 中, Apache 的預設安裝路徑是 /etc/apache)
然後修改 /etc/apache2/sites-available 中的 default 檔, 將其中的 AllowOverride NONE, 改成 AllowOverride All, 如下

         
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all

     
   

8. 重新啟動 apache, 在終端機中下指令

sudo /etc/init.d/apache2 restart
這樣應該就完成了!


==如果無法內建安裝外掛、佈景==
(試過 wp 4.2 on Mint 7)
在 wp-config.php 中的最後,加上幾行如下,即可啟動內建安裝:


if(is_admin()) {
add_filter('filesystem_method', create_function('$a', 'return "direct";' ));
define( 'FS_CHMOD_DIR', 0751 );
}


另見: Wordpress 的上傳檔案大小限制



參見:


=== see also ===
Re: Where is Apache installed on Ubuntu?
Apache config files are in /etc/apache
Apache log files are in /var/log/apache
Apache libs are in /usr/lib/apache
Other files can be in /usr/share/apache, /var/lib/apache

2010年7月11日

Ubuntu Enterprise Cloud, UEC

Eucalyptus Beginner’s Guide – UEC Edition

Chapter 1 – Introduction to UEC and its components


雲端運算安裝 Ubuntu Enterprise Cloud install

 

HAProxy 當 server load balancer 

硬體 Citrix / Alteon / Foundry 這些 SLB hardware device 

BalanceNG

Crossroads 

LVS 好像比較是 系統備援 (see http://www.ibm.com/developerworks/linux/library/l-linux-ha/index.html)

Virtualbox 網路的模式

source: http://www.dotblogs.com.tw/cyl1688/archive/2009/08/14/10055.aspx

VirtualBox 網路的模式,如下共5種(手冊上面寫的,但是用途為何?)

1.not attached (不使用網路卡)   
會出現網卡,但是沒有連接 

2.network address Translation(NAT)  預設值  
這是最簡單的方法連到外面的網路,這是單向,外部網路無法存取GUEST電腦(如果使用ultravnc 是否可以?), 一些限制:
  1. icmp ,ping 應該可以使用,但其它工具可能無法穩定工作
  2. UDP ,接收UDP傳播可能會不穩定
  3. 不支援GRE(pptp vpn)
  4. 無法將主機的連接埠轉向< 1024(這是保留給系統使用)
    整合在virtualbox 內的dhcp server會提供IP ,第一個卡 10.0.2.0,第二個卡10.0.3.0以此類推

3.bridged networking 橋接介面卡 
(可參見 VirtualBox 網路橋接(Bridge)模式 under Ubuntu 一文)
Guest會透過dhcp取得新內部的IP,因此會有兩個對外實體IP (使用一個設備驅動程式,過濾由實體的網卡來的資料,這個驅動程式已經完整被重寫,HOST 不再需要複雜的設定),  設定網路時要選擇bridge,並選取實體網卡  

4.internal networking    可以讓不同虛擬主機互通,好像接到同一個hub上,但是無法存取外部網路
  1. 安全:
  2. 速度:比bridged networking有效,因為它是直接傳送,不需要透過HOST作業系統的網路堆疊
    IP 要手動指定
5.僅限主機介面卡 (host-only networking) 
    這是2.2版新增的模式,不同的GUEST可以互通,也可以跟HOST互通
    可以想像混合 bridged 和 internal 網路模式,在 HOST 會建立一個軟體的網路卡, 如同虛擬機器連線到虛擬的網路, 只可以讓HOST和GUEST互通

  1. virtualbox host-only networking 要使用dhcp 不可以指定
  2. virtualbox ->檔案->偏好設定->網路->點選host-only networking 可以設定dhcp如上兩個host-only和GUEST會有相同網段的IP,就可以互通
  3. 這裏的dhcp伺服器不同於其它模式,它是獨立的,也只有在這裏才會可以關閉,並指定ip的範圍

2010年7月4日

xorg.conf

Section "Device"
Identifier "Configured Video Device"
Driver "vesa"
EndSection

Section "Monitor"
Identifier "Configured Monitor"
Vendorname "Generic LCD Display"
Modelname "LCD Panel 1024x768"
Horizsync 31.5-48.0
Vertrefresh 50-60
modeline "1024x768@60" 65.0 1024 1048 1184 1344 768 771 777 806 -vsync -hsync
EndSection

Section "Screen"
Identifier "Default Screen"
Monitor "Configured Monitor"
Device "Configured Video Device"
Defaultdepth 24
SubSection "Display"
Depth 24
Virtual 1024 768
Modes "1024x768@60" "800x600@60"
EndSubSection
EndSection

2010年7月3日

試用 ubuntu 10.04

今天用 virtualbox 3.1.2 在 ubuntu 9.10 下試用 ubuntu 10.4 版, 結果 ubuntu 10.04 系統開啟地很慢很慢...
後來將 virtualbox 換成 3.2.6 版, 問題才解決

ubuntu 10.04 視窗風格有很大的改變, 最不適應的是放大縮小鈕改成放在左上角 ...
要更改為放在右上角的話:
  1. 在終端機啟動 gconf-editor
  2. 點選 Apps > Metacity > General > Button Layout
  3. 把字串值改成:menu:minimize,maximize,close
    (原來的值是: close,minimize,maximize:)
ubuntu 10.04 這一版的預設中文輸入法仍是 iBus + 注音輸入法, 新增倉頡 3 代後, 發現輸入法會記住你上一次所挑選的字, 總算有些進步...

ubuntu 10.04 這一版預載可安裝的 gretl 是 1.8.7
gnuplot 是 4.2.6-1
要在圖形中正常顯示中文, 請參見
http://gretl.sourceforge.net/gnuplot_for_gretl.html
測試的 gretl script
open djclose
smpl 1988/01/04 1989/12/29
gf1 <- gnuplot djclose --time-series --output=display --with-lines
gf1.show

先裝上 gretl 1.8.7 之後, 再
https://sites.google.com/site/gretlforubuntu/home/gretl-deb
下載自行編譯的 gretl 1.9.1, 但無法執行:
 /usr/local/bin/gretl_x11/: error while loading shared libraries: liblapack.so.

用 
sudo aptitude install libfftw3-dev
sudo aptitude install liblapack-dev
之後再重裝 gretl 1.9.1 即可 (比上一版 9.10 的簡單一些)


最後, 固定寛度字形預設是 monospace, 但要改成 freemono, 或 Courier 10 pitch 顯示才會對齊... 


若執行 ARIMA 模型估計時, 出現 /usr/lib/gretl-gtk2/arma.so 找不到, 則建立連結:
sudo ln -s /usr/local/lib/gretl-gtk2/ /usr/lib/gretl-gtk2/

2010年6月10日

Drupal 架站筆記-雙語言網站

用 Views 來做一個顯示「最新消息」的區塊
http://riemann.math.nccu.edu.tw/forum/viewtopic.php?f=8&t=637
Views 的選項:
  • Basic Information:  View 的名稱
  • 頁面: 要做一個 page 時要用這一個。
  • 區塊: 區塊的設定。因為我們要做的是「最新消息」的區塊, 所以選用這一項。
  • Fields: 選擇要把 Node 的什麼部份顯示出來, 例如標題 (Title)。
  • Arguments: ...。
  • 過濾器: 沒有要把所有的 Nodes 顯示出來時, 要設一些條件。
  • Exposed Filters
  • Sort Criteria
相簿 show:  Dynamic display block模組
http://chenyuyi.mis.nchu.edu.tw/drupal-6.16/node/59

待確認:
區塊 (block) 的雙語模型 要用哪一個模組?

待試用的 modules


Better Formats
不同 role 指定不同輸入格式 (是否允許 HTML)
http://drupal.org/project/better_formats



Nice Menus
下拉 css 選單
http://drupal.org/project/nice_menus

2010年5月10日

ASP 中的 codepage

放在 *.asp 的第1行:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
936代表是簡體中文,而950代表繁體中文,65001就是 UTF-8 編碼了


若你的 *.asp 是 UTF-8 編碼, 則加入以下的程式碼在第1行, 就不會有亂碼了

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>

2010年4月23日

Regular Expression 語法

在很多程式中見到看起來很怪的語法, 中文稱為「正規表達式 」,例如
 
([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})
代表 yyyy-mm-dd 的日期格式, 或
 
a[0-9]*\.c
代表 a12.c,a932.c 等以 a 開頭, 以 .c 結尾, 中間只能是數字, 的所有字串
還滿聰明的一個做法
 
參見
特別要抓 unicode 中文的話, 看這裡

 
  它使用「/xxx/u」,在最後加上「u」,以這方式支援 UTF-8,
 
#!/usr/bin/php -q
$a = "def:123:這是:AB=你好!";
$pattern = 
'/123:([\x{4e00}-\x{9fff}]+):[A-B]*/u';
preg_match($pattern, 
$a,$match);
echo $match[0];
?> 
 
ASP 中使用:
例 1
Function RegExpTest(patrn, strng) 
   Dim regEx, retVal ' 建立變量。 
   Set regEx = New RegExp ' 建立正則表達式。 
   regEx.Pattern = patrn ' 設置模式。 
   regEx.IgnoreCase = False ' 設置是否區分大小寫。 
   retVal = regEx.Test(strng) ' 執行搜索測試。 
   If retVal Then 
      RegExpTest = "找到一個或多個匹配。" 
   Else 
      RegExpTest = "未找到匹配。" 
   End If 
End Function  
 
例 2
 
s1="This equation {x} + {y} = {x+y}
"
x=100
y=200
response.write "====>" & Var2Value(s1) & "
" 
function Var2Value(var_name)
   Var2Value = Txt2Value(var_name, 1)
end Function
function Txt2Value(str, level)
   dim regEx, Matches, Result
   Set regEx = new RegExp
   select case level
          case 0 regEx.Pattern = "\{([\w\(\)]+)\}" '變數名有效判斷
          case 1 regEx.Pattern = "\{([\w+\-\*/\\<>=\(\)]+)\}" '變數名及運算符號有效
          'case 2 regEx.Pattern = "\{([\w\s\(\)]+)\}" '除換行符外的所有字符有效
          case else exit function
   end select
   regEx.IgnoreCase = true
   regEx.Global = true
   Set Matches = regEx.Execute(str)
   Result = str
   'response.write Matches.Count
   For Each Match In Matches
      Result = Replace(Result, Match.Value, GetVar(Match.SubMatches(0)))
   Next
   set Matches = nothing
   set regEx = nothing
   Txt2Value = Result
end function

2010年3月1日

ubuntu 9.10 (Karmic) 下 firefox 的64 bit flashplugin 安裝

以下程式碼是從 http://the3mingheats.blogspot.com/2009/12/64bit-flash-player-on-linux.html?zx=a7531bec64ff2e02 抓來修改的
將以下程式碼複製後, 存成文字檔, 例如 install.sh
在終端機下指令, 讓此檔變成可執行
chmod +x install.sh
然後執行
./install.sh

Youtube 中文字有亂碼則參見這一篇: Ubuntu 8.10 AMD64 安裝了flash播放器,中文是亂碼

64 bit flash player for Firefox 可從此處下載: http://labs.adobe.com/downloads/flashplayer10_64bit.html

---beginning of the script---
echo "Stopping any Firefox that might be running"
sudo killall -9 firefox

echo "Removing any other flash plugin previously installed:"
sudo apt-get remove -y --purge flashplugin-nonfree gnash gnash-common mozilla-plugin-gnash swfdec-mozilla libflashsupport nspluginwrapper
sudo rm -f /usr/lib/mozilla/plugins/*flash*
sudo rm -f ~/.mozilla/plugins/*flash*
sudo rm -f /usr/lib/firefox/plugins/*flash*
sudo rm -f /usr/lib/firefox-addons/plugins/*flash*
sudo rm -rfd /usr/lib/nspluginwrapper

echo "Installing Flash Player 10"
cd ~
wget http://download.macromedia.com/pub/labs/flashplayer10/libflashplayer-10.0.45.2.linux-x86_64.so.tar.gz
 tar zxvf libflashplayer-10.0.45.2.linux-x86_64.so.tar.gz
sudo cp libflashplayer.so /usr/lib/mozilla/plugins/

echo "Linking the libraries so Firefox and apps depending on XULRunner (vuze, liferea, rsswol) can find it."
sudo ln -sf /usr/lib/mozilla/plugins/libflashplayer.so /usr/lib/firefox-addons/plugins/
sudo ln -sf /usr/lib/mozilla/plugins/libflashplayer.so /usr/lib/xulrunner-addons/plugins/

# now doing some cleaning up:
sudo rm -rf libflashplayer.so
sudo rm -rf libflashplayer-10.0.45.2.linux-x86_64.so.tar.gz
---end of the script---

2010年2月27日

在 ubuntu 下, 啟動第 2 個 X, 同時執行 linux 和 winXP

在 ubuntu 下, 啟動第 2 個 X, 同時執行 linux 和 winXP (in VirtualBox 全螢幕), 如此一來, 即像是在執行雙系統

1. 在 display:1 執行另一個 X, 再執行 xterm, (twm), VirtualBox
    X -display :1 &
    xterm -dsplay :1 &
    VirtualBox -display :1 &
2. 按 [Ctrl+Alt+F9] 切換到 display:1 (按 [Ctrl+Alt+F7] 可切回 display:0)
    在其中執行全視窗的 winXP in VirtualBox

若要執行全部 gnome 桌面的話, 下指令:
    startx -- :1 -bpp 32 -quiet &
事實上, 只要執行以下指令即可
    startx -- :1 &

ubuntu 9.10 無法休眠 (安裝時忘了建立 swap)

 安裝 ubuntu 9.10 時, 忘記分割 swap, 所以無法休眠, 修正方法如下:

1. (可利用 gparted) 重新分割 swap
2. ls -l /dev/disk/by-uuid/ 找出 swap 分割區的 uuid, 以便掛載
    或 sudo blkid
    /dev/sda6: UUID="08c5f7ed-1cf2-4bc5-9cea-7534dd554e3c" TYPE="swap"
3. sudo gedit /etc/fsatb 修改自動掛載的分區檔, 紅字部份請填入剛剛得到的uuid
    UUID=08c5f7ed-1cf2-4bc5-9cea-7534dd554e3c none swap  sw     0       0
4. 修改 (或新增)
sudo gedit /etc/initramfs-tools/conf.d/resume, 填入剛剛獲得的 UUID:
    RESUME=UUID=08c5f7ed-1cf2-4bc5-9cea-7534dd554e3c
5. 重建initrt檔 
    sudo update-initramfs -u
重新啟動後, 休眠功能回復了, 但喚醒後, 滑鼠不動 (還沒解決) 

2010年2月26日

ubuntu 自動登入後, 無線網路每次都必需輸入 keyring 密碼的不方便問題

不想每次自動登入 ubuntu 後, 還要輸入鑰匙圈的密碼 (keyring),可參考此網站的做法 (但可能不是很安全喔)

http://maketecheasier.com/auto-unlock-keyring-manager-in-ubuntu-intrepid/2009/03/14
應用程式->附屬應用程式->密碼及加密金鑰
然後在出現的視窗主選單中, 選 ->編輯->偏好設定, 按 [更改解鎖密碼] 鈕, 輸入原有密碼後, 不輸入新密碼 (就是留空白), 重新開機後, 應該就不用再輸入密碼了! Yeah!

2010年2月20日

在 ubuntu 下架設 VPN

很久以前試了一次沒成功能, 再次找到這一個架設 VPN 的說明, 有空試試
see: http://gsyan888.blogspot.com/2009/11/ubuntu-vpn-server.html

所需套件:pptpd
設定檔案:/etc/pptpd.conf , /etc/ppp/pptpd-options , /etc/ppp/chap-secrets

1. 安裝 pptpd
apt-get update
apt-get install pptpd
2. 修改 /etc/pptpd.conf
#server 端之 ip
localip 192.168.0.2
#要分配給 client 端之 ip
remoteip 192.168.0.11-20

指定當 client 連線成功以後分配 192.168.0.11 到 192.168.0.20 之間任一個 IP 給它,也可以用逗號分隔,一個個列表。

3.  修改 /etc/ppp/pptpd-options
這個檔案裡面,最重要的是兩項設定: name 和 ms-dns。
name 是定義在 /etc/ppp/chap-secrets 中第二個欄位(server name),因此兩邊要配合好,例如,下面是預設值:
name pptpd
依前述設定,在 /etc/ppp/chap-secrets 中就必須是下面的格式
xxxx pptpd xxxx 1.2.3.4
pptpd-options 中的另外一項要設的是 ms-dns ,它可以幫 client 端在連線成功以後指定 DNS,例如:
ms-dns 192.168.1.2
client 端連線成功以後會指定 192.168.1.2 為 DNS。對 Windows 的 clinet 來說,這項設定最多可以有兩行,因為 Windows 只能指定最多兩個 DNS。
此外,如果想幫 client 指定 WINS 則可以加入底下的設定:
ms-wins 192.168.1.3
上面的的設定可以幫 client 設定 WINS 到 192.168.1.3

4. 修改 /etc/ppp/chap-secrets
這個檔案主要是儲存 client 端進行 VPN 連線時的帳號、密碼資訊。例如:
username pptpd mypw *
上面的設定:
  • 帳號:username
  • 主機:pptpd (參考 /etc/ppp/pptpd-options 中的 name)
  • 密碼:mypw
最後一個欄位的星號  *  告訴 pptpd :不由這裡指定 client 連線時的 IP ,由 /etc/pptpd.conf 中的 remoteip 設定來分配。也就是採動態分配 IP (類似 DHCP),如果星號改成 IP ,那就是採固定 IP。


5. 啟動 pptpd
如果前面的步驟都完成,就可以啟動 pptpd !執行:
/etc/init.d/pptpd start
或是
/etc/init.d/pptpd restart

2010年2月19日

在ubuntu 將 virtualbox 裡網路設定靜態 IP

來源: http://waue0920.blogspot.com/2008/10/ubuntu-virtualbox.html
參考: https://help.ubuntu.com/community/VirtualBox#Networking
若要在virtualbox內的主機,設定為靜態或動態ip的上網模式, 我的router為 192.168.138.254,我ubuntu的主機網路位址為192.168.138.191,而在主機內的虛擬機器用dhcp的方式上網是完全沒有問題,但是想讓虛擬機器用同樣為192.168.138.xxx 的網址就需要額外設定了。
sudo apt-get install bridge-utils
sudo gedit /etc/network/interfaces
修改以下內容
auto eth0
iface eth0 inet manual
auto br0
iface br0 inet static
address 192.168.138.191
netmask 255.255.255.0
gateway 192.168.138.254
bridge_ports eth0 vbox0
auto lo
iface lo inet loopback
然後
sudo /etc/init.d/networking restart
sudo gedit /etc/vbox/interfaces
修改以下內容
# Each line should be of the format :
#
vbox0 waue br0
sudo /etc/init.d/vboxnet restart
sudo chown root:vboxusers /dev/net/tun
sudo chmod g+rw /dev/net/tun
gedit /etc/udev/rules.d/20-names.rules
將以下
KERNEL=="tun", NAME="net/%k"
改成
KERNEL=="tun", NAME="net/%k", GROUP="vboxusers", MODE="0660"
開啟virtualbox -> 設定值->網路->
附掛到:"主端介面"
介面名稱:"vbox0"

之後,開啟虛擬主機進入其作業系統之後,就可以設定其為靜態ip囉

compile gretl in ubuntu Karmic 9.10

先建一個子目錄, 例如 cvs,
進入後,  先下指令, 抓原始碼

cvs -d:pserver:anonymous@gretl.cvs.sourceforge.net:/cvsroot/gretl login
問密碼不用輸入, 直接按 [enter],
再輸入
cvs -z3 -d:pserver:anonymous@gretl.cvs.sourceforge.net:/cvsroot/gretl co -P gretl
如此會產生 ./cvs/gretl 子目錄, 以後更新原始碼時, 下指令
cvs update -d -P
就會自動更新了

在 ./configure 之後, 如果少了 zlib, 則需安裝
libzip-dev

2010年2月13日

grub2 的直接從 iso 檔開機功能 (boot from iso)

menuentry "Ubuntu Live 9.04 32bit" {
loopback loop /boot/isos/ubuntu9.04.iso
linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=/boot/isos/ubuntu9.04.iso --
initrd (loop)/casper/initrd.gz
}
menuentry "Ubuntu 8.10" {
set isofile="/boot/isos/ubuntu.iso"
loopback loop $isofile
linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=$isofile quiet splash noprompt --
initrd (loop)/casper/initrd.lz
}

2010年2月5日

遠端控制你的 ubuntu - vino, xrdp, ssh

1. 在 ubuntu 工作列 系統 -> 偏好設定 -> 遠端桌面 設定後, 即可利用 vnc 協定來連線
    在 client 端, 若是 ubuntu, 可用預裝的 網際網路-》遠端桌面檢視器
2. 如果習慣用終端伺服器用戶端 (連 windows 用的), 則要加裝 vnc4viewer, 或  xrdp
3. 用文字 ssh 介面登入的人,可以安裝 ssh server

用 vnc 連的缺點是一定要使用者在本地端登入了,才可檢視桌面, 旦重開機而無預設帳號登入,則無法使用VNCViewer檢視, 此時可改用 XDMCP

在終端伺服器用戶端下, XDMCP 預設是不能選的, 因為還要加安裝 xnest:
sudo apt-get install xnest

2010年2月4日

主機裝 virtualBox 2.0.4 OSE, 在 client 端中裝 Ubuntu 9.04, 螢幕解析度設定

參考: http://ok2.tw/blog/100
將以下 edit /etc/X11/xorg.conf 檔之內容改成以下, 即可用 1024x768 模式
Section "Device"
Identifier "VESA Framebuffer"
Driver "vesa"
#VideoRam 4096
# Insert Clocks lines here if appropriate
EndSection
Section "Monitor"
Identifier "My Monitor"
HorizSync 31.5 - 150.0
VertRefresh 75-85
EndSection
Section "Screen"
Identifier "Screen 1"
Device "VESA Framebuffer"
Monitor "My Monitor"
# If your card can handle it, a higher default color depth (like 24 or 32)
# is highly recommended.
# DefaultDepth 8
# DefaultDepth 16
DefaultDepth 24
# DefaultDepth 32
# "1024x768" is also a conservative usable default resolution. If you
# have a better monitor, feel free to try resolutions such as
# "1152x864", "1280x1024", "1600x1200", and "1800x1400" (or whatever your
# card/monitor can produce)
Subsection "Display"
Depth 8
Modes "1024x768" "800x600" "640x480"
EndSubsection
Subsection "Display"
Depth 16
Modes "1024x768" "800x600" "640x480"
EndSubsection
Subsection "Display"
Depth 24
Modes "1024x768" "800x600" "640x480"
EndSubsection
Subsection "Display"
Depth 32
Modes "1024x768" "800x600" "640x480"
EndSubsection
EndSection
Section "ServerLayout"
# The Identifier line must be present
Identifier "Simple Layout"
# Each Screen line specifies a Screen section name, and optionally
# the relative position of other screens. The four names after
# primary screen name are the screens to the top, bottom, left and right
# of the primary screen. In this example, screen 2 is located to the
# right of screen 1.
Screen "Screen 1"
EndSection

2010年2月1日

安裝 Acrobat Reader 在 Ubuntu 9.10 (karmic koala) AMD64

到這裡抓

http://archive.canonical.com/ubuntu/pool/partner/a/acroread/

或設套件來源
deb http://archive.canonical.com/ubuntu karmic partner

然後
sudo apt-get update
sudo apt-get install acroread

在 ubuntu 9.10 (AMD64) 裝 自行打包的 gretl 1.8.7 with aptitude

gretl-1.8.7 for ubuntu 9.10 (AMD64)
This deb file can be installed successfully on ubuntu 9.10 (Karmic) AMD64. But some actions should be done before gretl works.
1. Installing this deb on ubuntu 9.10 (AMD64) should have no problem.
2. After installing the deb, copy /usr/local/bin/libgrel*.* to /usr/bin (with sudo)
3. Install liblapack-dev with "sudo aptitude install liblapack-dev
    This is because synaptic and apt-get don't work for solving dependences issue.
OK, it is now to run gretl.

gretl_1.8.6-1_amd64.deb 這個是我在 ubutnu 8.10 AMD64 版本打包的, 還沒在其它電腦試過
安裝後發現
1. /usr/local/bin/gretl_x11: error while loading shared libraries: libgretl-1.0.so.0:
同上將 /usr/local/lib 下, libgretl-1.0.so.0 等 4 個以 libgretl* 開頭的檔, 全部複製到 /usr/lib

2. 發現有嚴重的 dependences 問題, google 後, 有人建議用 aptitude, 它會提出降級解決方案, 如下

xxx@xxx-desktop:~$ sudo aptitude install liblapack-dev
正在讀取套件清單... 完成
正在重建相依關係         
正在讀取狀態資料... 完成
初始化套件狀態... 完成    
正在編輯延伸狀態訊息... 完成
以下的套件狀態為毀斷
  libgfortran3
以下新套件將會安裝:
  libatlas-base-dev{a} libatlas-headers{a} libatlas3gf-base{a}
  libblas-dev{a} libblas3gf{a} liblapack-dev liblapack3gf{a}
0 個套件升級, 8 個新安裝, 0 個將移除且 0 個不會升級.
需要下載 22.9MB 的歸檔檔案. 解裝後將用去 91.3MB.
以下套件含有相依性:
  libgfortran3: 相依關係: gcc-4.4-base (= 4.4.1-4ubuntu8) 但 4.4.1-4ubuntu9 已安裝
以下動作會解決這些相依問題:

降級 下列套件:
cpp-4.4 [4.4.1-4ubuntu9 (now) -> 4.4.1-4ubuntu8 (karmic)]
gcc-4.4 [4.4.1-4ubuntu9 (now) -> 4.4.1-4ubuntu8 (karmic)]
gcc-4.4-base [4.4.1-4ubuntu9 (now) -> 4.4.1-4ubuntu8 (karmic)]
lib32gcc1 [1:4.4.1-4ubuntu9 (now) -> 1:4.4.1-4ubuntu8 (karmic)]
lib32stdc++6 [4.4.1-4ubuntu9 (now) -> 4.4.1-4ubuntu8 (karmic)]
libgcc1 [1:4.4.1-4ubuntu9 (now) -> 1:4.4.1-4ubuntu8 (karmic)]
libgomp1 [4.4.1-4ubuntu9 (now) -> 4.4.1-4ubuntu8 (karmic)]
libstdc++6 [4.4.1-4ubuntu9 (now) -> 4.4.1-4ubuntu8 (karmic)]

分數是 172

是否接受該解決方案?[Y/n/q/?] y


執行完畢後, 就可以正常跑了!
 

2010年1月25日

在不同 (虛擬) 桌面, 設不同的背景

這是在 http://qlj.sh.cn/linux/20090203/3d-background-img/ 看到的文章, 摘錄如下

執行 gconf-editor (不用 sudo), 在其中

apps–nautilus–preferences 在右邊的選項找到 show_desktop项,把它的勾選取消掉

0.7.4版:
在 Desktop 的 Desktop Cube 中 (所以要先設定 Cube) 的 Appearace下在background images 中, 依序增加多背圖片即可。
0.7.6版和0.7.8版:
在Utility(工具)裡的 Wallpaper選項下,新加 N 個圖片即可。


不過有人報告 ubuntu 8.10 的 nautilus 有 bug, 所以沒有這些選項 (我的 AMD86 8.10 即屬這種情況, 所以還沒有試)

see also: http://www.ubuntu-tw.org/modules/newbb/viewtopic.php?topic_id=14318&viewmode=compact&order=ASC&type=&mode=0&start=10

在 ubuntu 9.10 裝 自行打包的 gretl 1.8.6

同樣, 先下載 我自行打包的 gretl-1.8.6 for ubuntu 8.04
gretl_gretl-1.8.6-1_i386.deb

用 gdebi 安裝此 deb 檔 (應該顯示, 相依性已滿足), 然後下指令執行 gretl
/usr/local/bin$ cd ~
$ /usr/local/bin/gretl
/usr/local/bin/gretl_x11: error while loading shared libraries: libgretl-1.0.so.0: cannot open shared object file: No such file or directory

這個問題, 之前安裝在  ubuntu 8.04 時遇過, 解決方法是:

在 /usr/local/lib 下, 找到
libgretl-1.0.so.0 和其它 3 個以 libgretl* 開始的檔案, 都複製到 /usr/lib 

接著找不到 lapack.so.0
/usr/local/bin/gretl_x11: error while loading shared libraries: liblapack.so.3: cannot open shared object file: No such file or directory

應該是少了 lapack, 試著在 synaptic 裝 liblapack-dev,
之後用管理權限, 在 /usr/lib 下, 找到 liblapack.so, 複制成 liblapack.so.3
再用管理權限, 在 /usr/lib 下, 找到 libblas.so, 複制成 libblas.so.3

還久 libg2c.so.0, 但在 ubuntu 9.10 下找不到 libg2c-dev
先裝了 libgtk2.0-dev (它會自動安裝一大些 packages)
再裝 gfortran-4.4
都沒有用

直接將 libg2c.s0.0.0 下載至 /usr/lib, 再用 link 看能不能騙過去
再裝 libfftw3-3-dev
OK了! 自己打包的 gretl 可以在 ubuntu  (但別忘了裝 gunplot)

2010年1月23日

安裝 (非 compile) gretl 1.8.6 - 1.8.7 on ubuntu 8.04

先下載 我自行打包的 gretl-1.8.6 for ubuntu 8.04
gretl_gretl-1.8.6-1_i386.deb

用 gdebi 安裝此 deb 檔 (應該顯示, 相依性已滿足), 然後下指令執行 gretl

XXX@ubu804-desktop:~$ gretl
/usr/local/bin/gretl_x11: error while loading shared libraries: liblapack.so.3: cannot open shared object file: No such file or directory
用管理權限, 在 /usr/lib 下, 找到 liblapack.so, 複制成 liblapack.so.3 即可

XXX@ubu804-desktop:~$ gretl
/usr/local/bin/gretl_x11: error while loading shared libraries: libblas.so.3: cannot open shared object file: No such file or directory
用管理權限, 在 /usr/lib 下, 找到 libblas.so, 複制成 libblas.so.3 即可

XXX@ubu804-desktop:~$ gretl
/usr/local/bin/gretl_x11: error while loading shared libraries: libg2c.so.0: cannot open shared object file: No such file or directory
用 synaptic 安裝 libg2c-dev 套件即可

XXX@ubu804-desktop:~$ gretl
gretl window 終於出現了, 但是沒有選單, 一定是少了什麼
試安裝 libgtk2.0-dev (系統會自動安裝許多其它相關套件...), 之後仍然有相同的錯誤

再試移除原有的 gretl (1.8.0), 還是不行, 試了
sudo apt-get autoremove
之後, 有些必要的套不見了:
XXX@ubu804-desktop:~$ gretl
/usr/local/bin/gretl_x11: error while loading shared libraries: libgmp.so.3: cannot open shared object file: No such file or directory

XXX@ubu804-desktop:~$ sudo apt-get install libgmp3-dev
sudo apt-get install fftw3-dev

終於成功了

gretl 1.8.7 以後有問題的話, 試試
sudo aptitude install liblapack-dev

2010年1月22日

Ubuntu 8,04 下的 GJR-garchm for gretl 1.8.4

gertl 估計結果
? ret = garchm(r, 1, 2, l1, 1, 0, 0, 0, 0.7, 1, 1, null, null)

================================================================
   GJR-GARCH-in-Mean fucntion for gretl by Yi-Nung Yang
   Chung Yuan Christian University, Taiwan
   http://yaya.it.cycu.edu.tw/gretl
================================================================
The coefficient of GJR Term is gamma_i
Presample variance: backcast (parameter = 0.7)
Initial Values:
b1=-0.131806, omega=1.126780, alpha1=0.120000, alpha2=0.040000, gamma1=0.040000, beta1=0.600000,
-------    mean eq & variance eq in this GARCH model --------
   e= y -b1*X1
   h = omega +alpha1*(e(-1))^2+alpha2*(e(-2))^2+gamma1*(e(-1))^2*(e(-1)<0)+beta1*h(-1)
================================================================
Using numerical derivatives
Tolerance = 1.81899e-012
Function evaluations: 166
Evaluations of gradient: 39

Model 8: 最大概似法 (ML), using observations 3-1361 (T = 1359)
ll = -0.5*(log(2*pi)+log(h) + (e^2)/h)
Standard errors based on Outer Products matrix

              estimate    std. error   t-ratio    p-value
  --------------------------------------------------------
  b1         -0.0670351   0.0246001    -2.725    0.0064    ***
  omega       0.0101593   0.00146715    6.924    4.38e-012 ***
  alpha1     -0.0870361   0.0151949    -5.728    1.02e-08  ***
  alpha2      0.0597284   0.0162602     3.673    0.0002    ***
  gamma1      0.146400    0.0172923     8.466    2.53e-017 ***
  beta1       0.940360    0.00960635   97.89     0.0000    ***

Log-likelihood      -1772.480   Akaike criterion     3556.959
Schwarz criterion    3588.246   Hannan-Quinn         3568.673

Replaced list ret

Evniews 估計結果
Dependent Variable: R               
Method: ML - ARCH (Marquardt) - Normal distribution               
Date: 01/22/10   Time: 01:34               
Sample (adjusted): 1/06/2004 5/29/2009               
Included observations: 1359 after adjustments               
Estimation settings: tol= 0.00010, derivs=accurate numeric (linear)               
Initial Values: C(1)=-0.13181, C(2)=1.19673, C(3)=0.13333, C(4)=0.04444,               
        C(5)=0.04444, C(6)=0.53333               
Convergence achieved after 22 iterations               
Presample variance: backcast (parameter = 0.7)               
GARCH = C(2) + C(3)*RESID(-1)^2 + C(4)*RESID(-1)^2*(RESID(-1)<0) +               
        C(5)*RESID(-2)^2 + C(6)*GARCH(-1)               
               
    Coefficient    Std. Error    z-Statistic    Prob. 
               
R(-1)    -0.068286    0.024528    -2.784002    0.0054
               
    Variance Equation           
               
C    0.010315    0.001488    6.934109    0.0000
RESID(-1)^2    -0.086935    0.015597    -5.573912    0.0000
RESID(-1)^2*(RESID(-1)<0)    0.146578    0.017262    8.491349    0.0000
RESID(-2)^2    0.059067    0.016569    3.564933    0.0004
GARCH(-1)    0.940811    0.009581    98.19407    0.0000
               
R-squared    0.013200        Mean dependent var        -0.015854
Adjusted R-squared    0.009553        S.D. dependent var        1.330019
S.E. of regression    1.323651        Akaike info criterion        2.617407
Sum squared resid    2370.525        Schwarz criterion        2.640429
Log likelihood    -1772.528        Hannan-Quinn criter.        2.626026
Durbin-Watson stat    2.145564       

function list garchm (series depvar "Dep. var (應變數)", int GARCH[0:9:1] "GARCH p", int ARCH[1:9:1] "ARCH q", list indepvar[null] "Indpe var (自變數) list", int gjr_order[0:9:0] "GJR order (階次)", int option[0:3:0] "GRACH-in-Mean  (選項 0:none; 1:stdev; 2:h; 3:lnh)", int LB_Q[0:200:0] "Ljung-Box Q (殘差 Q 檢定階次)", int LB_Q2[0:200:0] "Ljung-Box Q2 (殘差 Q2 檢定階次)", scalar backcast[0:1:0.7] "backcasting (參數)", bool ShowInit[0] "Show Init. (顯示起始值)?", bool save_resid[0] "Save standardized residual and h (儲存殘差和 h)?", string res_name[null] "User-defined residual (自訂殘差名稱)", string ht_name[null] "User-defined h (自訂 h 名稱)")
  #================================================================
  #   GJR-GARCH-in-Mean fucntion for gretl by Yi-Nung Yang
  #   Chung Yuan Christian University, Taiwan
  #   http://yaya.it.cycu.edu.tw/gretl
  #================================================================
  set echo off
  set messages off
  # -------- variance equation -----------
  #       series h = omega + alpha*(e(-1))^2 + beta*h(-1)
  if ARCH=0
    funcerr "ARCH q 必須大於 0"
  else
    string v_eq = "h = omega "
    string arch_param = "omega "
    loop j=1..ARCH  --quiet
      sprintf arch_term "+alpha%d*(e(-%d))^2",j,j
      sprintf v_param "alpha%d ",j
      scalar @v_param = 0.04
      string v_eq = v_eq ~ arch_term
      string arch_param = arch_param ~ v_param
    endloop
    if gjr_order>0
      loop j=1..gjr_order  --quiet
        sprintf arch_term "+gamma%d*(e(-%d))^2*(e(-%d)<0)",j,j,j
        sprintf v_param "gamma%d ",j
        scalar @v_param = 0.05
        string v_eq = v_eq ~ arch_term
        string arch_param = arch_param ~ v_param
      endloop
    endif
    if GARCH>0
      loop j=1..GARCH  --quiet
        sprintf arch_term "+beta%d*h(-%d)",j,j
        sprintf v_param "beta%d ",j
        scalar @v_param = 0.04
        string v_eq = v_eq ~ arch_term
        string arch_param = arch_param ~ v_param
      endloop
    endif
  endif
  #   printf "%s\n", v_eq
  #   printf "%s\n", arch_param
  tL2 = indepvar
  tL3 = indepvar || const
  genr is_const = (tL2 = tL3)
  if is_const = 1
    tL2 -= const
  endif
  i=1
  loop foreach j tL2  --quiet
    string temp="x"
    sprintf temp "X%d",i
    #producing tmp%d independent variables
    genr @temp = tL2.$j
    i=i+1
  endloop
  scalar n_x = i-1
  scalar j=1
  # define ---------->  mean eq.
  if is_const = 1
    string m_eq = "e = y - b0 "
    string tParam = "b0 "
  else
    string m_eq = "e= y "
    string tParam = " "
  endif
  if n_x >=1
    loop j=1..n_x  --quiet
      sprintf tx "-b%d*X%d", j,j
      sprintf tparameter "b%d ", j
      scalar @tparameter = 0.0001
      string m_eq = m_eq ~ tx
      string tParam = tParam ~ tparameter
    endloop
  endif
  if option>0
    if option=1
      string m_eq = m_eq ~ "-theta*h^0.5"
      string tPremium="SQRT(h)"
    endif
    if option=2
      string m_eq = m_eq ~ "-theta*h"
      string tPremium="h"
    endif
    if option=3
      string m_eq = m_eq ~ "-theta*log(h)"
      string tPremium="ln(h)"
    endif
    if option>3
      funcerr "The GARCH-in-mean options are 1, 2, 3."
    endif
    string tParam = "theta " ~ tParam
  else
    string tPremium="None"
  endif
  #       printf "%s\n", m_eq
  #scalar backcast=0.7
  series y=depvar
  scalar mu = -0.037
  scalar alpha1 = 0.15 - 0.03*(ARCH>1)
  scalar beta1 = 0.6 - 0.12*(GARCH>1)
  scalar gamma1=0.05 - 0.01*(ARCH>1)
  ####  scalar theta =0.01879
  scalar b0=-0.00377
  scalar b1=0.5
  scalar b2=0.4
  #scalar omega = 1.149
  #scalar omega =var(y)*(1-alpha1-beta1)
  scalar omega =var(y)*backcast*0.91
  printf "\n\n\n\n"
  printf "================================================================\n"
  printf "   GJR-GARCH-in-Mean fucntion for gretl by Yi-Nung Yang\n"
  printf "   Chung Yuan Christian University, Taiwan\n"
  printf "   http://yaya.it.cycu.edu.tw/gretl\n"
  printf "================================================================\n"
  if gjr_order>0
    printf "The coefficient of GJR Term is gamma_i\n"
  endif
  if option>0
    printf "GARCH in mean Term is %s\n",tPremium
    printf "The coefficient of GARCH in mean Term is theta\n"
    printf "----------------------------------------------------------------\n"
  endif
  printf "Presample variance: backcast (parameter = %.1f)\n",backcast
  # obtaining intiatial values from OLS and printing intial values
  # -----------ols ty const
  # -----------printf "islist()=%d, nelem()=%d ===>\n",islist(indepvar) ,nelem(indepvar)
  if nelem(indepvar) > 0
    ols y indepvar --quiet
    # to keep the sample in use
    genr dum_original = $sample
    /*
    garch GARCH ARCH ; y indepvar
    if option=1
      series tInMean=$h^0.5
    elif option=2
      series tInMean=$h
    elif option=3
      series tInMean=log($h)
    endif
    */
    # ----- obtaining initial value for theta (nelem>0)
    if option > 0
      #garch GARCH ARCH ; y indepvar
      ols y indepvar --quiet
      if option=1
        series tInMean=($uhat^2)^0.5
      elif option=2
        series tInMean=($uhat^2)
      elif option=3
        series tInMean=log(($uhat^2))
      endif
      ols y indepvar --quiet
      #series tInMean=($uhat^2)^0.5
      ols y indepvar tInMean --quiet
      #ols y tInMean --quiet
      scalar theta= $coeff(tInMean)
    endif
    if ShowInit = 1  ### --- printing intial values
      printf "Initial Values:\n"
      if option >0
        printf "theta=%.6f, ",theta
      endif
    endif
    ols y indepvar --quiet
    if is_const = 1
      scalar b0=$coeff(const)
      if ShowInit = 1  ### --- printing intial values
        printf "b0=%.6f, ",b0
      endif
      matrix B=$coeff
      k=$ncoeff-1
      loop j=1..k --quiet
        scalar b$j = B[j+1]
        if ShowInit = 1  ### --- printing intial values
          printf "b%d=%.6f, ",j,b$j
        endif
      endloop
    else
      matrix B=$coeff
      k=$ncoeff
      loop j=1..k --quiet
        scalar b$j = B[j]
        if ShowInit = 1  ### --- printing intial values
          printf "b%d=%.6f, ",j,b$j
        endif
      endloop
    endif
  else   # ======================--------if nelem = 0
    ols y const --quiet
    # to keep the sample in use
    genr dum_original = $sample
    # ----- obtaining initial value for theta (nelem=0)
    if option > 0
      #garch GARCH ARCH ; y indepvar
      if option=1
        series tInMean=($uhat^2)^0.5
      elif option=2
        series tInMean=($uhat^2)
      elif option=3
        series tInMean=log(($uhat^2))
      endif
      ols y tInMean --quiet
      scalar theta= $coeff(tInMean)
    endif
    if ShowInit = 1  ### --- printing intial values
      printf "Initial Values:\n"
      if option >0
        printf "theta=%.6f, ",theta
      endif
    endif
  endif
  if ShowInit = 1  ### --- printing intial values
    printf "omega=%.6f, ",omega
    loop j=1..ARCH  --quiet
      printf "alpha%d=%.6f, ",j, alpha$j
    endloop
    if gjr_order>0
      loop j=1..gjr_order  --quiet
        printf "gamma%d=%.6f, ",j, gamma$j
      endloop
    endif
    if GARCH>0
      loop j=1..GARCH  --quiet
        printf "beta%d=%.6f, ",j, beta$j
      endloop
    endif
  endif
  string tAllParams = tParam ~ " " ~ arch_param
  # --- delete ---> printf "%s\n", tParam
  printf "\n-------    mean eq & variance eq in this GARCH model --------\n"
  printf "   %s\n",m_eq
  printf "   %s\n",v_eq
  printf "================================================================\n"
  scalar presample=0 ####y[1]/backcast  #see Eviews 6 Users guide, p.320 for algorithm
  loop j=2..100  --quiet
    presample = presample + backcast^(j-2)*y[j]^2
  endloop
  mle ll = -0.5*(log(2*pi)+log(h) + (e^2)/h)
    series h = backcast^($nobs)*var(y) + (1-backcast)*presample
    #####series h = backcast^($nobs)*var(y) + (1-backcast)*(y[2]^2+backcast*y[3]^2+backcast^2*y[4]^2+backcast^3*y[5]^2+backcast^4*y[6]^2+backcast^5*y[7]^2)
    #------------------------series e = y - theta*h^0.5
    series @m_eq
    #------------------------series e= y - b0 -b1*X1-b2*X2
    # ---> to be deleted -----> series h = omega + alpha*(e(-1))^2 + beta*h(-1)
    series @v_eq
    params @tAllParams
  end mle
  genr dum_in_mle = $sample
  ##### printf ">>>>>>>>>>>>>>>>>>sample size in MLE, nobs=%d, T=%d\n",$nobs, $T
  # 定義計算 estimated residuals 要取幾個落後期
  scalar start = $nobs-$T+1
  # --- to be deleted ---> printf "NOBS=%d  T=%d\n",$nobs,$T
  # ---- generating standardized residual and ht
  # ---- diagnosis of standardized residuals
  /*
  if LB_Q>0 && LB_Q2>0
    smpl full
    series h = backcast^($nobs)*var(y) + (1-backcast)*presample
    series e=0
    if option>0
      End=$T-1
      loop for j=1..End
        smpl j j
        genr @m_eq
        smpl +1 +1
        genr @v_eq
      endloop
      genr @m_eq
      smpl full
    else
      series @m_eq
      series @v_eq
    endif
    series stz_u=e/h^0.5
    series stz_u2 = stz_u^2
    corrgm stz_u  LB_Q  --quiet
    corrgm stz_u2 LB_Q2  --quiet
  endif
  */
  # ---- generating standardized residual (=e/h^0.5) and ht (=h)
  series h = backcast^($nobs)*var(y) + (1-backcast)*presample
  #series e=0
  if option>0
    End=$T-1
    loop for j=start..End --quiet
      smpl j j
      genr @m_eq
      smpl +1 +1
      genr @v_eq
    endloop
    genr @m_eq
    # 回復為原來的樣本
    smpl dum_original --dummy --replace
  else
    series @m_eq
    series @v_eq
  endif
  if isstring(res_name) =0
    sprintf res_name "stz_u" # default name for e(t)
  endif
  if isstring(ht_name) =0
    sprintf ht_name "h"   # default name for h(t)
  endif
  # 回復為原來的樣本
  smpl dum_original --dummy --replace
  series  @res_name =e/h^0.5
  series @ht_name=h
  if LB_Q >0
    corrgm @res_name  LB_Q  --quiet
  endif
  if LB_Q2>0
    series stz_u2=@res_name^2
    corrgm stz_u2 LB_Q2  --quiet
  endif
  if save_resid=1
    list retlist= @res_name @ht_name
    return retlist
  else
    list retlist = const
    return retlist
  endif
end function

2010年1月13日

裝 gretl 1.8.6 在 ubuntu 8.10 AMD64

好像缺了
lapack3
liblapack-dev_3.1.1-0.4ubuntu1_amd64.deb

要再試試這個
https://launchpad.net/ubuntu/intrepid/amd64/liblapack-dev/3.1.1-0.4ubuntu1

launchpad 套件庫
請在 /etc/apt/sources.list 加入以下兩行套件庫來源(或是透過 系統→管理→軟體來源 中的第三方軟體加入):


deb http://ppa.launchpad.net/lxde/ubuntu hardy main
deb-src http://ppa.launchpad.net/lxde/ubuntu hardy main
若您使用 Ubuntu 7.10 ,您只需要將以上兩行的 hardy 改成 gutsy。

              Ubuntu 8.10 (intredpid)
Debian:
http://packages.debian.org/squeeze/amd64/gretl/download

最後還是回到自行 compile, 但一直找不到 lapack3, 自已 compile lapack3, 一開始也不行, 後來不知道是裝了 gfortran, 還是 f2c 之後, 突然可以 compile, ./configure 之後, lapack 也有了... 莫名其妙就成功了! 打包起來 checkinstall 備用

========================================
configuring for gretl 1.8.6cvs (library version 0.0.56)
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking libintl.h usability... yes
checking libintl.h presence... yes
checking for libintl.h... yes
checking whether make sets $(MAKE)... yes
checking for a BSD-compatible install... /usr/bin/install -c
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking whether NLS is requested... yes
checking for msgfmt... /usr/bin/msgfmt
checking for gmsgfmt... /usr/bin/msgfmt
checking for xgettext... /usr/bin/xgettext
checking for msgmerge... /usr/bin/msgmerge
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking for ld used by GCC... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for shared library run path origin... done
checking for CFPreferencesCopyAppValue... no
checking for CFLocaleCopyCurrent... no
checking for GNU gettext in libc... yes
checking whether to use NLS... yes
checking where the gettext function comes from... libc
checking for gcc... (cached) gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for gcc option to accept ISO C89... (cached) none needed
checking for a BSD-compatible install... /usr/bin/install -c
checking for a sed that does not truncate output... /bin/sed
checking for fgrep... /bin/grep -F
checking for ld used by gcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1572864
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... yes
checking for /usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for ar... ar
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm -B output from gcc object... ok
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -fPIC -DPIC
checking if gcc PIC flag -fPIC -DPIC works... yes
checking if gcc static flag -static works... yes
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking for shl_load... no
checking for shl_load in -ldld... no
checking for dlopen... no
checking for dlopen in -ldl... yes
checking whether a program can dlopen itself... yes
checking whether a statically linked program can dlopen itself... no
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... no
checking whether ln -s works... yes
checking for sin in -lm... yes
checking for fopen in -lc... yes
checking for ANSI C header files... (cached) yes
checking for sys/wait.h that is POSIX.1 compatible... yes
checking for unistd.h... (cached) yes
checking dirent.h usability... yes
checking dirent.h presence... yes
checking for dirent.h... yes
checking fnmatch.h usability... yes
checking fnmatch.h presence... yes
checking for fnmatch.h... yes
checking byteswap.h usability... yes
checking byteswap.h presence... yes
checking for byteswap.h... yes
checking sys/times.h usability... yes
checking sys/times.h presence... yes
checking for sys/times.h... yes
checking for an ANSI C-conforming const... yes
checking for long double with more range or precision than double... yes
checking size of int... 4
checking return type of signal handlers... void
checking whether byte ordering is bigendian... no
checking netdb.h usability... yes
checking netdb.h presence... yes
checking for netdb.h... yes
checking sys/socket.h usability... yes
checking sys/socket.h presence... yes
checking for sys/socket.h... yes
checking for struct sockaddr_in... yes
checking for struct in_addr... yes
checking readline/readline.h usability... yes
checking readline/readline.h presence... yes
checking for readline/readline.h... yes
checking for tgetent in -lncurses... yes
checking for readline in -lreadline... yes
checking for rl_completion_matches in -lreadline... yes
checking for inet_addr in -lc... yes
checking for mmap... yes
checking for gzopen in -lz... yes
checking for GMP - version >= 4.0.1... yes
checking for MPFR - version >= 2.2.0... yes
checking for libgfortran... checking for _gfortran_abort in -lgfortran... yes
checking for LAPACK... yes
checking for dgejsv_ in -llapack... no
checking for gnuplot... yes
checking for PNG support in gnuplot... yes
checking for latex... yes
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for FFTW... yes
checking for GLIB... yes
checking for GTK... yes
checking for GTKPRINT... yes
checking for GTKSOURCEVIEW... no
version 2.0 not found
checking for GTKSOURCEVIEW... no
will use 1.8.5
checking for re_compile_pattern... yes
checking for re_compile_fastmap... yes
checking for re_search... yes
checking for re_match... yes
checking for GDK_PIXBUF... yes
checking for GNOME... no
no
checking for XML... yes
checking for RLIB... no
configure: creating ./config.status
config.status: creating Makefile
config.status: creating gretl_sh
config.status: creating gretl.pc
config.status: creating gui2/Makefile
config.status: creating gui2/debug
config.status: creating gui2/gtksourceview/Makefile
config.status: creating gnome/Makefile
config.status: creating gnome/gretl.keys
config.status: creating cli/Makefile
config.status: creating cli/debug
config.status: creating lib/Makefile
config.status: creating plugin/Makefile
config.status: creating po/Makefile.in
config.status: creating share/Makefile
config.status: creating share/bcih/Makefile
config.status: creating tests/Makefile
config.status: creating extra/Makefile
config.status: creating osx/Makefile
config.status: creating osx/fixlinks.sh
config.status: creating redhat/gretl.spec
config.status: creating config.h
config.status: config.h is unchanged
config.status: executing po-directories commands
config.status: creating po/POTFILES
config.status: creating po/Makefile
config.status: executing libtool commands

Configuration:

  Installation path:                      /usr/local
  Use readline library:                   yes
  Use gnuplot for graphs:                 yes
  Use PNG for gnuplot graphs:             yes
  Use LaTeX for typesetting output:       yes
  Gnu Multiple Precision support:         yes
  MPFR support:                           yes
  FFTW3 support:                          yes
  Build with GTK version:                 2.0
  Use GTK printing apparatus:             yes
  Use installed gtksourceview:            no
  Build with gnome support:               no
  Build gretl documentation:              no
  Use Lucida fonts:                       no
  Build message catalogs:                 yes
  Gnome installation prefix:              NA
  X-12-ARIMA support:                     yes
  TRAMO/SEATS support:                    yes
  libR support:                           no
  Ox support:                             no
  Experimental audio support:             no
  Experimental ODBC support:              no
  LAPACK libraries:
    -L/usr/lib -llapack -lblas -lgfortran

Now type 'make' to build gretl.

自行打包 deb for gretl 1.8.6 in ubuntu 8.04

上一則 PO 已成功 compile gretl-1.8.6, 我在想, 可以打包成 deb, 以便安裝在其它的 (ubuntu 8.04) 電腦嗎, google 之後, 發現有人討論, see 討論來源:


如果只是單純的從原始碼經過編譯之後,自己做成deb檔案自己用,應該不用這麼複雜的去宣告有的沒有的。

通常原始碼都有 autogen.sh 或者 configure 檔案可以執行設定系統資訊。執行之後如果有缺乏的套件,會顯示出來告訴你需要安裝。
只要沒有錯誤,就可以執行編譯了
編譯之前,請先安裝checkinstall這個套件
sudo apt-get install checkinstall

make clean # 預防萬一,先清除暫存檔案
make # 開始編譯

經過漫長的編譯過程,編譯完成之後,請執行

sudo checkinstall

會問你一些小問題,不知道就按enter過去就好。
這個程式會模擬安裝你所編譯好的軟體,並且將編譯好的檔案做成deb檔案。是個很方便很好用的軟體。
試試看吧!


最後顯示訊息:
**********************************************************************
 Done. The new package has been installed and saved to
 /home/yinung/gretl-1.8.6/gretl_1.8.6-1_i386.deb
 You can remove it from your system anytime using:
      dpkg -r gretl
**********************************************************************
 

待在其它電腦安裝看看囉!

/usr/local/bin$ cd ~
$ /usr/local/bin/gretl
/usr/local/bin/gretl_x11: error while loading shared libraries: libgretl-1.0.so.0: cannot open shared object file: No such file or directory

還是沒成功

在 /usr/local/lib 下, 找到
libgretl-1.0.so.0 和其它 3 個以 libgretl* 開始的檔案 (2個是 link 檔)
都複製到
/usr/lib

應該就 OK了

 

2010年1月12日

再次 try 安裝 gretl 1.8.6 on ubuntu 8.04

之前一直無法搞定 packages dependence 的問題, 在 gretl-user list 的建議下, 決定自行 compile

1. 先安裝基本 packages
sudo apt-get install gcc autoconf automake1.9 libtool flex bison gcc-doc
    以前找不到 libc6 和 libc6-dev 這次竟然會自動去找...


下列的【新】套件都將被安裝:
  autotools-dev cpp gcc-4.2-doc libc6 libc6-dev libc6-i686 linux-libc-dev m4
建議(Suggested)的套件:
  autoconf2.13 autobook autoconf-archive gnu-standards autoconf-doc
  automake1.9-doc bison-doc cpp-doc gcc-multilib manpages-dev glibc-doc gcj
  gfortran fortran95-compiler libtool-doc
推薦(Recommended)的套件:
  automaken libltdl3-dev
下列的【新】套件都將被安裝:
  autoconf automake1.9 autotools-dev bison flex gcc-4.2-doc gcc-doc libc6-dev
  libtool linux-libc-dev m4
下列的套件都將更新:
  cpp gcc libc6 libc6-i686
更新 4 個套件,新安裝 11 個套件,刪除 0 個套件,另不更新 503 個套件。
需要下載 13.5MB 的檔案。
After this operation, 29.9MB of additional disk space will be used.
繼續執行嗎? 是按 [Y] 鍵,否按 [n] 鍵 y


sudo apt-get install libgfortran1

下列的【新】套件都將被安裝:
  gcc-4.1-base
下列的【新】套件都將被安裝:
  gcc-4.1-base libgfortran1

sudo apt-get install libglib2.0-dev
讀取套件清單中... 完成
了解套件依存關係中      
Reading state information... 完成
下列的【新】套件都將被安裝:
  libglib2.0-0
建議(Suggested)的套件:
  libglib2.0-doc
推薦(Recommended)的套件:
  libglib2.0-data
下列的【新】套件都將被安裝:
  libglib2.0-dev
下列的套件都將更新:
  libglib2.0-0


 sudo apt-get install libpng12-dev

讀取套件清單中... 完成
了解套件依存關係中      
Reading state information... 完成
下列的【新】套件都將被安裝:
  libpng12-0 zlib1g-dev
下列的【新】套件都將被安裝:
  libpng12-dev zlib1g-dev
下列的套件都將更新:
  libpng12-0


sudo apt-get install libxslt1-dev
讀取套件清單中... 完成
了解套件依存關係中      
Reading state information... 完成
下列的【新】套件都將被安裝:
  libxml2 libxml2-dev libxslt1.1
下列的【新】套件都將被安裝:
  libxml2-dev libxslt1-dev
下列的套件都將更新:
  libxml2 libxslt1.1


 sudo apt-get install lapack3-dev
讀取套件清單中... 完成
了解套件依存關係中      
Reading state information... 完成
下列的【新】套件都將被安裝:
  cpp-3.4 g77 g77-3.4 gcc-3.4 gcc-3.4-base lapack3 libg2c0 libg2c0-dev
  refblas3 refblas3-dev
建議(Suggested)的套件:
  g77-doc g77-3.4-doc gcc-3.4-doc lib64gcc1 libc6-dev-amd64
下列的【新】套件都將被安裝:
  cpp-3.4 g77 g77-3.4 gcc-3.4 gcc-3.4-base lapack3 lapack3-dev libg2c0
  libg2c0-dev refblas3 refblas3-dev


sudo apt-get install fftw3-dev
讀取套件清單中... 完成
了解套件依存關係中      
Reading state information... 完成
注意,選擇了 libfftw3-dev 而非 fftw3-dev
下列的【新】套件都將被安裝:
  libfftw3-dev


sudo apt-get install libreadline5-dev
讀取套件清單中... 完成
了解套件依存關係中      
Reading state information... 完成
下列的【新】套件都將被安裝:
  libncurses5-dev
下列的【新】套件都將被安裝:
  libncurses5-dev libreadline5-dev


 sudo apt-get install libgmp3-dev
讀取套件清單中... 完成
了解套件依存關係中      
Reading state information... 完成
下列的【新】套件都將被安裝:
  libgmpxx4ldbl
建議(Suggested)的套件:
  libgmp3-doc libmpfr-dev
推薦(Recommended)的套件:
  libstdc++-dev
下列的【新】套件都將被安裝:
  libgmp3-dev libgmpxx4ldbl


sudo apt-get install gnuplot
讀取套件清單中... 完成
了解套件依存關係中      
Reading state information... 完成
下列的【新】套件都將被安裝:
  gnuplot-nox gnuplot-x11
建議(Suggested)的套件:
  gnuplot-doc
下列的【新】套件都將被安裝:
  gnuplot gnuplot-nox gnuplot-x11


sudo apt-get install texlive
讀取套件清單中... 完成
了解套件依存關係中      
Reading state information... 完成
下列的【新】套件都將被安裝:
  tex-common texlive-base texlive-base-bin texlive-common texlive-doc-base
  texlive-fonts-recommended texlive-latex-base texlive-latex-recommended
建議(Suggested)的套件:
  texlive-doc-en
推薦(Recommended)的套件:
  dvipdfmx lmodern perl-tk texlive-base-bin-doc texlive-fonts-recommended-doc
  tipa texlive-latex-base-doc latex-beamer latex-xcolor prosper
  texlive-latex-recommended-doc
下列的【新】套件都將被安裝:
  tex-common texlive texlive-base texlive-base-bin texlive-common
  texlive-doc-base texlive-fonts-recommended texlive-latex-base
  texlive-latex-recommended

缺的 packages:
libfortran1-dev  pkgconfig

sudo apt-get install libgtk2.0-dev
讀取套件清單中... 完成
了解套件依存關係中      
Reading state information... 完成
The following packages were automatically installed and are no longer required:
  libgfortran2 libblas3gf libmpfr1ldbl liblapack3gf
Use 'apt-get autoremove' to remove them.
下列的【新】套件都將被安裝:
  gtk2-engines-pixbuf libatk1.0-dev libcairo2 libcairo2-dev libexpat1-dev
  libfontconfig1-dev libfreetype6 libfreetype6-dev libgtk2.0-0 libice-dev
  libpango1.0-0 libpango1.0-common libpango1.0-dev libpixman-1-dev
  libpthread-stubs0 libpthread-stubs0-dev libsm-dev libx11-dev libxau-dev
  libxcb-xlib0-dev libxcb1-dev libxcomposite-dev libxcursor-dev libxdamage-dev
  libxdmcp-dev libxext-dev libxfixes-dev libxft-dev libxi-dev libxinerama-dev
  libxrandr-dev libxrender-dev x11proto-composite-dev x11proto-core-dev
  x11proto-damage-dev x11proto-fixes-dev x11proto-input-dev x11proto-kb-dev
  x11proto-randr-dev x11proto-render-dev x11proto-xext-dev
  x11proto-xinerama-dev xtrans-dev
建議(Suggested)的套件:
  libcairo2-doc libgtk2.0-doc ttf-arphic-bsmi00lp ttf-arphic-gbsn00lp
  ttf-arphic-gkai00mp ttf-baekmuk ttf-thryomanes libpango1.0-doc
下列的【新】套件都將被安裝:
  libatk1.0-dev libcairo2-dev libexpat1-dev libfontconfig1-dev
  libfreetype6-dev libgtk2.0-dev libice-dev libpango1.0-dev libpixman-1-dev
  libpthread-stubs0 libpthread-stubs0-dev libsm-dev libx11-dev libxau-dev
  libxcb-xlib0-dev libxcb1-dev libxcomposite-dev libxcursor-dev libxdamage-dev
  libxdmcp-dev libxext-dev libxfixes-dev libxft-dev libxi-dev libxinerama-dev
  libxrandr-dev libxrender-dev x11proto-composite-dev x11proto-core-dev
  x11proto-damage-dev x11proto-fixes-dev x11proto-input-dev x11proto-kb-dev
  x11proto-randr-dev x11proto-render-dev x11proto-xext-dev
  x11proto-xinerama-dev xtrans-dev
下列的套件都將更新:
  gtk2-engines-pixbuf libcairo2 libfreetype6 libgtk2.0-0 libpango1.0-0
  libpango1.0-common


2. ./configure (網友 Hélio Guilherme 建議先不要用 ./configure --enable-build-doc)
   這次果然成功了, 告訴我可以 "make" 了
3. make and sudo make install
   但發現在 /usr/local/bin 下, 只有 gretlcli 和 gretl-config, 並沒有 gui 介面的 gretl
   檢查後, 發現沒有 libgtk2.0-dev
   再次安裝
   sudo apt-get install libgtk2.0-dev
   再重覆步驟 2-3, 終於成功了!