linux c
dreamcs
lnsjc321@126.com
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Linux C编程(2) 使用GDB调试入门
此例参考《Linux C从入门到精通》 一、示例程序 程序功能:输入年月日后,判断此日为此年中第几日。 文件名为year.c #include int main() { int day, month, year, sum, leap; printf("\nplease input year, month, day\n"); sca原创 2013-07-26 12:17:46 · 1075 阅读 · 0 评论 -
Linux C编程(1) HelloWorld
一、控制台命令流 在控制台中输入如下命令 mkdir learnc cd learnc vim hello.c gcc -o hi.exe hello.c 生成hi.exe文件 运行此程序 ./hi.exe 输出 hello linux! ./ 代表当前目录 hi.exe在当前目录下。 -o 指定了编译生成的程序名为 hi.exe。如果不指定,则程序的名默认为a.out。原创 2013-07-26 08:33:14 · 1940 阅读 · 0 评论 -
Linux C编程(3) 使用C语言函数读写文件
一、逐个字符读文件 1.源代码 #include int main() { FILE * fp; int i; char * path="./test.txt"; int ch; fp = fopen(path, "r"); if(fp == NULL)原创 2013-07-26 14:27:33 · 7561 阅读 · 0 评论 -
Linux C编程(5) 使用GCC参数定义宏
源代码如下 //main.cpp #include #ifdef _TEST2013 void PrintfInfo() { printf("Has Defined _TEST2013:Yes\n"); } #else void PrintfInfo() { printf("Has Defined _TEST2013:No\n"); } #endif int main() {原创 2013-09-13 09:14:52 · 1216 阅读 · 0 评论 -
Linux C编程(5) 线程同步实例
#include #include #include pthread_mutex_t mutlock; pthread_cond_t condt; bool bIsOver = true; void Init() { pthread_mutex_init(&mutlock,NULL); pthread_cond_init(&condt,NULL); bIsOver = true; }原创 2013-09-12 10:42:49 · 1116 阅读 · 0 评论 -
Linux C编程(4) 基本网络编程
一、得到主机名及其它基本信息 1.源代码 #include #include int main() { int res; struct utsname netInfo; res = uname(&netInfo); if(-1 == res) { print原创 2013-07-27 09:07:17 · 1310 阅读 · 0 评论 -
Linux C编程(7) 使用相对路径加载动态库-LD_LIBRARY_PATH
Linux C编程(7) 使用相对路径加载动态库-LD_LIBRARY_PATH在编译出可执行文件后,运行此可执行文件。运行时,链接器会在LD_LIBRARY_PATH下搜索库文件。例子: 源码见上篇博文。 编译命令如下:gcc testso.c -fPIC -shared -o libtest.so gcc main.c -o test -ltest -L./运行test,出现如下错误。./t原创 2016-08-06 16:22:34 · 3960 阅读 · 0 评论 -
Linux C编程(8) 使用相对路径加载动态库-rpath和$ORIGIN
商业程序如何加载自己的so 使用LD_LIBRARY_PATH的缺点是要实现设置LD_LIBRARY_PATH。不够自动化。那么大型的商业程序是如何加载自己的so呢。 这里以QtCreator为例。 QtCreator安装在/home/xxx/Qt5.3.1目录下。使用ldd查看qtcreator依赖的so。 rpath ORIGN原创 2016-08-06 20:05:30 · 15377 阅读 · 1 评论 -
Linux C编程(6) 使用动态库
生成动态库 文件名:TestSO.c #include "testso.h" #include #include void test_a() { printf("this is in test_a...\n"); } void test_b() { printf("this is in test_b...\n"); } vo原创 2014-01-26 18:37:59 · 1029 阅读 · 0 评论
分享