2013年3月22日 星期五

How to Find a Yum Package

當要安裝一套library,可能不只要安裝64 bits版本,也需要安裝32 bits版本時,這個功能就很重要,可以查一下這套library的每種版本的名稱,以方便安裝。譬如說要安裝MyQL;

[root@]#yum search mysql

Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
 * base: mirror01.idc.hinet.net
 * extras: mirror01.idc.hinet.net
 * updates: ftp.riken.jp
=========================================== N/S Matched: mysql ===========================================
MySQL-python.x86_64 : An interface to MySQL
apr-util-mysql.x86_64 : APR utility library MySQL DBD driver
bacula-director-mysql.x86_64 : Bacula Director with MySQL database support
bacula-storage-mysql.x86_64 : MySQL Bacula storage daemon files
dovecot-mysql.x86_64 : MySQL back end for dovecot
freeradius-mysql.x86_64 : MySQL support for freeradius
libdbi-dbd-mysql.x86_64 : MySQL plugin for libdbi
mod_auth_mysql.x86_64 : Basic authentication for the Apache web server using a MySQL database
mysql.x86_64 : MySQL client programs and shared libraries
mysql-bench.x86_64 : MySQL benchmark scripts and data
mysql-connector-java.noarch : Official JDBC driver for MySQL
mysql-connector-odbc.x86_64 : ODBC driver for MySQL
mysql-devel.i686 : Files for development of MySQL applications
mysql-devel.x86_64 : Files for development of MySQL applications
mysql-embedded.i686 : MySQL as an embeddable library
mysql-embedded.x86_64 : MySQL as an embeddable library
mysql-embedded-devel.i686 : Development files for MySQL as an embeddable library
mysql-embedded-devel.x86_64 : Development files for MySQL as an embeddable library
mysql-libs.i686 : The shared libraries required for MySQL clients
mysql-libs.x86_64 : The shared libraries required for MySQL clients
mysql-server.x86_64 : The MySQL server and related files
mysql-test.x86_64 : The test suite distributed with MySQL
perl-DBD-MySQL.x86_64 : A MySQL interface for perl
php-mysql.x86_64 : A module for PHP applications that use MySQL databases
qt-mysql.i686 : MySQL driver for Qt's SQL classes
qt-mysql.x86_64 : MySQL driver for Qt's SQL classes
qt3-MySQL.i686 : MySQL drivers for Qt 3's SQL classes
qt3-MySQL.x86_64 : MySQL drivers for Qt 3's SQL classes
rsyslog-mysql.x86_64 : MySQL support for rsyslog

  Name and summary matches only, use "search all" for everything.

就可以獲得完整的資訊,接下來就可以選擇要安裝的版本啦!!!!

[root@]#yum -y install mysql-libs.i686

跨平台C++程式小筆記

  1. 前後關係的container,會傳回下一個有效的iterator
    std::vector
    std::deque
    std::list
    請用 i = abc.erase(i);

    不具備前後關係的container,則透過post operator來處理
    std::map
    std:multimap
    std::set
    std:: multiset
    abc.erase(i++);

    參考網址
    http://stackoverflow.com/questions/433164/what-happens-to-an-stl-iterator-after-erasing-it-in-vs-unix-linux
  2. 盡可能的專案底下的*.cpp*.h檔案,必須與.vcproj 檔案放在同一層,範例如下。

    D:\Project\aaa.vcproj
    D:\Project\aaa.h
    D:\Project\aaa.cpp

    不要再多一層目錄來存放*.h*.cpp
  3. gcc的compiler不認識將字串轉成寬字元的前導字元L,所以各位如何有需要將中文字寫進程式碼內的需求的話,請使用讀檔的方式。

    wchar_t wc = L’ ’; è error!!!!

CentOS 6.x上面安裝gcc 4.7

因為我的C++程式需要用到較新的gcc版本,所以就來研究一下怎麼從無到有的來安裝gcc4.7;雖然官方都有提供下載路徑,但是重點在於configure的設定,經過一番測試,只需要依序執行以下的指令,gcc 4.7就從下載到建置到安裝一口氣完成,缺點是必須要等待你的機器做完這些事情,反正是新裝機嘛~~就讓它跑一下吧!!!

64位元版
yum -y install glibc-devel.i686 glibc-devel
sudo yum install glibc-static libstdc++-static
wget http://ftp.gnu.org/gnu/gcc/gcc-4.7.0/gcc-4.7.0.tar.gz
tar xzf gcc-4.7.0.tar.gz
cd gcc-4.7.0
./contrib/download_prerequisites
cd ..
mkdir build_gcc4.7
cd build_gcc4.7
../gcc-4.7.0/configure --prefix=$HOME/.local --enable-languages=c,c++ --disable-multilib --enable-checking=release --enable-bootstrap  --build=x86-centos-linux 
make -j4
make install

32位元版
yum -y install glibc-devel.i686 glibc-devel
sudo yum install glibc-static libstdc++-static
wget http://ftp.gnu.org/gnu/gcc/gcc-4.7.0/gcc-4.7.0.tar.gz
tar xzf gcc-4.7.0.tar.gz 
cd gcc-4.7.0 
./contrib/download_prerequisites 
cd .. 
mkdir build_gcc4.7
cd build_gcc4.7
../gcc-4.7.0/configure --prefix=$HOME/.local --enable-languages=c,c++ --disable-multilib --enable-checking=release --enable-bootstrap --host=i686-linux-gnu --build=i686-linux-gnu
make -j4
make install

2013年3月7日 星期四

DOS指令 不需要寫死路徑

DOS指令 不需要寫死路徑

REM %CD%意指目前目錄
echo %CD%
REM %~dp0意指目前BATCH檔案的目錄
echo Script dir = %~dp0
REM %0意指目前BATCH檔案的目錄及檔名
echo Batch path = %0
REM %1意指目前的引數
echo User argument 1 = %1
Set ScriptDir=%~dp0
REM /D代表切換到那個磁碟機的目錄
CD /D %ScriptDir%