易截截图软件、单文件、免安装、纯绿色、仅160KB

高级Linux程序设计第一章:入门

1、用GCC编译
1.1、创建源文件
(main.c) C 源文件 - main.c
#include
#include “reciprocal.hpp”
int main (int argc, char **argv)
{
    int i;
    i = atoi (argv[1]);
    printf (“The reciprocal of %d is %g\n”, i, reciprocal (i));
    return 0;
}
(reciprocal.cpp) C++ 源文件 - reciprocal.cpp
#include
#include “reciprocal.hpp”
double reciprocal (int i) {
    // I should be non-zero.
    assert (i != 0);
    return 1.0/i;
}
(reciprocal.hpp) 头文件 - reciprocal.hpp
#ifdef __cplusplus
    extern “C” {
#endif
    extern double reciprocal (int i);
#ifdef __cplusplus
    }
#endif
1.2、编译源文件
编译main.c:
% gcc -c main.c
编译reciprocal.cpp:
% g++ -c reciprocal.cpp
参数-I指定搜索头文件的位置。
默认情况下,GCC在当前文件夹及标准库的头文件所在的文件夹来搜索头文件。
% g++ -c -I ../include reciprocal.cpp
可以用参数-D在命令行设定宏(macro),并且可以设定宏的值
对于如下程序definemacro.c:
#include "stdio.h"
#include "stdlib.h"
int main(int argc, char** argv){
        int i = 3;
#ifdef CHANGEVALUE
        i = 4;
#endif
        printf("i = %d\n", i);
        printf("PT = %f\n", PI);
}
如果编译时命令行为gcc definemacro.c,会报‘PI’ undeclared错误。
如果编译时命令行为gcc -D PI=3.14 definemacro.c,则输出如下:
i = 3
PT = 3.140000
如果编译时命令行为gcc -D PI=3.14 -D CHANGEVALUE definemacro.c,则输出如下:
i = 4
PT = 3.140000
可以用GCC编译时优化代码.
% g++ -c -O2 reciprocal.cpp
1.3、链接对象文件
g++可以将.o对象文件链接成程序
% g++ -o reciprocal main.o reciprocal.o
如果想链接其他库文件,则用参数-I
例如欲链接库libpam.a,则用如下命令行,编译器会自动加上前缀lib和后缀.a
% g++ -o reciprocal mai


相关文档:

linux 的 source命令

source命令(从 C Shell 而来)是bash shell的内置命令。点命令,就是一个点符号,(从Bourne Shell而来)是source的另一名称。这两个命令都以一个脚本为参数,该脚本将作为当前shell的环境执行,即不会启动一个新的子进程。所有在脚本中设置的变量将成为当前Shell的一部分。同样的,当前脚本中设置的变量也将作为脚本的环境,s ......

知识小记(linux)

1)webmin
    Webmin是目前功能最强大的基于Web的Unix系统管理工具。管理员通过浏览器访问Webmin的各种管理功能并完成相应的管理动作。目前
Webmin支持绝大多数的Unix系统,这些系统除了各种版本的linux以外还包括:AIX、HPUX、Solaris、Unixware、Irix
和FreeBSD等。
    Webmin 让您能 ......

转载 今天为我的Godaddy Linux主机开通SSH

以前Godaddy的Linux的主机是不能开通SSH的,只有VDS、VPS、独立主机可以开通,前几天在后台上看到有了SSH这个功能,不过需要删除所有的数据库,才可以进行开通的步骤。强烈建议备份数据库及网站!!
删除数据库就不用说了~很简单。
步骤:进入空间管理面板,选择Settings选项卡下的SSH选项,如下图:
godaddyssh-thumb. ......

Linux Windows 共享文件


samba实现ubuntu跟windows文件共享
一. Samba 简介
Samba(SMB是其缩写) 是一个网络服务器,用于Linux和Windows共享文件之用;Samba 即可以用于Windows和Linux之间的共享文件,也一样用于Linux和Linux之间的共享文件;不过对于Linux和Linux之间共享文件有更好的网络文件系统NFS,NFS也是需要架设服务器的;
大家知 ......

Linux x86 Dropbear SSH <= 0.34 remote root exploit

/*
* /*
* Linux x86 Dropbear SSH <= 0.34 remote root exploit
* coded by live
*
* You'll need a hacked ssh client to try this out. I included a patch
* to openssh-3.6.p1 somewhere below this comment.
*
* The point is: the buffer being exploited is too small(25 bytes) to hold our
......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号