显示标签为“Linux”的博文。显示所有博文
显示标签为“Linux”的博文。显示所有博文

2015/10/26

Cross-compiling a C application using the Android NDK

没有评论:
1 download ndk
export NDK=~/Downloads/android-ndk-r10e

2 Set cross-compiler for x86 (emulator)
mac:
export NDK_TOOLCHAIN=${NDK}/toolchains/x86-4.8/prebuilt/darwin-x86_64/bin/i686-linux-android-
export NDK_SYSROOT=${NDK}/platforms/android-19/arch-x86

Set cros-compiler for arm (device)
export NDK_TOOLCHAIN=${NDK}/toolchains/arm-linux-androideabi-4.8/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-
export NDK_SYSROOT=${NDK}/platforms/android-19/arch-arm

3 compile
// hello-world.c
#include <stdio.h>
int main(void)
{
printf("Hello world cross compiled on Android!\n");
 return 0;
}

make CC=${NDK_TOOLCHAIN}gcc CFLAGS=--sysroot=${NDK_SYSROOT} hello-world

4 push to test
$ adb push hello-world /data/

$ adb shell

# /data/hello-world

Hello world cross compiled on Android!

reference:
https://yaapb.wordpress.com/2012/09/27/cross-compiling-a-c-application-using-the-android-ndk/

2015/10/21

Linux ELF 文件操作的一些工具

没有评论:
Linux ELF 文件操作的一些工具

1 file yourlib.so 识别文件格式

nm -g yourlib.so 列举目标文件中的符号,
默认输出这个文件中声明的任何函数和全局变量的名称
nm -g yourlib.so   列出所有 extern & exported symbols
nm -gC  yourlib.so    #for C++
nm -t d -l -S -v ./a.out
nm -Ca lib.so     显示所有symbols and function names
nm -D lib.so      # list symbols in the dynamic symbol table, which you can find its address by dlsym.

3 ldd yourlib.so 解析动态链接二进制文件所依赖的库文件
在OS X上,使用 otool -L yourlib.dylib 可实现类似的功能

4  objdump
Linux 自带, Mac OS 上类似为otool.
objdump -D   lib.so    #display assembler contents for all sections
objdump -tT /lib/i386-linux-gnu/libc.so.6 | grep fopen
objdump -Dslx  lib.so
objdump -x lib.so
objdump -TC lib.so

5 readelf
readelf -Ws libc.so 显示所有symbol tables
readelf -s lib.so 显示所有symbol tables
readelf -h  lib.so     # elf header
readelf -S lib.so      #sections

6 strings yourfile 用于提取文件中的字符串
strings —readix=x  yourfile     显示字符串在文件中位置
-a    扫描整个文件  
-e   也扫描Unicode字符

7   size
size /usr/sbin/httpd
Sample outputs:
   text       data        bss        dec        hex    filename
 314213      12376      13304     339893      52fb5    /usr/sbin/httpd
Where,
text - Actual machine instructions that your CPU going to execute. Linux allows to share this data.
data - All initialized variables (declarations) declared in a program (e.g., float salary=123.45;).
bss - The BSS consists of uninitialized data such as arrays that you have not set any values to or null pointers.

8 elfedit
Linux 自带, 可修改machine type, file type, osabi信息

9 hexdump -C  /bin/ls | more
linux command, 查看二进制信息

refer to:
http://www.tenouk.com/Module000linuxnm3.html

2015/06/11

Linux 32-bit和64-bit编译

没有评论:
Environment:
Ubuntu 14.04 64-bit desktop, as guest virtual machine in virtual box
Host: MacBook Pro

在64位机器上缺省编译或运行时查找的是64位程序,但如果编译32位程序通常会遇到一些问题,这里做一个说明。

Build  32-bit C/C++ program on 64-bit Linux


sudo apt-get install g++    #to build C++ source files
sudo apt-get install g++-multilib   #to build 32-bit executable on 64-bit Linux
g++ -m32 -g -o a.out file1.cpp file2.cpp   #specify 32-bit binary

Run 32-bit executable on 64-bit Linux
要运行32位legacy程序,则需要安装相应的32位库文件(ia32-libs)。
首先添加 i386 architecture,然后安装必要的32位库。
sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386
sudo ./file-name

以下步骤可能也需要:
sudo apt-get update
sudo apt-get install lib32z1 lib32ncurses5 lib32bz2-1.0


特别的,比如需要libgc library,则需指定i386类型下载:
sudo apt-get install libgc1c2            (for 32-bit linux)
sudo apt-get install libgc1c2:i386 
  (for 64-bit linux)

可以用命令 “file file_name”查看执行文件类型:
file-name: ELF 32-bit LSB  executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.8, not stripped

2015/01/02

为反编译Android应用设置Linux环境

没有评论:
Linux environment setup

ubuntu 14.04 64-bit virtual machine on virtual box
1. shared folder:   in virtual box setting, create two shared folder “Documents”, “Downloads” on mac os, set full r/w rights and permanent. then in unbuntu’s mnt directory you will see “sf_Downloads” and “sf_Documents” ( with AdditionIn package installed ).
2. however, you may need to run “sudo adduser fanghui vboxsf” to add yourself to vboxsf group, and restart ubuntu guest.


android apktool
http://ibotpeaches.github.io/Apktool/install/
1. Check java 1.7 installed or not
       $java -version
       $sudo apt-get install default-jre  (or openjdk-7-jre)


2. Download Linux wrapper script (https://raw.githubusercontent.com/iBotPeaches/Apktool/master/scripts/linux/apktool,  Right click, Save Link As apktool)

3. Download apktool-2 (https://bitbucket.org/iBotPeaches/apktool/downloads, find newest here)

4. Make sure you have the 32bit libraries (ia32-libs) downloaded and installed by your linux package manager, if you are on a 64bit unix system.
(This helps provide support for the 32bit native binary aapt, which is required by apktool)

5. Rename downloaded jar to apktool.jar

6. Move both files (apktool.jar & apktool) to /usr/local/bin (root needed)
Make sure both files are executable (chmod +x)

7. Try running apktool via cli
   example:   $apktool d flappy-bird.apk
  will unzip the file structure
  find “Fake Flappy birds on Android” on http://androidmalwaredump.blogspot.sg/


dex2jar
   download dex2jar from http://sourceforge.net/projects/dex2jar/files/
   extract to a folder
        $unzip -x dex2jar-2.0.zip  -d /home/your_folder
   convert apk to jar file  ( you might need chmod +x d2j* )
        $sh /home/your_folder/dex2jar-2.0/d2j-dex2jar.sh  flappy_bird.apk


jd-gui
    download from jd.benow.ca
  it is a jar file “jd-gui-1.1.0.jar", so run with
     $java -jar jd-gui-1.1.0.jar
 a gui will pop up.

jad
jad is a decompiler tool similar to jd-gui, except command line.
download from http://varaneckas.com/jad/
somehow i cannot run jad 1.5.8e for linux on intel, so i choose jad 1.5.8e for linux (statically linked) instead.


boomerang (not mature)
download boomerang-linux-alpha-0.3 from http://boomerang.sourceforge.net/download.php
it requires libgc. when I try to run the program, I get this error:
./boomerang: error while loading shared libraries: libgc.so.1: cannot open shared object file: No such file or directory

You need to install libgc, something like

sudo apt-get install libgc1c2
sudo apt-get install libgc1c2:i386 
  (for 64-bit linux)

boomerang also requires libexpat1
sudo apt-get install libexpat1:i386

ok.

====
Note: run 32-bit executable on 64-bit linux

use “file file_name” to view exe type.

file-name: ELF 32-bit LSB  executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.8, not stripped


firstly install ia32-libs.
sudo apt-get install ia32-libs
or
sudo apt-get update
sudo apt-get install lib32z1 lib32ncurses5 lib32bz2-1.0

or
To run 32bit executable file in a 64 bit multi-arch Ubuntu system, you have to add i386 architecture and also you have to install libc6:i386,libncurses5:i386,libstdc++6:i386 these three library packages.
sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386
sudo ./file-name

2014/12/01

Linux compiler warnings

没有评论:
When compiling C++ programs, gcc reports -Wwrite-strings warning.
xxx.cpp:344:5: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
Solution 1 (推荐):
     cast constant string from char * s = "constant string" to const char *s= "constant string".

Solution 2:
 you can also pass -Wno-write-strings to gcc which then suppresses this warning.

Solution 3:
#pragma GCC diagnostic ignored "-Wwrite-strings"    忽略警报
...
#pragma GCC diagnostic pop       重新打开警报


gcc reports -Wmultichar warning:
xxx.cpp:332:7: warning: multi-character character constant [-Wmultichar]
 #if (('1234' >> 24) == '1')     // little endian ?
       ^
这个是用宏判断机器是否little-endian/big-endian,一般主机都是little-endian.
Solution 1 (推荐):
Check endian-ness at run time:
 int IS_LITTLE_ENDIAN() {
  static const int NL_AT_END = 0x000A;
  return ((char*)(void*)&NL_AT_END)[0] == '\n';
 }

Solution 2:
pass -Wno-multichar  to gcc for suppressing this warning.

Further reading: http://zipcon.net/~swhite/docs/computers/languages/c_multi-char_const.html
 

2010/03/01

Update vbox guest additions

没有评论:
New VirtualBox 3.1.4
How to update VBox Guest(Ubuntu) Additions?

1. use Vbox install option in GUI to download file "VBoxGuestAdditions_3.1.4.iso". The file was put into "C:\Documents and Settings\Administrator\.VirtualBox", and hint to mount. It will be mount to "/media/cdrom"

2. go to this directory and run
sudo ./VBoxLinuxAdditions-x86.run
Before do this, you might want to run
sudo apt-get install build-essential linux-headers-generic

3. restart guest OS (virtual linux)

Note: If you already download a *.iso file, you can mount it manually in vbox media manager.

P.S.: vbox 3.1.4 still has an annoying problem "could not switch the monitor configuration... CRTC56"!

2009/11/29

Ubuntu下的PDF编辑工具

没有评论:
Pdftk是由Sid Steward写的一个PDF增强软件,也就是所谓的PDF Hacks。它可以合并/分割PDF文档、解开必要的输入密码、输出加密、给PDF文档加水印、从PDF文档中解出附件、将PDF文档变成一页等等,能够做到操作PDF文档的所有事情。

安装:
sudo apt-get install pdftk


其合并文档的具体用法为:

按照顺序合并多个文档成一个文档:
pdftk 1.pdf 2.pdf 3.pdf cat output 123.pdf

使用参数:
pdftk A=1.pdf B=2.pdf cat A B output 12.pdf

使用通配符:
pdftk *.pdf cat output combined.pdf

从几个文档中分割内容合并成一个文档:
pdftk A=one.pdf B=two.pdf cat A1-7 B1-5 A8 output combined.pdf

或者 (使用通配符):
pdftk *.pdf cat output combined.pdf

把多个PDF的不同页面组合成一个新的PDF文档
pdftk A=one.pdf B=two.pdf cat A1-7 B1-5 A8 output combined.pdf

旋转PDF第一页90度
pdftk in.pdf cat 1E 2-end output out.pdf

选择所有PDF页面180度:
pdftk in.pdf cat 1-endS output out.pdf

使用128强度加密PDF
pdftk mydoc.pdf output mydoc.128.pdf owner_pw foopass

同上,同时给PDF加上访问密码
pdftk mydoc.pdf output mydoc.128.pdf owner_pw foo user_pw baz

同上,但是运行打印:
pdftk mydoc.pdf output mydoc.128.pdf owner_pw foo user_pw baz allow printing

解密PDF文档:
pdftk secured.pdf input_pw foopass output unsecured.pdf

合并两个PDF文档,其中一个是加密的,但最终文档不加密:
pdftk A=secured.pdf mydoc.pdf input_pw A=foopass cat output combined.pdf

解压PDF流,以便文本编辑:
pdftk mydoc.pdf output mydoc.clear.pdf uncompress

修复PDF文档
pdftk broken.pdf output fixed.pdf

分解成单页
pdftk mydoc.pdf burst

报告PDF信息,输出到文本
pdftk mydoc.pdf dump_data output report.txt


Pdfedit

PDFedit可以让你整个的编辑PDF文档。你可以改变PDF的任意部分。功能可以使用脚本添加。
脚本可以使用其他外部编辑器,并且可以定制自己的脚本。

安装
sudo apt-get install pdfedit


GIMP

首先安装krita:
sudo apt-get install krita

打开GIMP,然后打开PDF文件。对于多页文件,编辑也非常容易,它会自动打开多个编辑窗口。编辑完成以后,存为XCF格式。用krita打开XCF文件,选择“File"->"Printe",选择打印成PDF文件,并且选择目标文件的保持位置。


pdfjam
pdf合并和分拆工具.
下载:http://umn.dl.sourceforge.net/sourceforge/pdfsam/pdfsam-0.7sr1-out.zip(使用basic版,加强版收费)

2009/11/07

Ubuntu: 自动登录无线网络

没有评论:
ubuntu 自动登录无线网络

每次登录后连接无线网络时,总提示 nm-applet "enter password for default keyring to unlock". 因为笔记本就一个人用,这个提示很烦人,即使密码设成和login密码一样也无济于事。

解决办法: 给 keyring manager 设置一个空密码。
Menu->Applications->Accessories->Password and Encryption keys-> Passwords Tab -> Passwords:login 点右键, Unlock and then change password to blank。虽然会有安全提示,不管它,选 "Use unsafe storage",OK


Refer to:
Auto-Unlock Keyring Manager In Ubuntu

2009/11/04

Ubuntu 9.10 中文输入法

没有评论:
Ubuntu 9.10 中文输入法


9.10自带的是ibus,到menu->system->preference->ibus preference中加入 “拼Chinese-PinYin"输入法,同时删掉"English-ispell",即只保留一个即可。最后需要重启。按"ctrl+space" to turn off 输入法。


scim 程序有,但以前集成的输入法在9.10中缺。如需要,可
sudo apt-get install scim
打开新立得软件管理器(Synaptic),单击“搜索”按钮,输入scim,搜索与SCIM相关得所有软件。找到pinyin模块,单击右键,选择“标记并安装”项,单击“应用”按钮。打开SCIM配置实用工具对相关选项进行配置,重启计算机。


建议: 以后不能当ubuntu early adopter,因为总有一些bug让人担心。比如Ubuntu 9.10 中input/output error的突然出现让我虚惊一场:以为自己的文件会丢失,虽然重启后恢复正常。

2009/06/30

Linux下用smbmount命令挂载Windows共享

没有评论:
在Windows操作系统之间,可以通过映射网络驱动器的方式,将某个共享目录映射成一个磁盘文件系统,在Linux下,可以通过smbmount命令来实现相似的功能,将Windows的某个共享目录挂载到Linux下的某个目录下。

Note: ubuntu GUI下的"connect to server"并未真正mount windows shared filesystem, so can not see any mounted directory in terminal.

Let's manually mount a windows share thru commands!


1. Install smbmount

sudo apt-get install smbfs


2. Create a mount point "~/Desktop/winxp" in Ubuntu

fanghui@vbox:~/Desktop$ mkdir winxp # 必须先创建目录 winxp


3. smbmount command.

语法:smbmount //IP地址/共享名 挂载点 -o username=xxx,password=yyy
For example:
挂载整个c$共享
$ sudo smbmount //155.69.148.204/c$ ~/Desktop/winxp -o username=xxx
Password:

挂载某个目录"fanghui"
$ sudo smbmount //155.69.148.204/fanghui ~/Desktop/winxp -o username=xxx,password=xxxxxx


现在用mount查看,会看到最末一行:
//155.69.148.204/fanghui on /home/fanghui/Desktop/winxp type cifs (rw,mand)

4. umount
$ sudo umount ~/Desktop/winxp


Refer to:
Accessing an SMB Share With Linux Machines

2009/06/20

ubuntu下比较文件

没有评论:
under terminal:
diff file1 file2
vimdiff file1 file2
gvimdiff file1 file2 (图形界面)

gparted: ubuntu下分区工具

没有评论:
本机在一个物理硬盘上装了两个操作系统:Ubuntu9.04 and Windows XP.分别在D:, C:。 一不小心ubuntu分区给少了,现需要重新划分其分区大小,而不影响windows系统。

________________________________________________________________________
|Windows NTFS _____________________| Ubuntu ext3_____ |Ubuntu swap|
________________________________________________________________________

使用 gparted 工具:

1. Get GParted and burn it into a CD.
2. Boot machine from this CD.
3. Delete ubuntu partition, and create new one
4. Reinstall Ubuntu system.

Note: Gparted 也可 resize, delete, and extend partitions.

2009/05/29

windows XP 下用virtual box安装 ubuntu

没有评论:
虚拟机软件 :
Virtualbox是一个十分小
巧的虚拟化 软件,开源免费,相当不错。而且基本功能都具备,个人使用完全没有问题。约20M。 2008年2月virtualbox原来的公司 innotek被sun收购。

VMware Workstation with ACE, 600多M的安装包,适合公司内使用,便于管理多个设备。

Virtual PC 为微软产品。

本文介绍如何在windows XP 下用virtual box安装 ubuntu9.04

1. 安装 virtual box, 运行
点击“new”按钮创建一个ubuntu虚拟机

2. 不着急运行虚拟机,先配置ISO虚拟光盘。点击“setting”,在“光驱”选项中勾选“分配光驱”,点虚拟光盘。打开,创建一个并指向硬盘上的文件(下载 ubuntu-9.04-desktop-i386.iso文件)。

3 运行该虚拟机。会提示安装,余下皆如直接安装ubuntu过程。在预留硬盘空间时,选择 动态调整大小,并使用整个“硬盘”。该操作不会覆盖windows host也不占用整个空间,虚拟机只是在你的windows下开辟了一个目录存放。

注意: right ctrl 为切换键, right ctrl + F 为全屏切换。

其他问题:
1. VirtualBox Ubuntu全屏 , 分辨率
2. 共享文件
解决办法:
点击vbox菜单 devices -> install guest additions (似乎无反应). 重启后会发现在Ubuntu桌面上多出一个vbox光盘图标,这张光盘默认被自动加载到了文件夹/media/cdrom0 (或 链接 /cdrom )。

进入命令行终端,输入:
cd /media/cdrom0
sudo ./VboxLinuxAdditions.run
开始安装工具包。安装完毕后会提示要重启Ubuntu。之后屏幕分辨率问题应该解决。 windows 与ubuntu之间共享可以简单处理如下: windows设置共享目录, ubuntu connects to server。 或
借助virtual box设置共享文件夹
重启完成后点击"设备(Devices)" -> 共享文件夹(Shared Folders)菜单,添加一个共享文件夹,选项Make Permanent是指该文件夹是否是持久的。共享名可以任取一个自己喜欢的,比如"flamingo",尽量使用英文名称。
挂载共享文件夹
重新进入虚拟Ubuntu,在命令行终端下输入:
sudo mkdir /mnt/shared
sudo mount -t vboxsf flamingo /mnt/shared
其中"flamingo"是之前创建的共享文件夹的名字。OK,现在Ubuntu和主机可以互传文件了。
假如您不想每一次都手动挂载,可以在/etc/fstab中添加一项
flamingo /mnt/shared vboxsf rw,gid=100,uid=1000,auto 0 0
这样就能够自动挂载了。
注意:
共享文件夹的名称千万不要和挂载点的名称相同。比如,上面的挂载点是/mnt/shared,如果共享文件夹的名字也是shared的话,在挂载的时候就会出现如下的错误信息(看http://www.virtualbox.org/ticket/2265):
/sbin/mount.vboxsf: mounting failed with the error: Protocol error
原因分析可以看《Tips on running Sun Virtualbox》的Shared Folder on a Linux Guest节。
卸载的话使用下面的命令:
sudo umount -f /mnt/shared

2009/05/12

Ubuntu 9.04: firefox中不能输入中文

没有评论:
问题: firefox上不能用 ctrl+空格 启动scim输入法

解决:
1. 找到firefox 3.0.10启动脚本位置 /usr/bin/firefox

2. 用vi或其他编辑器打开/usr/bin/firefox,在文件开头处加入如下红色内容:
MOZDIR=$HOME/.mozilla
LIBDIR=/usr/lib/firefox-3.0.3
APPVER=3.0
META_NAME=firefox
GDB=/usr/bin/gdb
DROPPED=abandoned

XMODIFIERS=@im=SCIM
GTK_IM_MODULE=scim-bridge
export XMODIFIERS GTK_IM_MODULE

2009/05/01

Install CGAL-python under Ubuntu 9.04

没有评论:
如何安装:

问题在于ubuntu 9.04 uses python 2.6 instead of python 2.5, which makes the previous build of cgal-python0.9.3 invalid. Need to rebuild cgal-python.

Since the newest CGAL version is 3.4, we upgrade it from 3.3.

--------------------------
install boost-python

still use libboost-python1.34.1. note that 1.37.0 does not make the cgal-python building correct. If 1.37.0 exists, remove from synatic.

sudo apt-get install libboost-python1.34.1
sudo apt-get install libboost-python-dev

-------------------------
install CGAL 3.4

1. download
http://gforge.inria.fr/frs/?group_id=52

2. sudo apt-get install cmake

3. follow the instruction of INSTALL under CGAL-3.4 directory
cmake .

4. make

5. sudo make install

------------------------

install cgal-python0.9.4 beta1 (the latest. I guess 0.9.3 is also OK.)


download the package, and do
export CPATH=/usr/include/python2.6:$CPATH
export LIBRARY_PATH=/usr/local/lib:$LIBRARY_PATH

python setup.py build
python setup.py install (possibly as root)

2009/03/20

Anjuta: C++ IDE for Ubuntu

没有评论:
Linux下C/C++工具推荐Anjuta

vi/vim, gedit 和emacs is simple

KDeveloper is based on KDE

Eclipse, 基于Java的IDE, 慢,耗内存

NetBeans , 基于Java

基于GTK/Glade的Anjuta集成开发环境(IDE)不错,体积小,速度快,有自动代码补全和提示功能. I feel even for python IDE, anjuta can beat eric-python!

1. Install anjuta directly by menu->Applications->add/remove->programming

2. 安装C/C++开发文档
在编程的过程中有时会记不得某个函数的用法,通常这时查man手册是比较快的,所以把这个manpages-dev软件包安装上。想要看某个函数的用法就man它。
执行安装命令: sudo apt-get install manpages-dev

manpage的索引由mandb命令管理,有时在安装了新的manpage文件后,可能需要更新一下索引才能看到man -k 和man -f这些函数。
执行命令:mandb -c

然后,就可以查看这些文档了。比如,fopen的:
man fopen

3. 写个Hello World 的C++程序
在Anjuta中新建Project。出现“应用程序向导”,点“前进”;工程类型选“C++”中的“Generic C++”,之后点“前进”;“前进”;工程选项(Project Options)中,全选“否”,再点“前进”,应用即可。点左侧“工程”按钮,点工程名“foobar-cpp”,双击“main.cc”打开它,可以看到,main() 函数已预先写好了。按下“Shift+F11”编译,再按“F3”运行(这两个快捷键对应菜单在“Build”菜单下。),Anjuta的更多功能等待发掘,点击“设置”》“Plugins”...

References:
[1] http://anjuta.org/apt
[2] http://forum.ubuntu.org.cn/viewtopic.php?t=79137

2009/02/13

Ubuntu 8.10下如何升级eric4-python到4.3.0

没有评论:
Ubuntu下的python IDE 软件:
gedit虽然已经很好了,可还是想要一个集成开发环境。ubuntu下的
Eric python IDE 似乎还行。
Stani's Python Editor: another choice 还行,但不能 create project.
PyPE : not good
vim 但没有集成环境
sudo apt-get install vim-full vim-python
最终选用 Eric Python Editor
升级ubuntu from 8.04 to 8.10后,发现eric-python 不再能 auto python code completion (出现提示窗口,但不能选择!)。

解决方案: 重新安装eric4-4.3.0

0. uninstall previous eric4.1.0 from synaptic

1. download eric4 package from http://eric-ide.python-projects.org/eric4-download.html

2. sudo apt-get install python-qt4-dev python-qscintilla2

3. cd to eric-package directory
sudo python install.py
若提示:
Please enter the name of the Qt data directory.
(That is the one containing the 'qsci' subdirectory.)
>>
输入 /usr/share/qt4

4. 运行.
目前ubuntu source 未包含最新eric版本,因此在terminal 执行eric4 (位于/usr/local/bin/eric4)

Note: 目前eric4.3在laptop上窗口显示有问题。

2009/02/06

安装Ubuntu 8.10 带来的问题

没有评论:
Ubuntu 8.10: firefox中flash无声音
解决: sudo apt-get install flashplugin-nonfree-extrasound

启动我的python程序,多了如下两个bugs. :-(

/usr/lib/python2.5/site-packages/pytz/__init__.py:29: UserWarning: Module _mysql was already imported from /var/lib/python-support/python2.5/_mysql.so, but /var/lib/python-support/python2.5 is being added to sys.path
from pkg_resources import resource_stream

import MySQLdb
import matplotlib
会出现 UserWarning, 但顺序
import matplotlib
import MySQLdb
则不会

解释: matplotlib may import mySQLdb and a warning message is issued if mySQLdb already is imported.
而 /usr/lib/python2.5/site-packages/pytz has to do with timezones. python-tz ( pytz: python time zone)

解决方法:
1。 简易。 调整 import 顺序.
2. or look into
/usr/lib/python2.5/site-packages/pytz/__init__.py:29
找到 pkg_resources.py, 修改该文件。
/usr/lib/python2.5/site-packages/pkg_resources.py, Line 2272:

From:
if fn and normalize_path(fn).startswith(loc):
To:
if fn and (fn.startswith(loc) or normalize_path(fn).startswith(loc)):

the warning goes away.




/usr/lib/python2.5/site-packages/pytz/__init__.py:29: UserWarning: Module dateutil was already imported from /var/lib/python-support/python2.5/dateutil/__init__.py, but /var/lib/python-support/python2.5 is being added to sys.path
from pkg_resources import resource_stream

这个好像与 旧的pyc文件没有 update有关,It may be caused by outdated *.pyc files. Can try (sudo python -c 'import dateutil') - that should regenerate
outdated *.pyc files. 第二个warning消失.


/usr/lib/python2.5/site-packages/CGAL/__init__.py:3: RuntimeWarning: Python C API version mismatch for module Kernel: This Python has API version 1013, module Kernel has version 1012.
from Kernel import *
/usr/lib/python2.5/site-packages/CGAL/__init__.py:4: RuntimeWarning: Python C API version mismatch for module Triangulations_2: This Python has API version 1013, module Triangulations_2 has version 1012.
from Triangulations_2 import *
/usr/lib/python2.5/site-packages/CGAL/__init__.py:5: RuntimeWarning: Python C API version mismatch for module Triangulations_3: This Python has API version 1013, module Triangulations_3 has version 1012.
from Triangulations_3 import *

这个与 CGAL 版本落后有关, 按 cgal-python version = 0.9.3 ,python=2.5 重新自己编译. OK. (参见 cgal-python安装)


当然 Ubuntu 8.10也带来一个pylab/matplotlib的好处: pylab绘图完成后会将控制权返回,因此可以在一个canvas上interactive plotting. 以前必须关闭canvas返回。

2008/03/01

Ubuntu: 安装 latex 排版软件

没有评论:

安装 latex 排版软件


I only install the basic tetex package.

sudo apt-get install tex-common tetex-base tetex-bin tetex-extra

Use latex sample.tex to create sample.dvi file
Use pdflatex sample.tex to create sample.pdf file

For editing, i use kile, gedit or vi. Someone says emacs is powerful, but i got used to.


Ubuntu: Xfig, TexMaker, Winefish Latex Editor, Dia diagram editor

一些关于latex编辑和office的工具软件:
Xfig
TexMaker
Winefish Latex Editor 感觉一般,界面帮助不大,不如TexMaker
Dia diagram editor
Kile 推荐


在此之前我用的是
gedit - text editor
gimp - image editor


1) KILE可能是世界上最强大的LaTeX编辑器(集成环境)了。
有很多高级功能:
自动补全latex命令
跳跃到出错地点
警告和badbox提示
代码折叠
......
但是Kile依赖kde的库,你要安装kdelib等东西来安装。

2) Texmaker 的作者原来就是kile的作者之一。功能和kile相近,但是弱了一点。没有上面提到的高级功能。


No spell checker in new kile

The spellchecker in KDE is managed via KControl. By default, it uses ispell. That's why ispell works but not aspell.
Solution 1: install ispell directly.
$sudo apt-get install ispell

Solution 2: use kcontrol to change spellchecker to aspell.
1) $ sudo apt-get install kcontrol
2) $ kcontrol
3) Select KDE Components > Spell Checker
4) Choose aspell as client (and utf-8 as encoding)

2008/02/07

Ubuntu: 中文输入及 scim

没有评论:
The complete solution:
1. Use Synaptic to remove scim-* completely.
2. Remove previously installed SCIM files/data using terminal:
sudo rm -rf /usr/bin/scim
sudo rm -rf /usr/local/bin/scim
sudo rm -rf /etc/scim
sudo rm ~/.scim
sudo rm /root/.scim
3. Reinstall SCIM through System - Administration - Language Support.
基本等同于
sudo apt-get install language-pack-gnome-zh language-pack-gnome-zh-base language-pack-zh language-pack-zh-base language-support-zh
sudo apt-get install scim scim-chinese scim-pinyin

4. If Pinyin not found in scim setup-> IMEngine, then download scim-pinyin, scim-tables,
./configure
make
sudo make install
奇怪的是 sudo apt-get install scim-pinyin 无法成功
5. 如安装之后在firefox和google的输入框还是无法敲中文。可以如下处理:
im-switch -s scim -z default #设置 scim 为缺省输入法
logout and login again. In order to achieve this, you may need to install:
im-switch scim-qtimm
6. 有可能会遇到修改文件名时不能输入,在firefox中不能光标跟随,在gaim,pidgin,amsn,emesene,eva,gtalk等聊天软件不能输入文字等等的问题.解决方法如下:
修改 /etc/X11/xinit/xinput.d/scim
改成这样:
#GTK_IM_MODULE=xim
#QT_IM_MODULE=xim
GTK_IM_MODULE=scim
QT_IM_MODULE=scim
重启动,应该可以了
========
附:查看缺省语言
locale
say en_US is the locale, then using command:
im-switch -z en_US -s scim # set scim default
另:
我现在从windows xp 主机向 ubuntu 机器上传文件,用的ssh ftp client。上传的中文文件名在ssh ftp client中正常,但在ubuntu 下用ls 显示依旧是乱码(view encoding already changed to chn in terminal)。如果用
ls *.pdf | grep pdf
则可正常显示。 可能是ssh不支持编码转换。
设置LC_ALL和其它属性:
sudo gedit /etc/environment
在编辑器里,将内容修改如下(默认使用中文界面):
LANGUAGE="zh_CN:zh:en_US:en"
LANG=zh_CN.UTF-8
英文界面,将内容修改如下:
LANGUAGE="en_US:en"
LANG=en_US.UTF-8
保存,关闭编辑器
ubuntu 8.04 scim problem
Ubuntu 升级到8.04后,在Kile编辑状态或终端时,有时键盘输入失灵(但箭头键还能用),需要转到其他窗口有一番动作后回来才能用。上网search了一下,觉得是scim的问题。将之关闭则问题消失,但有时又要输入中文,唉,麻烦。
解决方案 1: 换用 scim-bridge 改善 scim 在 Ubuntu 中的表现
经实验: scim-bridge 未解决问题. ;-(
scim-bridge作为客户端用socket和scim通讯, 是用 C 代替了 C++ 编写的,可以解决原来 scim 和 acroread / realplay / vmplayer 等包不兼容的问题。
sudo gedit /etc/X11/xinit/xinput.d/scim
将GTK_IM_MODULE=xim
改成GTK_IM_MODULE="scim-bridge"
然后Restart system. 或者手工启动
scim -d
解决方案 2:
im-switch -s scim -z default
修改 /etc/X11/xinit/xinput.d/scim
改成这样:
#GTK_IM_MODULE=xim
#QT_IM_MODULE=xim
GTK_IM_MODULE=scim
QT_IM_MODULE=scim
重启后可以. ;-)
but it does not work for eric4, a python editor.
scim is a very bad input method, always resulting deadkey.
scim configuration:
去掉“scim设置”的 “前端”->“全局设置”->“将预编辑字符串嵌入到客户窗口中” 前的勾,就一切OK了
Gtk -> remove "embeded input table"