eclipse使用

Eclipse中添加多行注释的快捷键

# for c
apt-get install eclipse-cdt

https://packages.debian.org/wheezy/eclipse-cdt

第一种 //注释
选择你要注释的那一行或多行代码,按 Ctrl+/ 即可,取消注释也是选中之后按 Ctrl+/ 即可。此快捷键是 //注释 而不是 /**/注释。

第二种 /**/注释

Ctrl+Shift+/
说明:添加/* */注释

Ctrl+Shift+\
说明:消除/* */注释

要修改在eclispe中的命令的快捷键方式我们只需进入windows -> preference -> General -> key设置就行了

eclipse 使用

Why does Eclipse Luna 4.4 crash on kali with Oracle JDK8 64bit?–cannot register existing type `GdkDisplayManager'

evan@evankali:~/program/new-eclipse$ ./eclipse

(java:23844): GLib-GObject-WARNING **: cannot register existing type `GdkDisplayManager’

(java:23844): GLib-CRITICAL **: g_once_init_leave: assertion `result != 0′ failed

(java:23844): GLib-GObject-CRITICAL **: g_object_new: assertion `G_TYPE_IS_OBJECT (object_type)’ failed

(java:23844): GLib-GObject-WARNING **: invalid (NULL) pointer instance

(java:23844): GLib-GObject-CRITICAL **: g_signal_connect_data: assertion `G_TYPE_CHECK_INSTANCE (instance)’ failed

(java:23844): GLib-GObject-WARNING **: invalid (NULL) pointer instance

(java:23844): GLib-GObject-CRITICAL **: g_signal_connect_data: assertion `G_TYPE_CHECK_INSTANCE (instance)’ failed

(java:23844): GLib-GObject-WARNING **: cannot register existing type `GdkDisplay’

(java:23844): GLib-CRITICAL **: g_once_init_leave: assertion `result != 0′ failed

(java:23844): GLib-GObject-CRITICAL **: g_type_register_static: assertion `parent_type > 0′ failed

(java:23844): GLib-CRITICAL **: g_once_init_leave: assertion `result != 0′ failed

(java:23844): GLib-GObject-CRITICAL **: g_object_new: assertion `G_TYPE_IS_OBJECT (object_type)’ failed
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x00007ffe598f773f, pid=23844, tid=140730770458368
#
# JRE version: Java(TM) SE Runtime Environment (7.0_76-b13) (build 1.7.0_76-b13)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (24.76-b04 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# C [libgdk-x11-2.0.so.0+0x5173f] gdk_display_open+0x3f
#
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try “ulimit -c unlimited” before starting Java again
#
# An error report file with more information is saved as:
# /home/evan/program/new-eclipse/hs_err_pid23844.log
#
# If you would like to submit a bug report, please visit:
# http://bugreport.java.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
evan@evankali:~/program/new-eclipse$ export SWT_GTK3=0
evan@evankali:~/program/new-eclipse$ ./eclipse

sudo ln -s /home/evan/program/luna-eclipse/eclipse /usr/bin/eclipse

sudo cp firefox-mozilla-build.desktop eclipse.desktop

evan@evankali:/usr/share/applications$ cat eclipse.desktop
[Desktop Entry]
Encoding=UTF-8
Name=eclipse
GenericName=IDE
Comment=IDE
Exec=/home/evan/program/luna-eclipse/run-eclipse
Icon=/home/evan/program/luna-eclipse/icon.xpm
Terminal=false
X-MultipleArgs=false
StartupWMClass=Firefox
Type=Application
Categories=Network;WebBrowser;
MimeType=text/html;text/xml;application/xhtml+xml;application/xml;application/rss+xml;application/rdf+xml;image/gif;image/jpeg;image/png;x-scheme-handler/http;x-scheme-handler/https;x-scheme-handler/ftp;x-scheme-handler/chrome;video/webm;application/x-xpinstall;

wc.c

/*
* wc.c
*
* Created on: 2015年5月8日
* Author: evan
*/

#include

#define IN 1 // 在单词内
#define OUT 0 // 在单词外

main()
{
int c; nl, nw , nc , state;
state = OUT;
nl = nw = nc = 0;
/* 循环进行统计 */
while((c = getchar() !=EOF))
{
/* 统计字符 */
++nc;
/* 统计行数 */
if(c=='/n')
++nl;
/* 统计单词 */
if(c == ''||c=='/n'||c=='/t')
state = OUT;
else if(state == OUT)
{
state = IN;
++nw;
}
}

printf("%d %d %d\n",nl,nw,nc);

/*
*其实我们上面程序还存在漏洞,比如无法统计一些符号分割的单词,比如", . ! ' ' "等等;另外,无法统计文件,这两个基本功能是又待加强,如果你又兴趣可以尝试。
* */
}

linux中安装eclipse

作为一个c fans 总是喜欢eclipse !在此 采用了下载二进制包的方法 适合各种版本 不管你是debain kali or centos gentoo

下载
可以直接apt

sudo apt install eclipse-cdt
https://packages.debian.org/sid/devel/eclipse-cdt

http://mirrors.neusoft.edu.cn/eclipse/technology/epp/downloads/release/neon/1a/eclipse-cpp-neon-1a-linux-gtk-x86_64.tar.gz

注意了 是本本才是 ,PC没有SSD 哈哈
考虑到ssd分区启动比较快,现在是
root@evankali:/opt/eclipse# pwd
/opt/eclipse

cat .bashrc
alias eclipse=/opt/eclipse/eclipse


再做启动器比较爽

[Desktop Entry]
Name=eclipse
Name[zh_CN]=eclipse IDE
GenericName=Integrated Development Environment
GenericName[zh_CN]=集成开发环境
Comment=Develop software in an integrated development environment
Comment[zh_CN]=在集成开发环境中开发软件
Encoding=UTF-8
Exec=/opt/eclipse/eclipse
Icon=/opt/eclipse/icon.xpm
Terminal=false
X-MultipleArgs=false
StartupWMClass=Firefox
Type=Application
Categories=GNOME;GTK;Development;IDE;
StartupNotify=true

语言包下载
打开
http://www.eclipse.org/babel/downloads.php

看到
Babel Language Pack Zips
Neon | Mars | Luna

点击进去 找到我们要的

http://download.eclipse.org/technology/babel/babel_language_packs/R0.14.0/neon/neon.php

Language: Chinese (Simplified)

wget -c http://mirrors.neusoft.edu.cn/eclipse/technology/babel/babel_language_packs/R0.14.0/neon/BabelLanguagePack-eclipse-zh_4.6.0.v20160813060001.zip

把你下载的zip文件解压,得到一个名为eclipse的文件夹,它里面包含两个文件夹:features和plugins,复制features和plugins到你的eclipse程序目录,覆盖原程序文件即可:

cp -a features/ ~/software/eclipse/
cp -a plugins/ ~/software/eclipse/

wget -c http://mirrors.tuna.tsinghua.edu.cn/eclipse//technology/epp/downloads/release/kepler/SR2/eclipse-cpp-kepler-SR2-linux-gtk-x86_64.tar.gz
tar xvf eclipse-cpp-kepler-SR2-linux-gtk-x86_64.tar.gz
cd eclipse; ./eclipse

evan@latop:~$ vim .bashrc
alias halt='sudo poweroff'
export LANG=zh_CN.utf8
alias vi=vim
alias ll='ls -l'
alias ifconfig='/sbin/ifconfig'
##加上这句 这个有时不好用
alias eclipse='/home/evan/program/eclipse/eclipse'

#全局启动eclipse 其它软件也是相似 因为
#evan@evankali:~$ echo $PATH
#/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games

sudo ln -s /home/evan/program/eclipse/eclipse /usr/bin/eclipse

当然也可以手动创建菜单选项

手动创建菜单选项

我是xmonad ,一般用synapse启动软件 ,所以有没有开始菜单什么的于我不是很重要

ps
Debian Linux Install Eclipse Java / C / C++ IDE
http://www.cyberciti.biz/faq/debina-linux-installing-eclipse-jdt-eclipse-cdt-packages/

pc icon
evan@evanpc:/usr/share/applications$ cat eclipse.desktop
[Desktop Entry]
Encoding=UTF-8
Name=eclipse
GenericName=eclipse
Comment=IDE
Exec=/home/evan/program/eclipse/eclipse
Icon=/home/evan/program/eclipse/icon.xpm
Terminal=false
X-MultipleArgs=false
StartupWMClass=Firefox
Type=Application
Categories=Network;WebBrowser;
MimeType=text/html;text/xml;application/xhtml+xml;application/xml;application/rss+xml;application/rdf+xml;image/gif;image/jpeg;image/png;x-scheme-handler/http;x-scheme-handler/https;x-scheme-handler/ftp;x-scheme-handler/chrome;video/webm;application/x-xpinstall;

rpm 打包入门举例

参考资源
http://vbird.dic.ksu.edu.tw/linux_basic/0520rpm_and_srpm_3.php
http://linux.vbird.org/linux_basic/0520source/main.tgz

第一 源码,并加上Makefile
wget http://linux.vbird.org/linux_basic/0520source/main.tgz
mkdir -p /usr/local/src/main-0.1
tar -zxvf main.tgz -C /usr/local/src/main-0.1
cd /usr/local/src/main-0.1/
tar -czvf main-0.1.tar.gz main-0.1

## add Makefile 要记得下载回来的main.tgz不包括这个文件哦 要加才行
vim Makefile
LIBS = -lm
OBJS = main.o haha.o sin_value.o cos_value.o
main: ${OBJS}
gcc -o main ${OBJS} ${LIBS}
clean:
rm -f main ${OBJS}
install:
install -m 755 main $(RPM_INSTALL_ROOT)/usr/local/bin/main
# 记得 gcc 与 rm 之前是使用 按键作出来的空白喔!

第二 源码放到 /usr/src/redhat/SOURCES 底下,并创建 *.spec 的配置
[root@c main-0.1]# cd ..
[root@c src]# tar -zcvf main-0.1.tar.gz main-0.1
# 此时会产生 main-0.1.tar.gz ,将他挪到 /usr/src/redhat/SOURCES 底下:
[root@c src]# cp main-0.1.tar.gz /usr/src/redhat/SOURCES

创建 *.spec 的配置档
[root@c ~]# cd /usr/src/redhat/SPECS
[root@c SPECS]# vim main.spec
Summary: calculate sin and cos value.
Name: main
Version: 0.1
Release: 1
License: GPL
Group: VBird's Home
#<==记得要写正确的 Tarball 档名喔! Source: main-0.1.tar.gz Url: http://linux.vbird.org Packager: VBird BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root %description This package will let you input your name and calculate sin cos value. %prep %setup -q %build make %install rm -rf %{buildroot} mkdir -p %{buildroot}/usr/local/bin make install RPM_INSTALL_ROOT=%{buildroot} %files /usr/local/bin/main %changelog * Wed Jul 01 2009 VBird Tsai 0.1
- build the program

第三编译成RPM AND SRPM
[root@c SPECS]# rpmbuild -ba main.spec
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.3469
+ umask 022
+ cd /usr/src/redhat/BUILD
+ LANG=C
+ export LANG
….(前面省略)….
Processing files: main-debuginfo-0.1-1
Requires(rpmlib): rpmlib(CompressedFileNames) <= 3.0.4-1 rpmlib(PayloadFilesHavePrefix) <= 4.0-1 Checking for unpackaged file(s): /usr/lib/rpm/check-files /var/tmp/main-0.1-1-root Wrote: /usr/src/redhat/SRPMS/main-0.1-1.src.rpm Wrote: /usr/src/redhat/RPMS/x86_64/main-0.1-1.x86_64.rpm Wrote: /usr/src/redhat/RPMS/x86_64/main-debuginfo-0.1-1.x86_64.rpm [root@c SPECS]# rpm -ivh /usr/src/redhat/RPMS/x86_64/main-0.1-1.x86_64.rpm [root@c SPECS]# rpm -ql main /usr/local/bin/main [root@c SPECS]# rpm -qi main Name : main Relocations: (not relocatable) Version : 0.1 Vendor: (none) Release : 1 Build Date: Wed 14 Aug 2013 09:10:47 AM CST Install Date: Wed 14 Aug 2013 09:11:32 AM CST Build Host: c.com Group : VBird's Home Source RPM: main-0.1-1.src.rpm Size : 5088 License: GPL Signature : (none) Packager : VBird URL : http://linux.vbird.org Summary : calculate sin and cos value. Description : This package will let you input your name and calculate sin cos value. SRPM 的编译命令 -ba/-bb rpmbuild -ba rp-pppoe.spec

故意利用break 的switch

/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
/*
* main.c
* Copyright (C) 2013 evan
*/

#include
void print_day(int day)
{
switch (day)
{
case 1:
case 2:
case 3:
case 4:
case 5:
printf ("Weekday n");
break;
case 6:
case 7:
printf ("Weekend n");
break;
default:
printf ("Illegal day numbern");
break;
}
}
int main()
{
print_day (2);
return (0);
}

eclipse 简单使用

第一 下载
因此ide 是java写的 , 所以我们先安装 jdk
emerge jdk
其实下面这个是安装了 dev-java/icedtea-bin,详情也可以看http://www.gentoo.org/doc/en/java.xml

http://www.eclipse.org/downloads/
下面的
Eclipse IDE for C/C++ Developers,

Linux 32 Bit or Linux 64 Bit 就你自己选择喽

下载后 解析到你喜欢的目录便可

第二 使用

screenshots 请看http://www.douban.com/photos/photo/1611544939/
新建 c–cproject—netst—empty project/hello world nasic

其它可能常常用到的小技巧
#eclipse 显示行号
Window — Prefences — General — Editors — Text Editors — show line numbers

eclipse修改编辑器字体
窗口——–>首选项 工作台—–>颜色和字体——–>基本—–>文本字体
点击更改
Window—>General—>Appearance—>Colors and Fonts —>Basic—>Text Font —>Edit/Change

**********************************
ubuntu eclipse 报 program g++ not found in path

安装了以后查看eclipse 的window–》preference–》c/c++–》 build –》 setting –》discovery–》CDT GCC Build in Complier Settings [Shared]
From: ${COMMAND} -E -P -v -dD “${INPUTS}”
改为
To: /usr/bin/${COMMAND} -E -P -v -dD “${INPUTS}” 之后就OK了。

http://blog.csdn.net/jiangxuchen/article/details/17954579

anjuta简单使用

下班后,没事看了一下c,想起以前学hellow c ,为什么 要用TC呢 原来这anjuta才是王道, 安装了再说

第一
emerge anjuta ##安装anjuta

第二 用 anjuta写第一个程序
在Anjuta中点击菜单,“文件”==>“新建”(不是新建(N))==>“4. 项目” ==>我在这里选择“通用” 点击“继续”==>“继续”

构建==>编译(shift+f9) 调试==> 运行(shift+f3) 就可以看到结果喽

##这里的提示让我们知道 /home/evan/test1/Debug/src/test就是可执行文件,再也不用 gcc main.c ; ./a.out 喽

/home/evan/test1/Debug/src/test
———————————————-
Hello klsworld