- 浏览: 2722680 次
- 性别:
- 来自: 宜昌
-
最新评论
-
aigo:
senlin305 写道为了不至于误导后续来解决问题的人,专门 ...
gitblit无法安装windows服务或者启动服务失败:Failed creating java -
vhly:
录了一套关于MediaPlayer的视频,有播放控制、播放列表 ...
[UE4]如何播放视频文件(media) -
vhly:
制作了一套关于 UE4 Spline 的基础视频,包含 蓝图 ...
[UE4]蓝图-SplineMeshComponent用法 -
senlin305:
为了不至于误导后续来解决问题的人,专门弄个帐号来回复一下。出现 ...
gitblit无法安装windows服务或者启动服务失败:Failed creating java -
^=^:
请问博主试过这个方法吗?有效吗?
windows 10 更新失败:We couldn't complete the updates, undoing changes
文章列表
两种方式:
1,
start cmd /k echo Hello, World!
2,
start cmd /C pause
区别是第二种执行完毕以后,新开的窗口会自动关闭,第一种则不会
参考:http://stackoverflow.com/questions/9392874/bat-file-open-new-cmd-window-and-enter-code-in-there
用start命令执行操作后,start所在的窗口会自动关闭,如何启动其他bat之后,初始cmd窗口不关闭?
方式如下:
例子1
启动脚本start.bat内容如下:
cmd /k "C\MyPath\TEST.BAT"
这样运行TEST.bat之后,start.bat所在的cmd窗口不会自动关闭。
参考:http://stackoverflow.com/questions/8807118/how-to-avoid-cmd-will-be-closed-after-a-batch-was-executed
例子2:
启动vcvarsall.bat ...
有两种方式,一种是使用cmake自带的FindProtobuf module,这个模块内部集成了生成代码命令的操作,用起来最方便;另外一种是将protoc命令集成到CMakeLists.txt中,这种要麻烦点。
自带的FindProtobuf
方法如下:
使用cmake自带的FindProtobuf解析protobuf
http://www.leoox.com/?p=285
但是我按照文章试了一遍,结果不成功,最后nmake错误时提示:
NMAKE : fatal error U1073: don't know how to make 'E:\Source\pr ...
演示下cmake如何构建引用了第三方库的C++工程,这里第三方库已protobuf-lite为例。
1,我们用protobuf生成一个简单的c++代码,模版文件如下,test.proto:
package HProtocol;
option optimize_for = LITE_RUNTIME;
message add {
required int32 val = 1;
}
2,设置编译目录结构
由于引用了protobuf-lite第三方库,所以我们将编译好的protobuf-lite.lib与其头文件考过来,同时将生成的test.pb. ...
原因:
多半是因为release模式下开启了全程序优化(/GL),这个选项默认是关闭的。
关闭方法:
工程Properties -》 Configuration Properties -》 C/C++ -》 Optimization -》 Whole Program Optimization设置为 No
1,编写C++代码app.cpp:
#pragma once
#include <cstdio>
int main(char** args, int size)
{
#ifdef _DEBUG
printf("debug\n");
#endif
#ifdef NDEBUG
printf("release\n");
#endif
return 1;
}
2,编写CMakeLists.txt:
cmake_minimum_required(VERSION 3.5)
se ...
用depends工具查看:
debug模式的dll和exe,VCRUNTIME.DLL文件名后面多一个字母D;release模式下则没有D。
x64架构的dll和exe,图标右边都有一个“64”字样的小图标;x86架构的图标右边是空白。
debug x86
debug x64
release x86
release x64
错误:
D:\Program_Filesx86\Microsoft Visual Studio 14.0\VC\INCLUDE\cmath(17): error C2061: syntax error: identifier 'noexcept'
D:\Program_Filesx86\Microsoft Visual Studio 14.0\VC\INCLUDE\cmath(17): error C2059: syntax error: ';'
D:\Program_Filesx86\Microsoft Visual Studio 14.0\VC\INCLUDE\cmath(18): ...
一般Debug和Release必须在不同的目录下编译,否则每次当切换模式时必须把编译文件全部删掉。
这里假设新建两个目录Debug和Release来分别用于构建相应的模式:
mkdir Release
cd Release
cmake -DCMAKE_BUILD_TYPE=Release ..
make
mkdir Debug
cd Debug
cmake -DCMAKE_BUILD_TYPE=Debug ..
make
windows下的注意事项
如果是windows下,想使用CMAKE_BUILD_TYPE参数,cmake时必须用-G& ...
答案是没有。
推荐等价于clean的方法:
在你的source目录之外建一个build目录,在这个build目录下进行cmake,如果想清理,删掉build下所有文件即可:
mkdir build
cd build
cmake ..
make
参考:
http://stackoverflow.com/questions/27247123/how-to-clean-up-the-project-files-generated-by-cmake
原文:
CMake target_link_libraries Interface Dependencies
http://stackoverflow.com/questions/26037954/cmake-target-link-libraries-interface-dependencies
If you are creating a shared library and your source cpp files #include the headers of another library (Say, QtNetwork for example), but ...
比如boost有很多库,如果都要引用,最原始的方法就是一个一个添加:
target_link_libraries(${TARGET} PRIVATE
"${BOOST_PATH}/libboost_filesystem.a"
"${BOOST_PATH}/libboost_system.a"
"${BOOST_PATH}/libboost_chrono.a"
...
)
cmake提供的通配符方法:
file(GLOB LIBS "${BOOST_PATH}/libboost*.a ...
CMakeLists.txt写法示例,假设生成的lib名字为archive:
动态库
add_library(archive SHARED archive.cpp zip.cpp lzma.cpp)
静态库
add_library(archive STATIC archive.cpp zip.cpp lzma.cpp)
官方文档:
https://cmake.org/cmake/help/v3.0/manual/cmake-buildsystem.7.html#binary-library-types
Windows
vs2015 x64编译器为例,cmake命令如下:
cmake -G "Visual Studio 14 Win64" path\to\source\dir
去掉Win64,就是32bit:
cmake -G "Visual Studio 14" path\to\source\dir
另外一种等价方式,用命令行参数-A来指定架构(x64或者ARM):
cmake -A x64 path\to\source\dir
更多参考:
https://cmake.org/cmake/help/v3.1/manual/cma ...
protobuf 2.6之前的版本,同时为多个proto文件生成java或者c++代码时,是支持通配符的,比如
protoc.exe --proto_path=custom_msg --cpp_out=build custom_msg/*.proto
但现在2.6已经不支持这种写法了,要同时指定多个proto文件名,必须追加文件名:
protoc.exe --proto_path=custom_msg --cpp_out=build custom_msg/aaa.proto custom_msg/bbb.proto