我不想在交叉编译项目中的源代码树中包含静态库,而是将boost直接添加到cmake中并构建它.这可用吗?
我正在尝试使用Windows上的CMake制作一个非常基本的Qt5应用程序.我使用Qt5的文档来使用CMake,我的main.cpp文件只包含一个main函数.
我CMakeLists.txt的确如此:
cmake_minimum_required(VERSION 2.8.9)
project(testproject)
Run Code Online (Sandbox Code Playgroud)
编辑解决方案
set (CMAKE_PREFIX_PATH "C:\\Qt\\Qt5.0.1\\5.0.1\\msvc2010\\")
Run Code Online (Sandbox Code Playgroud)
结束编辑
# Find includes in corresponding build directories
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# Instruct CMake to run moc automatically when needed.
set(CMAKE_AUTOMOC ON)
# Find the QtWidgets library
find_package(Qt5Widgets)
# Tell CMake to create the helloworld executable
add_executable(helloworld hello.cpp)
# Use the Widgets module from Qt 5.
qt5_use_modules(helloworld Widgets)
Run Code Online (Sandbox Code Playgroud)
在MSysGit bash中我输入`$ cmake -G"Visual Studio 11"
我得到这个输出:
$ cmake -G"Visual Studio 11"
-- The …Run Code Online (Sandbox Code Playgroud) 我一直在尝试使用clang-modernize与CMAKE_EXPORT_COMPILE_COMMANDS在该工具的帮助推荐.
使用此选项,cmake会生成一个包含编译信息(如include路径)的JSON文件(另请参阅).
此变量在cmake的命令行中被接受,但cmake --help-variable CMAKE_EXPORT_COMPILE_COMMANDS不起作用(这与此邮件列表发布一致).
有人知道如何使用它吗?
我也可以用cppcheck.
更多信息
我在clang开发者论坛上发现,这个cmake功能并非在所有生成器上都可用.这可能会在未来发生变化,同时我的问题仍然存在,我也会尝试看看如果我使用其他生成器而不是Visual Studio会发生什么.
我正在尝试在Visual Studio 2013上对小型控制台应用程序进行基准测试.
我已经在检测模式下设置了一个性能会话,我在其中激活了CPU Counters集合,并选择了"Last Level Cache Misses".
当我收到工作台的报告时,我看不到包含此信息的任何列,即使我查看"添加/删除列"菜单也是如此.
你能帮助我吗?
提前致谢.
##一些额外的信息

我有一个C++应用程序,需要使用标准的压缩格式的目录.我想过使用zip格式.因此,zlib显而易见.
我的问题是构建字典,即将包含一些zlib文件的目录压缩到标准zip文件.
我已经读过zlib做了但我不明白怎么做.我检查了minzip代码.它似乎使用gzip.我可以构建自己的格式,但我希望能够使用7z打开这些文件进行调试(以防万一).
我应该在zlib中使用什么来压缩目录?
[编辑] 在minzip 我使用minzip压缩1文件到它的gz版本 - >不拉链但对我来说很好.(我将在世界各种编译器上使用它 - 如果客户端平台出现问题,则标准格式更容易)
此外,还有这个代码main.它在文件列表上循环并将其写入输出.但是档案中文件位置的信息在哪里?
do {
if (uncompr) {
if (copyout) {
file = gzopen(*argv, "rb");
if (file == NULL)
fprintf(stderr, "%s: can't gzopen %s\n", prog, *argv);
else
gz_uncompress(file, stdout);
} else {
file_uncompress(*argv);
}
} else {
if (copyout) {
FILE * in = fopen(*argv, "rb");
if (in == NULL) {
perror(*argv);
} else {
file = gzdopen(fileno(stdout), outmode);
if (file == NULL) error("can't gzdopen stdout");
gz_compress(in, file);
} …Run Code Online (Sandbox Code Playgroud) 我知道constexpr 变量可以在编译时使用.例如,对于模板或静态asser.
但如果我想在没有constexpr的情况下这样做,我可以static const.
什么是自C++ 11/14引入constexpr之间的区别
constexpr int a = 3;
//AND
static const int a = 3;
Run Code Online (Sandbox Code Playgroud)
谢谢!
另一种看待这个问题的方法是我应该使用哪种方法?
我有一个奇怪的问题,为我的一个班级定义==.我将这里的代码简化为我在visual 2013上测试的示例; MyClass在名称空间N中定义
这确实编译:
N::MyClass a, b;
bool test = a == b;
Run Code Online (Sandbox Code Playgroud)
这个也是:
const N::MyClass a, b;
bool test = a == b;
Run Code Online (Sandbox Code Playgroud)
这不编译
std::map<int, N::MyClass> a, b;
bool test = a == b;
Run Code Online (Sandbox Code Playgroud)
为了您的信息,==运算符声明如下:
bool operator==(const N::MyClass & a, const N::MyClass & b);
Run Code Online (Sandbox Code Playgroud)
这是我得到的错误: error C2678: binary '==' : no operator found which takes a left-hand operand of type 'const MyClass' (or there is no acceptable conversion)
但据我所知,地图运算符已定义:map == cppreference.com上的引用
谁能解释一下为什么这是错的?
先感谢您.
我没有找到答案,如果这是愚蠢的话,我很抱歉.
[解决方案] 如果我将运算符模式化为命名空间,它可以工作:
bool N::operator==(const …Run Code Online (Sandbox Code Playgroud) 我的问题似乎很简单,但是我有一个在终端中启动的模块,如下所示:
bash
python -m my_module.my_file
我如何在Visual Studio Code中调试它。
我在launch.json(文档)中有这个
"type": "python",
"request": "launch",
"pythonPath": "D:\\ProgramData\\Anaconda3\\envs\\simulec\\python.exe",
"args": [
"-m",
"my_module.my_file",
]
Run Code Online (Sandbox Code Playgroud)
如果未设置该program选项,或者将其设置为""“文件不存在”,则会出现错误。
任何的想法?提前致谢
我想测试调用我的一个类的不同函数的线程.我有一个关键时间线程,我不希望任何人调用可能调用new从该线程调用的函数.但是,由于这两个功能是公开的,我不能用语言强制执行.
我的想法是测试线程ID.假设我可以保证呼叫初始化线程ID是在正确的线程,我将只需要调用thread::get_id()其他的呼叫,并比较线程ID我得救了.
问题是我还想在关键线程中测试这个ID,但我无法锁定该线程.
因此我的问题是:thread::get_id()锁定是否自由(以及可能是最糟糕的执行时间)?
我只是试图在Xcode5.0.2上使用c ++ 11的make_unique函数,Clang版本是
Apple LLVM 5.0版(clang-500.2.79)(基于LLVM 3.3svn)
检查后<memory>看起来它不存在.make_shared是.
我知道这是C++ 14,但它也是第一个为c ++ 14验证的函数之一.它甚至在Visual :)中.
它何时可用?
我正在做一些移动语义的测试,我试过这个:
class A{
public:
A(){printf("A CTOR\n");}
A(A&) {printf("A CTOR by copy\n");}
A(A&&){printf("A CTOR by universal reverence\n");}
};
A&& create(){
A v;
return std::move(v);
}
auto x{ create() };//this does not compile
float d[]{1.2,1.3,5,6};//this does compile
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
error C3086: cannot find 'std::initializer_list': you need to #include <initializer_list>
Run Code Online (Sandbox Code Playgroud)
我不明白,初始化列表功能已添加到VC11与CTP2012 nov.这是因为我们必须等待stdlib的更新吗?
我认为代码是正确的,因为我从Scott meyers的幻灯片中复制它:Move Semantics,Rvalue References,Perfect Forwarding.
谢谢您的帮助. 为了您的信息,发生了虚假副本,因为我没有在我的CTOR中添加"const"副本. 最好