草庐IT

fcatch-undefined-behavior

全部标签

c++ - OpenCV 2.3 编译问题 - undefined reference - Ubuntu 11.10

系统信息:Ubuntu11.10(64位)和OpenCV2.3(今天安装)我正在尝试在OpenCV2.3中编译一些非常简单的代码,但我遇到了一个奇怪的错误。#include#includeintmain(){cv::Matimage=cv::imread("img.jpg");cv::namedWindow("MyImage");cv::imshow("MyImage",image);cv::waitKey(0);return1;}但是,我收到了这些错误消息...-SG41:~/Desktop$g++`pkg-configopencv--cflags--libs`-otest_1tes

c++ - OpenCV 2.3 编译问题 - undefined reference - Ubuntu 11.10

系统信息:Ubuntu11.10(64位)和OpenCV2.3(今天安装)我正在尝试在OpenCV2.3中编译一些非常简单的代码,但我遇到了一个奇怪的错误。#include#includeintmain(){cv::Matimage=cv::imread("img.jpg");cv::namedWindow("MyImage");cv::imshow("MyImage",image);cv::waitKey(0);return1;}但是,我收到了这些错误消息...-SG41:~/Desktop$g++`pkg-configopencv--cflags--libs`-otest_1tes

c++ - 为什么这个 "undefined extern variable"不会导致 C++17 中的链接器错误?

我已经在C++17编译器(Coliru)中编译并运行了以下程序。在程序中,我声明了一个extern变量,但没有定义它。但是,编译器不会给出链接器错误。#includeexterninti;//Onlydeclarationintfunc(){ifconstexpr(true)return0;elseif(i)returni;elsereturn-1;}intmain(){intret=func();std::cout为什么编译器不给出链接器错误? 最佳答案 因为变量没有被odr使用。你有一个constexprif总是丢弃可以使用它的

c++ - 为什么这个 "undefined extern variable"不会导致 C++17 中的链接器错误?

我已经在C++17编译器(Coliru)中编译并运行了以下程序。在程序中,我声明了一个extern变量,但没有定义它。但是,编译器不会给出链接器错误。#includeexterninti;//Onlydeclarationintfunc(){ifconstexpr(true)return0;elseif(i)returni;elsereturn-1;}intmain(){intret=func();std::cout为什么编译器不给出链接器错误? 最佳答案 因为变量没有被odr使用。你有一个constexprif总是丢弃可以使用它的

c++ - gcc: undefined reference

我想编译这个。program.c#includeintmain(){inti=avpicture_get_size(AV_PIX_FMT_RGB24,300,300);}运行这个gcc-I$HOME/ffmpeg/includeprogram.c报错/tmp/ccxMLBme.o:Infunction`main':program.c:(.text+0x18):undefinedreferenceto`avpicture_get_size'collect2:ldreturned1exitstatus但是,avpicture_get_size是定义的。为什么会这样?

c++ - gcc: undefined reference

我想编译这个。program.c#includeintmain(){inti=avpicture_get_size(AV_PIX_FMT_RGB24,300,300);}运行这个gcc-I$HOME/ffmpeg/includeprogram.c报错/tmp/ccxMLBme.o:Infunction`main':program.c:(.text+0x18):undefinedreferenceto`avpicture_get_size'collect2:ldreturned1exitstatus但是,avpicture_get_size是定义的。为什么会这样?

c++ - 架构 x86_64 : Compiling problems 的 undefined symbol

所以我正在尝试开始一项作业,我的教授给了我们一个Main.cpp、Main.h、Scanner.cpp、Scanner.h和一些其他实用程序。我的工作是创建一个相似度类来使用余弦和Jaccard系数比较文档。但是,我似乎无法正确链接项目,因此无法从实际代码开始。在尝试了几个小时来看看我做错了什么之后,我需要用新的眼光来看看我做错了什么,我怀疑这很明显。这里是Main.cpp#include"Main.h"usingnamespacestd;staticconststringTAG="Main:";intmain(intargc,char*argv[]){stringinStreamNa

c++ - 架构 x86_64 : Compiling problems 的 undefined symbol

所以我正在尝试开始一项作业,我的教授给了我们一个Main.cpp、Main.h、Scanner.cpp、Scanner.h和一些其他实用程序。我的工作是创建一个相似度类来使用余弦和Jaccard系数比较文档。但是,我似乎无法正确链接项目,因此无法从实际代码开始。在尝试了几个小时来看看我做错了什么之后,我需要用新的眼光来看看我做错了什么,我怀疑这很明显。这里是Main.cpp#include"Main.h"usingnamespacestd;staticconststringTAG="Main:";intmain(intargc,char*argv[]){stringinStreamNa

带模板的 C++ 共享库 : Undefined symbols error

我正在尝试使用模板类链接到共享库,但它给了我“undefinedsymbol”错误。我已经将问题压缩到大约20行代码。shared.htemplateclassmyclass{Typex;public:myclass(){x=0;}voidsetx(Typey);Typegetx();};shared.cpp#include"shared.h"templatevoidmyclass::setx(Typey){x=y;}templateTypemyclass::getx(){returnx;}ma​​in.cpp#include#include"shared.h"usingnamespa

带模板的 C++ 共享库 : Undefined symbols error

我正在尝试使用模板类链接到共享库,但它给了我“undefinedsymbol”错误。我已经将问题压缩到大约20行代码。shared.htemplateclassmyclass{Typex;public:myclass(){x=0;}voidsetx(Typey);Typegetx();};shared.cpp#include"shared.h"templatevoidmyclass::setx(Typey){x=y;}templateTypemyclass::getx(){returnx;}ma​​in.cpp#include#include"shared.h"usingnamespa