草庐IT

fcatch-undefined-behavior

全部标签

将可执行文件链接到第三方依赖共享库时,C++ CMake undefined reference

我阅读了很多相关主题(如1、2、3)但我自己没有找到答案,所以我来了。我有一个构建和可执行的CMake项目,比方说“x”。我创建了一个名为“a.so”的共享库,它依赖于另一个名为“b.so”的共享库。我想在“x”中使用“a”。这是我简化的“x”CMakelists.txt:SET(ROOT_DIR${CMAKE_CURRENT_SOURCE_DIR})LINK_DIRECTORIES(${ROOT_DIR}/lib/a/bin/)#containsliba.soINCLUDE_DIRECTORIES(${ROOT_DIR}/lib/a/include/)#contains"a"head

c++ - "warning: operation of ... may be undefined"用于三元运算——不是 if/else block

这个问题在这里已经有了答案:Undefinedbehaviorandsequencepoints(5个答案)关闭6年前。这是我的代码:intmain(){staticinttest=0;constintanotherInt=1;test=anotherInt>test?test++:0;if(anotherInt>test)test++;elsetest=0;return0;}这是我构建它时产生的警告:../main.cpp:15:40:warning:operationon‘test’maybeundefined[-Wsequence-point]test=anotherInt>te

c++ - 编译错误 : undefined reference to‘__atomic_fetch_add_4’

#includeusingnamespacecv;intmain(){Matimg=imread("cornea.jpg");imshow("src",img);waitKey(0);return0;}然后我编译它:g++main.cpp-omain`pkg-configopencv--cflags--libs`或g++main.cpp-omain-I/usr/local/opencv-3.1.0/include/opencv-I/usr/local/opencv-3.1.0/include-L/usr/local/opencv-3.1.0/lib-lopencv_shape-lope

c++ - 对 __isoc99_sscanf 的 undefined reference

我有一个使用sscanf的静态C库libex.a。库是使用-std=c99编译的我想在使用-std=c++11编译的某些C++代码中使用库函数,但出现以下错误:lib/libex.a(srcfile.o):Infunction`my_function':/srcpath/srcfile.c:215:undefinedreferenceto`__isoc99_sscanf'经过一番探索后,我发现sscanf由于向后兼容性黑客攻击而存在版本问题,因此重定向到__isoc99_sscanf,所以我怀疑这是不知何故问题的根源。但是,我检查了我的glibc版本,它看起来足够新,以至于其他地方建议

c++ - Boost 1_65_1 不使用 OpenSSL 1.1.0g "undefined reference"编译,但使用 "nm"找到

我正在尝试让SSL与boostASIO一起工作。我在Windows上使用MingW6.3。我用MingW构建了OpenSSL1.1、1.0和0.8,当我尝试将它们链接到项目时,我总是会遇到不同的错误(取决于缺少什么)。现在我正在尝试使OpenSSL1.1.0g工作,但即使我使用CMAKE手动提供库的路径,我也会遇到这些错误:如果我使用OpenSSL1.1.0g构建我的项目,这是错误:"C:\ProgramFiles\JetBrains\CLion2017.2.3\bin\cmake\bin\cmake.exe"--buildC:\Users\myuser\Documents\Mages

c++ - 什么是 undefined reference /未解析的外部符号错误,我该如何解决?

什么是undefinedreference/未解析的外部符号错误?常见原因是什么以及如何修复/预防它们? 最佳答案 编译C++程序需要几个步骤,如2.2(creditstoKeithThompsonforthereference)所指定的那样:Theprecedenceamongthesyntaxrulesoftranslationisspecifiedbythefollowingphases[seefootnote].Physicalsourcefilecharactersaremapped,inanimplementation-

c++ - Poco C++ 中的 undefined symbol

我之前编译了一个简单的命令行程序,它使用了PocoC++(顺便说一句,我喜欢它)。该程序完美运行了几个月。我的电脑上肯定有一些变化,因为现在当我运行程序时,我收到以下错误。dyld:Symbolnotfound:__ZN4Poco4Util11Application12handleOptionERKNSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEESA_Referencedfrom:/Users/me/bin/sqlmergeExpectedin:/usr/local/opt/poco/lib/libPoco

c++ - Opencv,对 `cv::imread(??cv::String const&???, int)' 的 undefined reference

这个问题在这里已经有了答案:error:undefinedreferenceto`cv::imread(std::stringconst&,int)'(4个答案)Whatisanundefinedreference/unresolvedexternalsymbolerrorandhowdoIfixit?(38个答案)关闭5年前。我在QT+Opencv中有一个项目,代码可以正常工作,但我必须格式化窗口,现在我试图再次导入该项目,但出现了这个错误。对`cv::imread(cv::Stringconst&,int)'的undefinedreference在这一行中:mat=cv::imre

c++ - 对 `kill' 的 undefined reference

我用C为ARM7嵌入式系统开发了一个应用程序。现在我想用C++编译和链接它,以便使用一些C++功能。为此,我使用mipsel-elf-g++而不是mipsel-elf-gcc。我可以使用mipsel-elf-g++成功编译我的代码,但在链接步骤中出现错误:/opt/mipsel/lib/gcc/mipsel-elf/3.4.6/../../../../mipsel-elf/lib/libc.a(lib_a-abort.o):Infunction```abort':/cygdrive/d/Files/cross/mips/newlib-1.15.0/newlib/libc/stdlib/

c++ - 不满意链接错误 : undefined symbol _ZN5boost6system16generic_categoryEv in java (JNI)

我创建了一个.so文件,其中我根本没有使用boost库(当然早些时候我使用过它),但后来我切换到pthreads并删除了所有头文件和boost.so文件链接生成文件。Java文件编译成功。但是,当我尝试使用java-Djava.library.path=libs/-cpbuild/发送它给我以下错误。线程“main”中的异常java.lang.UnsatisfiedLinkError:/home/aahmed/libplxmsg-java/libs/libplxmsgjavaasyncbinder.so:/home/aahmed/libplxmsg-java/libs/libplxms