2011年11月7日星期一

zz eclipse运行C++控制台不输出结果的解决办法

解决方法:

Run Configurations -> Environment

Name
: PATH
Value : C:\MinGW\bin

在运行设置中增加 Path=C:\MinGW\bin
eclipse运行C++控制台不输出结果的解决办法

eclipse运行C++控制台不输出结果的解决办法

2011年11月4日星期五

ubuntu eclipse c++ cdt 安装

通过Eclipse的Help -> Install New Software进入安装插件界面;
首先,需要添加一个CDT的下载站点,填写CDT的下载地址:
p2 software repository: http://download.eclipse.org/tools/cdt/releases/indigo

之后在此站点安装CDT包即可。

2011年11月3日星期四

Linux下安装MPICH(转载)

Linux mpich2 安装

1:从MPICH2官网下载源代码,http://www.mcs.anl.gov/research/projects/mpich2 /downloads/tarballs/1.0.8/mpich2-1.0.8.tar.gz  目前最新的是1.0.8,当然如果你使用的windows平台也可以下载http://www.mcs.anl.gov/research /projects/mpich2/downloads/tarballs/1.0.8/mpich2-1.0.8-win-ia32.msi,以及 http://www.mcs.anl.gov/research/projects/mpich2/documentation/files/mpich2-1.0.8-windevguide.pdf 这是windows平台下的开发文档。
你也可以登录http://www.mcs.anl.gov/research/projects/mpich2/downloads/index.php?s=downloads,查看你需要的mpich版本,根据自己需要下载即可。
2、然后,将mpich2-1.0.8.tar.gz解压到/home/mpi/mpich2/src中,
执行下列命令:cd /home/mpi/mpich2/src
./configure -prefix=/home/mpi/mpich2(配置安装位置为 /home/mpi/mpich2)
如果没有问题,再运行下面
make
make install
稍等就大功造成了。
3、修改机器的~/.bash_profile(Ubuntu修改~/.bashrc)文件,在最后加上下面的语句
export MPI_ROOT=/home/mpi/mpich2
export PATH=$MPI_ROOT/bin:$PATH
export MANPATH=$MPI_ROOT/man:$MANPATH
4、编辑下面的文件,并存储为hello.c
#include "mpi.h"
#include <stdio.h>
#include <math.h>

int main (int argc, char **argv)
{
int myid, numprocs;
int namelen;
char processor_name[MPI_MAX_PROCESSOR_NAME];

MPI_Init
(&argc, &argv);
MPI_Comm_rank
(MPI_COMM_WORLD, &myid);
MPI_Comm_size
(MPI_COMM_WORLD, &numprocs);
MPI_Get_processor_name
(processor_name, &namelen);
fprintf (stderr, "Hello World! Process %d of %d on %s\n", myid, numprocs, processor_name);
MPI_Finalize
();
return 0;
}



5、接着编译一下

mpicc -o hello hello.c
C程序用 mpicc编译,C++程序用mpicxx编译)
6MPI应用一个管理器来管理运行MPI程序,这个管理器就是mpd,但是在正式开始运行mpd前还需要一个基于安全考虑的配置文件.mpd.conf,这个文件是要放在运行程序的用户的home目录下,本例子中就是/home/mpi/.mpd.conf,而且这个文件只能由这个用户读写,创建文件的命令是,
cd $HOME
touch .mpd.conf
chmod 600 .mpd.conf
然后在.mpd.conf文件中(如果没有这个文件需要创建一个)写入这么一行,secretword=******可以是任意的值,如果配置集群的话,这个值在参与计算的计算机上必需完全一致。如果是root用户的话,这个文件应该是/etc/mpd.conf

7、启动并行环境 mpdboot
第一次使用这个命令时,可能会出现错误,执行以下代码
cd

touch .mpd.conf                  //
这是修改mpd配置文件的时间戳
chmod 600 .mpd.conf          //
这是修改配置文件的权限

运行程序: mpirun -np 4 ./hello
-np
是指用几个进程模拟运行,这里用4
输出结果为:  (下面结果每台机器可能都不一样,是正常的)
Hello World! Process 1 of 4 on jack-laptop
Hello World! Process 3 of 4 on jack-laptop
Hello World! Process 2 of 4 on jack-laptop
Hello World! Process 0 of 4 on jack-laptop
想停止并行运行环境
mpdcleanup

8、如在第七步出现类似下面的报错
mpdroot: perror msg: Connection refused
mpdroot: cannot connect to local mpd at: /tmp/mpd2.console_root
probable cause: no mpd daemon on this machine
possible cause: unix socket /tmp/mpd2.console_root has been removed

请打开另外一个终端,并执行mpd命令,同时不要关闭这个终端,在执行第7步即可。

9、 如果你的os是Ubuntu的话,安装过程中如果提示缺少什么,首先安装这个东西之后再按照这个步骤即可。

2011年10月15日星期六

Ubuntu下eclipse快捷方式找不到JVM的问题 (转载:http://blog.csdn.net/seafit/article/details/5673629)

昨日通过vmware装上最新的Ubuntu系统,电脑配置比较高,所以跑起来速度还是很不错。接着装了TOMCAT,ANDROID,等等必须的开发软件。 不过期间eclipse的一个问题确实花了不少时间,记录一下解决方案。

1,下载JDK和ECLIPSE。
       下载就不用说了,去eclipse官网下一个伽利略的版本即可,JDK相信下载过WINDOWSjava的人都知道。  最好用1.5.0版的,网上说JDK1.6编译android会出问题,我没试过,为了少走弯路,吸取了前人经验。

        安装JDK方面也不用多说,网上资料太多了。这里记录几个细节问题。

        JDK路径: 基本上JDK装在任何地方都是可以的,把JAVA_HOME,classpath, path指对路径就可以了,我的安装如下。

         export JAVA_HOME=/usr/java/jdk1.5.0_22
         export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
         export PATH=$PATH:$JAVA_HOME/bin

          由于我是初学linux,对于linux的环境变量不知道如何设置,从网上的结果来看,我在/etc/bash.bashrc    和  /etc/environment里都加了以上三行。


2,安装eclipse.
          从网上来看,eclipse也是可以安装在任何地方的,我的安装在/opt/eclipse里。安装完成后,会在Applications->program里有一个快捷方式。这下问题就来了,点击这个快捷方式会报下面的错误。

A Java Runtime Environment (JRE) or Java Development Kit (JDK)
must be available in order to run Eclipse. No Java virtual machine
was found after searching the following locations:
/opt/eclipse/jre/bin/java
java in your current PATH

这个就本篇博客要记录的内容,因为这个简单的问题花了我很多时间。
从最后的解决办法来看,是因为桌面启动没有加载之前提到的三行环境变量。但是在控制台是可以通过命令行启动的。




解决办法是在终端进入你的eclipse目录,然后输入:

mkdir jre
cd jre
ln -s 你的JDK目录/bin bin




 

最后的解决办法如下:

在创建文件 /usr/bin/eclipse  内容如下
#!/bin/sh
export MOZILLA_FIVE_HOME=/usr/lib/mozilla/
export ECLIPSE_HOME=/opt/eclipse

export JAVA_HOME=/usr/java/jdk1.5.0_22
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin

$ECLIPSE_HOME/eclipse $*

然后编辑ECLIPSE的快捷方式
将command 变为 eclipse.

也可以自己写一个bash脚本,我放在了/userrun/eclipse.sh.   内容如下

#!/bin/sh
export GDK_NATIVE_WINDOWS=1
export ECLIPSE_HOME=/opt/eclipse
export JAVA_HOME=/usr/java/jdk1.5.0_22
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin

$ECLIPSE_HOME/eclipse $*

然后把快捷方式的command变为  /userrun/eclipse.sh  也可以实现快捷方式启动eclipase.


网上搜了很多资料,都是零碎的,每个人说几点,但都没有说全,很费解。 回头看看还是很简单的,环境变量设置对了就一切搞掂

ubuntu10 Realtek ID 270 无声

Step 1

If you are using Ubuntu 11.04 (Natty), then execute this command and reboot:
sudo add-apt-repository ppa:ubuntu-audio-dev/ppa; sudo apt-get update;sudo apt-get dist-upgrade; sudo apt-get install linux-sound-base alsa-base alsa-utils gdm ubuntu-desktop  linux-image-`uname -r` linux-alsa-driver-modules-$(uname -r) libasound2; sudo apt-get -y --reinstall install linux-sound-base alsa-base alsa-utils gdm ubuntu-desktop  linux-image-`uname -r` linux-alsa-driver-modules-$(uname -r)  libasound2; killall pulseaudio; rm -r ~/.pulse*
If you are using Ubuntu 10.10 (Maverick), then execute this command and reboot:
sudo add-apt-repository ppa:ubuntu-audio-dev/ppa; sudo add-apt-repository ppa:ricotz/unstable;  sudo apt-get update;sudo apt-get dist-upgrade; sudo apt-get install  linux-sound-base alsa-base alsa-utils gdm ubuntu-desktop  linux-image-`uname -r` linux-alsa-driver-modules-$(uname -r) libasound2; sudo apt-get --reinstall install  linux-sound-base alsa-base alsa-utils gdm ubuntu-desktop  linux-image-`uname -r` linux-alsa-driver-modules-$(uname -r) libasound2; killall pulseaudio; rm -r ~/.pulse*
If you are using Ubuntu 10.04 (Lucid), then execute this command and reboot:
sudo add-apt-repository ppa:ubuntu-audio-dev/ppa; sudo add-apt-repository ppa:team-iquik/alsa; sudo apt-get update; sudo apt-get dist-upgrade; sudo apt-get install linux-sound-base alsa-base alsa-utils gdm ubuntu-desktop linux-image-`uname -r` linux-alsa-driver-modules-$(uname -r) libasound2; sudo apt-get --reinstall install linux-sound-base alsa-base alsa-utils gdm ubuntu-desktop linux-image-`uname -r` linux-alsa-driver-modules-$(uname -r)  libasound2; killall pulseaudio; rm -r ~/.pulse*
If you are using Ubuntu 9.10 (Karmic), then you should upgrade to Ubuntu 10.04.2 LTS or newer versions. End of life date for Ubuntu 9.10 was April 2011.
If you upgraded ALSA using the command above and still do not have working sound after rebooting your PC again, then execute this command, reboot and retest sound using headphones and speakers:
cd; sudo apt-get update; sudo apt-get -y install build-essential ncurses-dev gettext xmlto libasound2-dev linux-headers-`uname -r` libncursesw5-dev; wget ftp://ftp.alsa-project.org/pub/driver/alsa-driver-1.0.24.tar.bz2; tar jxvf ./alsa-driver-1.0.24.tar.bz2; rm ./alsa-driver-1.0.24.tar.bz2; cd ./alsa-driver-1.0.24; sudo ./configure; sudo make; sudo make install; killall pulseaudio; cd; rm -r ~/.pulse*; rm ./alsa-driver-1.0.24

Step 2

In gnome-terminal, make sure that unlimited scrolling is enabled:
  • click on Edit > Profiles > "Default" profile > Scrolling. Choose "Unlimited" as scrolling option. Click Close and Close again.
If you are using the Gnome interface, open the Terminal console via "Applications->Accessories->Terminal"
If you are using the Unity interface, the easiest way to open the Terminal is to use the 'search' function on the dash. Or you can click on the 'More Apps' button, click on the 'See more results' by the installed section, and find it in that list of applications. A third way, available after you click on the 'More Apps' button, is to go to the search bar, and see that the far right end of it says 'All Applications'. You then click on that, and you'll see the full list. Then you can go to Accessories > Terminal after that.
So the methods in Unity are:
Dash > Search for Terminal
Dash > More Apps > 'See More Results' > Terminal
Dash > More Apps > Accessories > Terminal

Step 3

Reboot your computer. Then run the following 2 diagnostic commands.
Tip: If you have a wheel mouse or 3-button mouse, you do not need to type the commands into the Terminal. Instead, copy the commands from this web page and paste them into the terminal. To do this, move your mouse cursor over the start of the command written on the Web page. Then press the left mouse button and drag the mouse till the end of the command to highlight the whole command; then release the mouse button. Then press the middle mouse button or mouse wheel anywhere inside the Terminal. The command should now be printed in the Terminal without errors. Now press <Enter> to execute the command.
wget -O alsa-info.sh http://www.alsa-project.org/alsa-info.sh; chmod +x ./alsa-info.sh; ./alsa-info.sh
Post the full Terminal output after the script has actually run by creating a new question in launchpad then copy&paste the terminal output into your newly created question. Carefully inspect the Terminal output of the ALSA Information script that was generated by the previous diagnostic command
bash alsa-info.sh --stdout
After upgrading ALSA and rebooting the computer make sure that the ALSA driver version, library version and utilities version are all exactly the same version number.
The Terminal output after running the ALSA information script should contain something like this:
# ALSA Version
# Driver version: 1.0.24
# Library version: 1.0.24.1
# Utilities version: 1.0.24.2
If the Driver, Library and Utilities version numbers are not equal, this probably due to one of the following issues:
1. One of the ALSA components was not successfully upgraded during step 1 in this procedure
2. ALSA was correctly installed or upgraded, but a wrong / old kernel was booted instead of the most recent kernel version. In that case, boot the newest kernel version (that is available in the standard/default Ubuntu repositories) and then retest sound.
For example: if you installed or upgraded to Ubuntu 10.10 (Maverick Meerkat edition), make sure the running kernel version is 2.6.35-22-generic or higher. Or else sound will not work!
For example: if you installed or upgraded to Ubuntu 10.04 (Lucid Lynx edition), make sure the running kernel version is 2.6.32-21-generic or higher. Or else sound will not work!

Step 4

Copy & paste the following diagnostic command into the Linux Terminal, then press <Enter>. The command starts with the command cat and ends with the word sound. (Do not copy & paste this diagnostic command from an email message into the Terminal, as that will only copy part of the command.) When asked for your password, type your normal user password (no stars are given as you type); then press <Enter> again.
Tip: If you have a wheel mouse or 3-button mouse, you do not need to type the commands into the Terminal. Instead, copy the commands from this web page and paste them into the terminal. To do this, move your mouse cursor over the start of the command written on the Web page. Then press the left mouse button and drag the mouse till the end of the command to highlight the whole command; then release the mouse button. Then press the middle mouse button or mouse wheel anywhere inside the Terminal. The command should now be printed in the Terminal without errors. Now press <Enter> to execute the command.
cat /proc/asound/{version,cards,devices,hwdep,pcm,seq/clients}; sudo rm /etc/asound.conf; sudo rm -r ~/.pulse ~/.asound* ;sudo rm ~/.pulse-cookie; sudo apt-get update; sudo apt-get install aptitude; sudo aptitude install paman gnome-alsamixer libasound2-plugins padevchooser libsdl1.2debian-pulseaudio; sudo lshw -short;ls -lart /dev/snd;  cat /dev/sndstat; lspci -nn;  sudo which alsactl; sudo fuser -v /dev/dsp /dev/snd/* ; dpkg -S bin/slmodemd; dmesg | egrep 'EMU|probe|emu|ALSA|alsa|ac97|udi|snd|ound|irmware'; sudo /etc/init.d/sl-modem-daemon status; sudo grep model /etc/modprobe.d/* ; sudo dmidecode|egrep 'anufact|roduct|erial|elease'; lsmod | egrep 'snd|usb|midi|udio'; aplay -l; sudo lshw -C sound

 

Your ALSA output shows several issues:
Step A)
WARNING: All config files need .conf: /etc/modprobe.d/alsa-base, it will be ignored in a future release.
WARNING: All config files need .conf: /etc/modprobe.d/options, it will be ignored in a future release.
 Please run the following commands to delete those invalid ALSA configuration files:
sudo rm /etc/modprobe.d/alsa-base
sudo rm /etc/modprobe.d/options
Only the following configuration file is the right one to use in Ubuntu 10.04 and should NOT be deleted:
/etc/modprobe.d/alsa-base.conf
Step B)
!!ALSA Version
!!------------
Driver version: 1.0.21
Library version: 1.0.22
Utilities version: 1.0.22
Your ALSA driver, library and utilities versions are not equal and not fully up-to-date.
Please execute the following procedure to upgrade ALSA to version 1.0.23:
http://monespaceperso.org/blog-en/2010/05/02/upgrade-alsa-1-0-23-on-ubuntu-lucid-lynx-10-04/
Step C)
!!Modprobe options (Sound related)
!!--------------------------------
snd-pcsp: index=-2
snd-hda-intel: model=m51va
!!HDA-Intel Codec information
!!---------------------------
--startcollapse--
Codec: Realtek ID 270
The model option you selected to use in /etc/modprobe.d/alsa-base.conf does not correspond with the Codec version that the ALSA driver detected. Codec: Realtek ID 270 means that your ALSA driver is unable to identify precisely which Codec and mixer type is linked to your soundcard. This is another reason to upgrade ALSA to a newer version. Hopefully, the newer ALSA driver can correctly identify the Codec.
So there is no good reason YET to set a model option in the /etc/modprobe.d/alsa-base.conf file.
Run the following command:
gksudo gedit /etc/modprobe.d/alsa-base.conf
In the /etc/modprobe.d/alsa-base.conf file, REMOVE the following line, if it exists:
options snd-hda-intel model=m51va
Then save the change to the file.
After executing steps A, B and C, please reboot and retest sound.

 

 

 

ubuntu 开机自动运行 命令

cd /etc
sudo gedit rc.local
在其中加入命令 最后要以 exit 0 结束

2011年10月14日星期五

安装Ubuntu Fcitx (转载)

安装Ubuntu Fcitx
  1. sudo apt-get install im-switch fcitx   
  2. sudo im-switch -s fcitx -z default  
  3. im-switch -s fcitx -z default #修改当前用户的默认输入法, 具体看man im-switch 
Ubuntu Fcitx完成设置最好重启一下X,输入法就生效了.如果发现软件界面字体是方块,gedit ~/.fcitx/config或gksu gedit /usr/share/fcitx/data/tables.conf打开配置文件修改一下字体就OK.可以使用fc-list来查看已安装的字体。如果 配置文件出现乱码,使用gedit --encoding gbk XXX #打开配置文件。
Ubuntu Fcitx 字体列表: xlsfonts或 fc-list (取=前面)
某些情况下可能,在安装了fcitx输入法以后可能会出现和SCIM并存的问题,只要用im-switch把默认输入法改成fcitx就可以了:
  1. sudo im-switch -a fcitx  
  2. im-switch -a fcitx 




Ubuntu Linux 10.04自带的输入法不是很好用,linux下的输入法和windows下的比起来还是有很大差距的,相对来说比较好的输入法我看还是fcitx还不 错,不过在Ubuntu下通过“sudo apt-get install fcitx”命令安装之后会出现方块的乱码。那是因为fcitx安装后默认的中文显示字体设置错误。
fcitx的配置文件 是~/.fcitx/config
但是直接用 gedit ~/.fcitx/config 打开配置文件显示的也都是乱码,解决办法就是指定编码方式打开“sudo gedit --encoding gbk ~/.fcitx/config” Ubuntu默认的编码方式是UTF-8格式,因此需要通过gbk方式来打开该文件。
[程序]
显示字体(中)=*
显示字体(中)=*
显示字体 (英)=Courier New
显示字体(英)=Courier New
显 示字体大小=12
主窗口字体大小=9
字体区域=zh_CN.UTF-8
使用AA字体=1
使用粗体=1
使用托盘图 标=1
需要将第一行配置改成
“显示字体(中)=AR PL ShanHeiSun Uni”
注销之后,fcitx正常工作。