草庐IT

cross-compiling

全部标签

c++ - "crosses initialization of variable"仅当初始化结合声明时

我读过thisquestion关于“跳转到案例标签”错误,但我还有一些疑问。我在Ubuntu12.04上使用g++4.7。这段代码报错:intmain(){intfoo=1;switch(foo){case1:inti=0;i++;break;case2:i++;break;}}错误是jump-to-case-label.cpp:Infunction‘intmain()’:jump-to-case-label.cpp:8:8:error:jumptocaselabel[-fpermissive]jump-to-case-label.cpp:5:9:error:crossesinitia

c++ - if(null) 正在使用 clang++ 编译的特定计算机中执行

我有一个大型代码,我们在团队中使用了很长时间。但是它在我的机器上编译时出现了几个星期的问题。代码针对IntelAtomCPU交叉编译并在特定机器上运行。当它在我的计算机上编译时,与其他人不同,它会导致段错误。段错误来自不应执行的ifblock:Settings*s=&Global::getSettings();std::coutGlobal::getSettings()如下:...private:static__threadSettings*theSettings;public:staticSettings&getSettings(){return*theSettings;}...__

不同目标的 C++ 转换(编译器)

鉴于以下情况:code-link为了方便起见,这里是代码本身(我不确定我的链接是否有效):#include#include#includeusingnamespacestd;intmain(){couttest_vect{"1","2"};longunsignedintsize=static_cast(test_vect.size());std::cout以及以下编译选项:g++file.c-Wall-Wextra"-Werror""-Wuseless-cast"你可以在这里看到我正在将vector.size()转换为longunsignedint,但是这在Wandbox(我的链接)上

C++ 模板 : How to conditionally compile different code based on data type?

这里有一个小例子来说明我的问题的本质:#includeusingnamespacestd;typedefcharachar_t;templateclassSTRING{public:T*memory;intsize;intcapacity;public:STRING(){size=0;capacity=128;memory=(T*)malloc(capacity*sizeof(T));}constSTRING&operator=(T*buf){if(typeid(T)==typeid(char))strcpy(memory,buf);elsewcscpy(memory,buf);ret

C++ 单例用法 : compiler complains about private constructor

我知道有一百万个关于单例的问题和答案,但我似乎无法找到解决方案。所以冒着反对票的风险,这是我的问题:我想使用AndreiAlexandrescu的现代C++设计中的单例实现:标题:classSingleton{staticSingleton&Instance();private:Singleton(){};Singleton(constSingleton&){};Singleton&operator=(constSingleton&){};~Singleton(){};};实现:#include"s.hh"Singleton&Singleton::Instance(){staticSi

c++ - Windows 上 Mingw 的 DLL 依赖项

我正在开发一个程序,该程序使用autotools作为其构建系统并在Linux上编译良好。为了为windows构建,我试图让mingw交叉编译器为windows工作。现在,当我在linux上编译并移动到windows时,我当然会丢失一些默认情况下未安装在windows上的dll。这会导致缺少dll错误。由于LGPL的限制,我无法静态链接我的程序。所以我的问题是在这种情况下交叉编译的正确方法是什么?我觉得我需要将我的exe包装在一个安装程序中,该安装程序会自动解析并安装Windows的dll依赖项,但我无法找到解释如何执行此操作的内容。基本上我在考虑yum/apt-getforwindow

c++ - 在 AVX 上使用 AVX2/AVX512 内在函数编译 C++ 代码

我的生产代码具有针对各种SIMD指令集(包括AVX、AVX2和AVX512)实现的内核。代码可以在目标机器上为目标机器编译,类似./configure--enable-proc=AVXCXXFLAGS="-mavx"。这在公开AVX内在函数的TravisCI上也很有效。我想至少编译AVX2和AVX512版本,以查看是否所有文件都已checkin。但似乎为不同的ISA编译并不那么容易。一个简单的AVX2测试程序:#includeintmain(intargc,char**argv){__m256da;__m256db;__m256dc;_mm256_fnmadd_pd(a,b,c);}在

c++ - Visual Studio 2017 : _mm_load_ps often compiled to movups

我正在查看为我的代码生成的程序集(使用VisualStudio2017)并注意到_mm_load_ps经常(总是?)编译为movups。我使用_mm_load_ps的数据定义如下:structalignas(16)Vector{floatv[4];}//oftenembeddedinotherstructslikethisstructAABB{Vectormin;Vectormax;boolintersection(/*parameters*/)const;}现在,当我使用这个构造时,会发生以下情况://thiscode__mm128bb_min=_mm_load_ps(min.v);

c++ - 在 Ubuntu 上为 Raspberry Pi 交叉编译 opencv 项目

我已经为此苦苦挣扎了2天,但无法正常工作。到目前为止我做了什么:在Ubuntu12.04LTS上从源代码构建opencv2.4.8-->OpenCV项目在ubuntu上编译运行在RaspberryPiRaspian上从源代码构建opencv2.4.8-->OpenCV项目在树莓派上编译运行使用crosstools-ng(http://www.bootc.net/archives/2012/05/26/how-to-build-a-cross-compiler-for-your-raspberry-pi/)为RaspberryPi构建了一个交叉编译器-->在Ubuntu上构建的c++程序

c++ - Gtest : test compiling error

我正在尝试测试我用googletest编写的电机控制库,但我没有编译测试代码。测试位于名为test.cpp的文件中,如下所示:#include#include"../motor.hpp"TEST(constructorTest,contructorDefault){}我将测试主函数放在另一个名为main.cpp的文件中。#include#include"../motor.hpp"intmain(intargc,char*argv[]){::testing::InitGoogleTest(&argc,argv);RUN_ALL_TESTS();}为了编译,我执行了以下行:g++main.