Visual studio 2015程序转Eclipse gun编译出现的问题总结
Visual studio 2015程序转Eclipse gun编译出现的问题总结
1、C++11支持
1)Project
settings
project右键->
c/c++
build ->Settings -> GCC C++ Compiler -> Miscellaneous ->
Other flags后面加上
-std=c++11
2)Workspace
settings
Window->
Preference -> Build -> Settings ->Discovery -> CDT GCC
Built-in Compiler Settings MinGW(shared) ->(command to get
compiler specs) ${COMMAND} -E -P -v -dD "${INPUTS}"
-std=c++11
2、Ubuntu下boost库的编译安装步骤及卸载方法详解
最近由于编译一个程序用到了C++的boost库,所以便安装了这个库。但是,其中遇到了一些小问题。所以记录下来,以供别人参考。
首先说一下我的环境:Ubuntu
14.04 64bit, gcc (Ubuntu 4.8.4-2ubuntu1~14.04.1) 4.8.4
其实在ubuntu下,可以用一下命令直接安装
sudo apt-get install
libboost-all-dev //完全安装所有boost库
sudo apt-get install
aptitude
aptitude search
boost
apt-get install
PACKAGE_NAME
Is the command
used to install any package you know the name for, like aptitude.
sudo is used to
earn root access and be able to install and remove software. sudo is
always required if you do system wide changes like installing,
removing, updating and upgrading packages.
apt-get
Is the command
used to manage any software and software sources. install is an extra
command that tells the computer that you want to install software
with the package name as follows. It will then check the software
sources for a download link with the same name and then download and
install the latest version (or specified version).
update
will update the
sofware sources with new versions of the software listed (not
installing anything)
upgrade
upgrades the
software if new versions are available in the software sources.
remove
removes the
package name specified after (like install).
there are more
useful commands, but these are necessary for getting started with
managing software from the terminal.
Aptitude
The command
apt-get install aptitude will install a graphical package
manager called aptitude.
Aptitude is a
famous package manager with a ncurses GUI. I prefer it
over the other package managers, since it is faster(IMHO) and the
conflict management system works very well.
After more
research on aptitude i found out that it's already installed. So
installing aptitude wouldn't resolve in anything besides errors in
the conosle. Start aptitude by:
sudo aptitude
The aptitude
package is a GUI version of the apt-get command, it hasn't
got the full set of features as apt-get but you have the
basics like, remove, update, upgrade, install, etc. More information
about aptitude and it features can be found here.
Also search in
the software center if you want o use a GUI to find and
install/uninstall applications.
安装后查看libboost-dev版本
root@ubuntu:~# dpkg
-s libboost-dev | grep 'Version'
Version:
1.54.0.1ubuntu1
root@ubuntu:~#
安装后的目录:
1)include
2)lib(so动态链接库文件所在目录)
3)需要包含libboost_system.so和libboost_serialization.so
在Add的时候,要去掉前缀“lib”和扩展名“.so”
boost安装常用的几个依赖文件(完全安装时,这些依赖库应该可以自动被安装):
apt-get install
mpi-default-dev #安装mpi库
apt-get install
libicu-dev #支持正则表达式的UNICODE字符集
apt-get install
python-dev #需要python的话
apt-get install
libbz2-dev
下载特定版本手动安装:
1.下载boost1.53源文件http://sourceforge.net/projects/boost/files/latest/download?source=dlp
2.解压后,进入boost_1_53_0目录,执行:
./bootstrap.sh
3.(重点)修改
tools/build/v2/user-config.jam文件,在最后面加上一行“using
mpi ;”(注意mpi后面有个空格,然后一个分号
)
4. 执行:
./b2
(或者:
./bjam -a
-sHAVE_ICU=1 #-a参数,代表重新编译,-sHAVE_ICU=1代表支持Unicode/ICU
)
5. 执行:
sudo ./b2 install
以上便是全部安装过程,因为网上提到的比较多,所以此处从略。重点想提的是第三步,务必记得。不过,如果你的程序不需要mpi这个功能,那也就不重要了。
应用默认设置即可。而且,第四步,执行时可以在后面加prefix参数,如果不加,装好后,默认的头文件在/usr/local/include
/boost目录下。库文件在/usr/local/lib/目录下。默认不用修改。
如果编译好程序后,在运行时提示无法加载某个库文件,则把/usr/local/lib下的所有boost的库文件mv到/usr/lib目录下就可以了。
默认安装头文件在目录/usr/local/include,而库文件在目录/usr/local/lib。卸载也很简单,直接将以上两个目录中有关boost的内容删除就可以了。
更多详情可参考boost官方网站:http://www.boost.org/
3、localtime、localtime_s、localtime_r
(1)、localtime用来获取系统时间,精度为秒
#include <stdio.h>
#include <time.h>
int main(){
time_t time_seconds = time(0);
struct tm* now_time = localtime(&time_seconds);
printf("%d-%d-%d %d:%d:%d/n", now_time->tm_year + 1900,
now_time->tm_mon + 1, now_time->tm_mday,
now_time->tm_hour, now_time->tm_min, now_time->tm_sec);
}
函数原型为struct
tm *localtime(const time_t * timep)
需要包含头文件:#include
<time.h>
struct tm的结构为
int tm_sec;
/* 秒 –
取值区间为[0,59] */
int tm_min;
/* 分 -
取值区间为[0,59]
*/
int tm_hour;
/* 时 -
取值区间为[0,23]
*/
int tm_mday;
/* 一个月中的日期
- 取值区间为[1,31]
*/
int tm_mon;
/* 月份(从一月开始,0代表一月)
- 取值区间为[0,11]
*/
int tm_year;
/* 年份,其值等于实际年份减去1900
*/
int tm_wday;
/* 星期 –
取值区间为[0,6],其中0代表星期天,1代表星期一,以此类推
*/
int tm_yday;
/* 从每年的1月1日开始的天数
– 取值区间为[0,365],其中0代表1月1日,1代表1月2日,以此类推
*/
int tm_isdst;
/*
夏令时标识符,实行夏令时的时候,tm_isdst为正。不实行夏令时的进候,tm_isdst为0;不了解情况时,tm_isdst()为负。*/
(2)localtime_r也是用来获取系统时间,运行于linux平台下
函数原型为struct
tm *localtime_r(const time_t *timep, struct tm *result);
#include <stdio.h>
#include <time.h>
int main(){
time_t time_seconds = time(0);
struct tm now_time;
localtime_r(&time_seconds, &now_time);
printf("%d-%d-%d %d:%d:%d/n", now_time.tm_year + 1900,
now_time.tm_mon + 1, now_time.tm_mday, now_time.tm_hour,
now_time.tm_min, now_time.tm_sec);
}
(3)localtime_s也是用来获取系统时间,运行于windows平台下,与localtime_r只有参数顺序不一样
#include <iostream>
#include <time.h>
int main(){
time_t time_seconds = time(0);
struct tm now_time;
localtime_s(&now_time,&time_seconds);
printf("%d-%d-%d %d:%d:%d/n", now_time.tm_year + 1900,
now_time.tm_mon + 1, now_time.tm_mday, now_time.tm_hour,
now_time.tm_min, now_time.tm_sec);
}
为什么有了localtime还要有其他两个函数呢,因为localtime并不是线程安全的,观察localtime和localtime_r的调用发现,localtime在使用时,我们只需定义一个指针,并不需要为指针申请空间,而指针必须要指向内存空间才可以使用,其实申请空间的动作由函数自己完成,这样在多线程的情况下,如果有另一个线程调用了这个函数,那么指针指向的struct
tm结构体的数据就会改变。
在localtime_s与localtime_r调用时,定义的是struct
tm的结构体,获取到的时间已经保存在struct
tm中,并不会受其他线程的影响。
4、noexcept(true)
在c++11标准之前,c++在函数声明中有exception
specification(异常声明)的功能,用来指定函数可能抛出的异常类型。
voidFunc0()
throw(runtime_error);
voidFunc1() throw();
voidFunc2();
函数Func0可能抛出runtime_error类型的异常;函数Func1不会抛出任何异常;函数Func2没有异常说明,则该函数可以抛出任何类型的异常。
如果函数抛出了没有在异常说明中列出的异常,则编译器会调用标准库函数unexpected。默认情况下,unexpected函数会调用terminate函数终止程序。
这种异常声明的功能很少使用,因此在c++11中被弃用。c++11引入noexcept,具体用法如下。
voidFunc3()
noexcept;
noexcept的功能相当于上面的throw(),表示函数不会抛出异常。如果noexcept修饰的函数抛出了异常,编译器可以选择直接调用std::terminate()终止程序运行。noexcept比throw()效率高一些。
voidFunc4()
noexcept(常量表达式);
如果常量表达式的结果为true,表示该函数不会抛出异常,反之则有可能抛出异常。不带常量表达式的noexcept相当于noexcept(true)。
上面noexcept的用法是其作为修饰符时的用法,实际上noexcept还可以作为操作符,常用于模板中。
template <typename
T>
voidfunc5()
noexcept( noexcept(T()) ) {}
第2个noexcept就是一个操作符,如果其参数是一个有可能抛出异常的表达式,则返回值为false(func5为noexcept(false),有可能会抛出异常),否则返回值为true(func5为noexcept(true),不会抛出异常)。
这样函数是否会抛出异常,可以由表达式进行推导,使得c++11更好的支持泛型编程。
noexcept被大量的使用在c++11的标准库中,用于提高标准库的性能,以及满足一些阻止异常扩散的需求。随便在c++11标准文档中搜索一下noexcept关键字,就知道它的应用有多广泛了。
c++11默认将delete设置成noexcept,这样可以提高应用程序的安全性,因为在析构函数中不应该抛出异常,而析构函数中经常会调用delete。
voidoperator
delete(void* ptr) noexcept;
voidoperator
delete(void* ptr, const std::nothrow_t&) noexcept;
voidoperator
delete[](void* ptr) noexcept;
voidoperator
delete[](void* ptr, const std::nothrow_t&) noexcept;
voidoperator
delete(void* ptr, void*) noexcept;
voidoperator
delete[](void* ptr, void*) noexcept;
同样出于安全因素考虑,c++11将类的析构函数默认为noexcept(true)。但如果程序员显示的为析构函数指定noexcept(false),或者类的基类或成员有noexcept(false)的析构函数,则析构函数不会再保持默认值。
Visual studio 2015程序转Eclipse gun编译出现的问题总结的更多相关文章
- [No0000AB]用Visual Studio 2015在 WIN10 64bit 上编译7-zip (32 bit)
1.7-ZIP简介 7-zip 是一款免费的压缩解压软件.ZIP格式的文件默认被苹果和微软支持,完全不需要额外安装其他软件就可以解压.但对于非US-ASCII编码的文件名和大于2GB的ZIP文件,可能 ...
- [No0000AD]7z源码完全移植至Visual Studio 2015
今天在上次的基础上(原文地址:[No0000AB]用Visual Studio 2015在 WIN10 64bit 上编译7-zip (32 bit)),将7Z的源码完全移植到了vs2015开发环境下 ...
- Grunt和Gulp构建工具在Visual Studio 2015中的高效的应用
Grunt和Gulp构建工具在Visual Studio 2015中的高效的应用 Grunt和Gulp是Javascript世界里的用来做自动压缩.Typescript编译.代码质量lint工具.cs ...
- ASP.NET5之客户端开发:Grunt和Gulp构建工具在Visual Studio 2015中的高效的应用
Grunt和Gulp是Javascript世界里的用来做自动压缩.Typescript编译.代码质量lint工具.css预处理器的构建工具,它帮助开发者处理客户端开发中的一些烦操重复性的工作.Grun ...
- 新手,Visual Studio 2015 配置Boost库,如何编译和选择,遇到无法打开文件“libboost_thread-vc140-mt-gd-1_63.lib“的解决办法
1,到官网下载最新的boost,www.boost.org 这里我下载的1-63版本. 2,安装,解压后运行bootstrap.bat文件.稍等一小会就OK. 3,编译boost库.注意一定要使用VS ...
- Visual Studio 2015的坑:中文字符串编译后成乱码
(2015年8月5日更新:微软已经修复了Roslyn的这个bug,详见 https://github.com/dotnet/roslyn/pull/4303 ) 昨天,我们用VS2015编译了博客程序 ...
- ASP.NET 5系列教程 (五):在Visual Studio 2015中使用Grunt、Bower开发Web程序
基于Visual Studio 2015,你可以: 方便的管理前端包,如jQuery, Bootstrap, 或Angular. 自动运行任务,如LESS.JavaScript压缩.JSLint.Ja ...
- 体验Visual Studio 2015 Windows Forms应用程序开发与维护
昨天到半夜还没有等到Visual Studio 2015的下载地址,实在熬不住就先休息了.北美地区的时区比北京时间要晚一些,今天早上到公司就看到Visual Studio 2015的下载地址,迅速的将 ...
- Visual Studio 2015编译wxWidgets
宫指导说,换帅如换刀 程序员的编译器一换,基本套路必须都重练几次 使用wxWidgets并不难,但不能使用现有的库和工程配置文件,细节就必须理清楚 获取wxWidgets 官方的下载页面,下7z或zi ...
随机推荐
- Web---JS-返回上一页并刷新代码整理
返回上一页并刷新在此功能有利于用户的体验,是每一个web开发人员所必备的一项,长话短说,今天介绍实现此功能的一个方法,需要了解的朋友可以参考下: 一:JS 重载页面,本地刷新,返回上一页 代码如下: ...
- Web Service学习笔记
Web Service概述 Web Service的定义 W3C组织对其的定义如下,它是一个软件系统,为了支持跨网络的机器间相互操作交互而设计.Web Service服务通常被定义为一组模块化的API ...
- uvaLA4255 Guess BFS+拓扑排序
算法指南白书 思路:“连续和转化成前缀和之差” #include <stdio.h> #include <string.h> #include <iostream> ...
- 使用DNSAgent拦截特定域名
开发程序时,为方便测试,需要把本来发往abc.com的数据发到本地. 最简单的方法是直接在程序中修改,把abc.com修改为需要的地址. 但这样提交代码时,容易把调试地址给提交到服务器. 或是嵌入式设 ...
- 知道创宇爬虫题--代码持续更新中 - littlethunder的专栏 - 博客频道 - CSDN.NET
知道创宇爬虫题--代码持续更新中 - littlethunder的专栏 - 博客频道 - CSDN.NET undefined 公司介绍 - 数人科技 undefined
- IO(Input Output)流__字符流
一.IO流简述------用于操作数据的 IO流用来处理设备之间的数据传输; Java对数据的操作是通过流的方式; Java用于操作流的对象都是在IO包中; 流按操作数据分为: 字节流(通用)和字符流 ...
- C#常用工具类——Excel操作类
/// 常用工具类——Excel操作类 /// <para> ------------------------------------------------</para> / ...
- Python中的判断、循环 if...else,while
if...else语句: a=3; b=3; if a == b :print(a,b)elif a <= b :print(str(a) + " is less than " ...
- Linux安装程序Anaconda分析
1.概述 Anaconda是RedHat.CentOS.Fedora等Linux的安装管理程序.它能够提供文本.图形等安装管理方式,并支持Kickstart等脚本提供自己主动安装的功能.此外, ...
- ZooKeeper监控
http://jm-blog.aliapp.com/?p=1450 在公司内部,有不少应用已经强依赖zookeeper,zookeeper的工作状态直接影响它们的正常工作.目前开源世界中暂没有一个比较 ...