gnu

sed -i command for in-place editing to work with both GNU sed and BSD/OSX

耗尽温柔 提交于 2019-12-17 04:47:51
问题 I've got a makefile (developed for gmake on Linux) that I'm attempting to port to MacOS, but it seems like sed doesn't want to cooperate. What I do is use GCC to autogenerate dependency files, and then tweak them a bit using sed . The relevant portion of the makefile : $(OBJ_DIR)/%.d: $(SRC_DIR)/%.cpp $(CPPC) -MM -MD $< -o $@ sed -i 's|\(.*\)\.o:|$(OBJ_DIR)/\1.o $(OBJ_DIR)/\1.d $(TEST_OBJ_DIR)/\1_utest.o:|' $@ While this runs with no trouble under GNU/Linux, I get errors like the following

Increase stack size in Linux with setrlimit

丶灬走出姿态 提交于 2019-12-17 02:15:06
问题 reading information about how to increase stack size for a c++ application compiled with gnu, at compilation time, I understood that it can be done with setrlimit at the beginning of the program. Nevertheless I could not find any successful example on how to use it and in which part of the program apply it in order to get a 64M stack size for a c++ program, could anybody help me? Thanlks 回答1: Normally you would set the stack size early on, e,g, at the start of main() , before calling any

Increase stack size in Linux with setrlimit

ⅰ亾dé卋堺 提交于 2019-12-17 02:15:06
问题 reading information about how to increase stack size for a c++ application compiled with gnu, at compilation time, I understood that it can be done with setrlimit at the beginning of the program. Nevertheless I could not find any successful example on how to use it and in which part of the program apply it in order to get a 64M stack size for a c++ program, could anybody help me? Thanlks 回答1: Normally you would set the stack size early on, e,g, at the start of main() , before calling any

Change stack size for a C++ application in Linux during compilation with GNU compiler

本秂侑毒 提交于 2019-12-16 19:46:10
问题 In OSX during C++ program compilation with g++ I use LD_FLAGS= -Wl,-stack_size,0x100000000 but in SUSE Linux I constantly get errors like: x86_64-suse-linux/bin/ld: unrecognized option '--stack' and similar. I know that it is possible to use ulimit -s unlimited but this is not nice as not always can a single user do that. How can I increase the stack size in Linux with GCC for a single application? 回答1: You can set the stack size programmatically with setrlimit, e.g. #include <sys/resource.h>

C 环境设置

北城以北 提交于 2019-12-16 11:42:11
原文链接: https://www.runoob.com/cprogramming/c-environment-setup.html 本地环境设置 如果您想要设置 C 语言环境,您需要确保电脑上有以下两款可用的软件,文本编辑器和 C 编译器。 文本编辑器 这将用于输入您的程序。文本编辑器包括 Windows Notepad、OS Edit command、Brief、Epsilon、EMACS 和 vim/vi。 文本编辑器的名称和版本在不同的操作系统上可能会有所不同。例如,Notepad 通常用于 Windows 操作系统上,vim/vi 可用于 Windows 和 Linux/UNIX 操作系统上。 通过编辑器创建的文件通常称为源文件,源文件包含程序源代码。C 程序的源文件通常使用扩展名 " .c "。 在开始编程之前,请确保您有一个文本编辑器,且有足够的经验来编写一个计算机程序,然后把它保存在一个文件中,编译并执行它。 C 编译器 写在源文件中的源代码是人类可读的源。它需要"编译",转为机器语言,这样 CPU 可以按给定指令执行程序。 C 语言编译器用于把源代码编译成最终的可执行程序。这里假设您已经对编程语言编译器有基本的了解了。 最常用的免费可用的编译器是 GNU 的 C/C++ 编译器,如果您使用的是 HP 或 Solaris,则可以使用各自操作系统上的编译器。

GNU Autotools的使用方法

∥☆過路亽.° 提交于 2019-12-15 20:19:52
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 手工写Makefile是一件很有趣的事情,对于比较大型的项目,如果有工具可以代劳,自然是一件好事。在Linux系统开发环境中,GNU Autotools 无疑就充当了这个重要角色。(在Windows系统的开发环境中,IDE工具,诸如Visual Studio,来管理项目也很方便。) 本文以一个简单项目为例子,来讲述GNU Autotools的一列工具及其命令的用法。 autotools是系列工具, 它主要由autoconf、automake、perl语言环境和m4等组成;所包含的命令有五个: (1)aclocal (2)autoscan (3)autoconf (4)autoheader (5)automake 一、准备源代码 (1)目录project包含一个main.c的文件和两个子目录lib与include;lib目录中包含一个test.c,include目录中包含一个test.h。在系统中,显示如下: [root@localhost project]# ls include lib main.c [root@localhost project]# [root@localhost project]# ls include/ test.h [root@localhost project]# ls lib/

绝世秘籍之GNU构建系统与Autotool概念分析

泄露秘密 提交于 2019-12-15 20:18:11
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 为了简化可移植构建的难度,在早期有一套autotools工具帮助程序员构建软件。我们熟知的configure->make->make install三部曲,大多都是基于autotools来构建的。autotools是GNU程序的标准构建系统,所以其实我们经常在使用三部曲。有些程序虽然也是这三部曲,但却不是用autotools实现的,比如nginx的源码就是作者自己编写的构建程序。 用户视角 用户通过configure->make->make install基于源码安装软件。然而大部分用户可能并不知道这个过程究竟做了些什么。 configure脚本是由软件开发者维护并发布给用户使用的shell脚本。这个脚本的作用是检测系统环境,最终目的是生成Makefile和config.h。 make通过读取Makefile文件,开始构建软件。而make install可以将软件安装到需要安装的位置。 如上图,开发者在分发源码包时,除了源代码(.c .h…),还有许多用以支撑软件构建的文件和工具,其中最重要的文件就是Makefile.in和config.h.in。configure脚本执行成功后,将为每一个*.in文件处理成对应的非*.in文件。 大部分情况只生成Makefile和config.h

GNU 构建系统

痴心易碎 提交于 2019-12-15 20:03:30
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 需要整理关于 ' GNU构建系统 ' 的文章 Autoconf, Automake and Libtool http://sources.redhat.com/autobook /autobook/autobook_toc.html http://sources.redhat.com/autobook/autobook/autobook_toc.html#SEC_Contents Autoconf http://zh.wikipedia.org/wiki/Autoconf GNU构建系统 http://zh.wikipedia.org/wiki/GNU%E6%9E%84%E5%BB%BA%E7%B3%BB%E7%BB%9F Autotoolset Tutorial http://autotoolset.sourceforge.net/tutorial.html http://hi.baidu.com/aflyhorse1990/blog/item/516201520880bd030df3e322.html Automake Manual http://www.gnu.org/software/automake/manual/html_node/index.html Autoconf Manual http:/

例解GNU C之指定初始化项目

北慕城南 提交于 2019-12-15 19:51:07
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 前言:计算机语言是编译器和程序员交流的依据和规范,GNU C是GCC特有的功能,在Linux内核中被广泛应用。 帮助文档: http://gcc.gnu.org/onlinedocs/gcc-4.6.2/gcc/C-Extensions.html#C-Extensions 指定初始化项目(Designated Initializers):指的是可以对数组中的某些元素或结构体变量中的某些成员以任意的顺序进行选择性的初始化。 1、在数组中的应用 在数组的初始化列表中使用“[index]= value”这样的形式即可实现对指定(通过index指定)的某个元素进行初始化。 举例,如清单1: [cpp] view plain copy #include <stdio.h> int main( void ) { int i; int arr[6] = { [3] = 29, 18, [0] = 12, 33}; //等价于int arr[6] = { [3] = 29, [4] = 18, [0] = 12, [1] = 33}; //也就是等价于int arr[6] = {12, 33, 0, 29, 18, 0}; for (i = 0; i < 6; i++) printf( "arr[%d]: %d\n" , i,

Linux 基础入门

岁酱吖の 提交于 2019-12-15 18:25:08
Linux 基础入门 文章目录 Linux 基础入门 一、Linux是什么? **1.1 Linux简史** **1.2 GNU** **1.3 Linux哲学思想** **1.4 Linux的内核版本组成** **1.5 Red Hat** **1.6 开源 Open Source** **1.7 Linux 生产主流版本** 二、Linux基础 **1.1 用户类型** **1.2 终端 terminal** **1.2.1终端类型** 1.2.2 查看当前的终端设备:tty 1.3 交互式接口 1.3.1 交互式接口类型 1.3.2 什么是shell 1.3.3 各种Shell 1.3.4 bash shell 1.4 设置主机名 1.5 命令提示符(prompt) 1.6 执行命令 1.6.1 执行命令过程 1.6.2 shell中可执行的两类命令 **1.6.2.2 执行外部命令** 16.2.3 Hash缓存表 一、Linux是什么? Linux是一套免费使用和自由传播的 类Unix 操作系统 ,是一个基于 POSIX 和Unix的多用户、 多任务 、支持 多线程 和多 CPU 的操作系统。它能运行主要的Unix工具软件、应用程序和网络协议。它支持 32位 和 64位 硬件。Linux继承了Unix以网络为核心的设计思想,是一个性能稳定的多用户网络操作系统。 1.1