undefined-reference 相关问题

由于缺少程序中其他位置使用的符号定义而导致的链接器错误

与 `cc` 链接失败:退出状态:1

我正在使用 MultiversX Rust 测试框架编写集成测试。 所以,我正在运行货物测试。但它会抛出这个错误: 注意:/usr/bin/ld:/usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64...

回答 1 投票 0

Qt6 函数未定义

我使用 sudo apt install qt6-base-dev 命令在 Ubuntu 上安装了 Qt6。我创建了 Clion Qt6 项目并编写了简单的窗口代码: #包括 #包括 #包括<

回答 1 投票 0

OpenMP 对 `_CRT_fenv' 和 `_setargv' 的未定义引用

我正在尝试运行这个简单的 OpenMP 示例: #包括 #包括 使用命名空间 std; int main() { 开关(_OPENMP){ 案例200805: 计算<< "Op...

回答 2 投票 0

未定义的符号“vtable for ...”和“typeinfo for...”?

快到最后一步了,但仍然出现一些奇怪的错误...... bash-3.2$ 使 g++ -Wall -c -g Myworld.cc g++ -Wall -gsolvePlanningProblem.o Position.o AStarNode.o PRM.o PRMNode.o World.o SingleCircleWorl...

回答 6 投票 0

超级构造函数语法问题 - 错误:没有带有名称的命名参数

我正在尝试运行其他开发人员的现有代码。它向我展示了这个奇怪的错误: Xcode 的输出: lib/ui/ActHospitalDetail.dart:171:25:错误:没有名为“itemBuilde...

回答 2 投票 0

为什么我会得到对我链接的库中定义的符号的未定义引用?

当我在使用 Raylib 库的特定函数时得到未定义的引用时,我试图编译一个不相关的项目。 我能够使用以下 test.c 重现此行为 #

回答 1 投票 0

对`cuMemAlloc_v2'的未定义引用

我需要修改linux rdma-core驱动,添加一些cuda相关的功能;首先,cuMemAlloc。 我已更改驱动程序中的 CMake 文件以包含 cuda.h 头文件。但是当我编译

回答 1 投票 0

yaml-cpp 的编译器错误 - 对 `YAML::detail::node_data::convert_to_map` 的未定义引用

这是完整的日志: /tmp/ccCvErNZ.o:在函数 `YAML::detail::node& YAML::detail::node_data::get(std::string const&, std::shared_ptr) 这是完整的日志: /tmp/ccCvErNZ.o: In function `YAML::detail::node& YAML::detail::node_data::get<std::string>(std::string const&, std::shared_ptr<YAML::detail::memory_holder>)': cricket.cpp:(.text._ZN4YAML6detail9node_data3getISsEERNS0_4nodeERKT_St10shared_ptrINS0_13memory_holderEE[_ZN4YAML6detail9node_data3getISsEERNS0_4nodeERKT_St10shared_ptrINS0_13memory_holderEE]+0x94): undefined reference to `YAML::detail::node_data::convert_to_map(std::shared_ptr<YAML::detail::memory_holder>)' collect2: error: ld returned 1 exit status 我尝试编译的代码很简单 #include <iostream> #include <yaml-cpp/yaml.h> using namespace std; int main() { YAML::Node test = YAML::LoadFile("test.yaml"); if (test["date"]) { cout << "HELLO"; } return 0; } 我使用的 YAML 是来自 http://www.yaml.org/start.html 的示例 如果我只是尝试加载 YAML,它会加载得很好。但如果我尝试访问任何数据,我会得到同样的错误。所以这不是链接问题。 编辑:我可以执行诸如 cout << test 和 cout << test.type() 之类的操作以及其他功能。我认为问题在于使用基于字符串的映射来访问内部节点。 您似乎没有正确链接yaml-cpp库。编译时添加参数-lyaml-cpp。例如: g++ -I/usr/local/include -L/usr/local/lib -lyaml-cpp -o test main.cpp 编辑 另一种选择是将此 cmake 包含到您的 CMakeLists.txt 中: # attempt to find static library first if this is set if(YAMLCPP_STATIC_LIBRARY) set(YAMLCPP_STATIC libyaml-cpp.a) endif() # find the yaml-cpp include directory find_path(YAMLCPP_INCLUDE_DIR yaml-cpp/yaml.h PATH_SUFFIXES include PATHS ~/Library/Frameworks/yaml-cpp/include/ /Library/Frameworks/yaml-cpp/include/ /usr/local/include/ /usr/include/ /sw/yaml-cpp/ # Fink /opt/local/yaml-cpp/ # DarwinPorts /opt/csw/yaml-cpp/ # Blastwave /opt/yaml-cpp/ ${YAMLCPP_DIR}/include/) # find the yaml-cpp library find_library(YAMLCPP_LIBRARY NAMES ${YAMLCPP_STATIC} yaml-cpp PATH_SUFFIXES lib64 lib PATHS ~/Library/Frameworks /Library/Frameworks /usr/local /usr /sw /opt/local /opt/csw /opt ${YAMLCPP_DIR}/lib) # handle the QUIETLY and REQUIRED arguments and set YAMLCPP_FOUND to TRUE if all listed variables are TRUE include(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(YAMLCPP DEFAULT_MSG YAMLCPP_INCLUDE_DIR YAMLCPP_LIBRARY) mark_as_advanced(YAMLCPP_INCLUDE_DIR YAMLCPP_LIBRARY) 我在 Debian 系统上尝试编译 OpenXcom 时遇到了类似的情况。事实证明,我混合使用了测试包和稳定包,yaml 包来自稳定包,如果初始功能不止几个,那么这种组合会以某种方式导致链接失败。 如果这就是您遇到的情况(并且您也在使用 Debian),请尝试使用 从稳定版编译源代码包 apt-get --build source libyaml-cpp0.5/stable 此命令将为 libyaml 构建 .deb 包,然后您可以使用 dpkg 插入它们,如下所示: dpkg -i libyaml-cpp0.5*.deb 作为根。 从源代码编译 libyaml 将使其链接到您已有的测试库,而不是期望稳定的库,因此应该可以解决上述问题。至少对我来说是这样。 即使您不使用 Debian,出于类似的原因,从源代码(例如 tarball)编译 yaml-cpp 也可能有效。 确保这两个文件存在: /usr/local/lib/libyaml-cpp.a /usr/local/include/yaml-cpp/yaml.h 我的CMakeLists.txt: CMAKE_MINIMUM_REQUIRED(VERSION 3.4) FIND_PACKAGE(yaml-cpp REQUIRED) ADD_EXECUTABLE(yaml_cpp_test yaml_cpp_test.cpp) TARGET_LINK_LIBRARIES(yaml_cpp_test yaml-cpp) yaml_cpp_test.cpp 的内容与问题中提到的相同。 我尝试在 vps 上重现该问题(Ubuntu 14.04.1 LTS) wget -c https://github.com/jbeder/yaml-cpp/archive/release-0.5.1.tar.gz tar xvf release-0.5.1.tar.gz yaml-cpp-release-0.5.1/ cd yaml-cpp-release-0.5.1/ sudo apt-get install cmake sudo apt-get install libboost-dev cmake . make make install 之后,yaml-cpp 安装到 /usr/local/lib 和 /usr/local/include 我的工作目录中的文件: fqlgy@li407-86:~/yaml-cpp$ ll total 12 -rw-r--r-- 1 fqlgy fqlgy 162 May 8 03:29 CMakeLists.txt -rw-r--r-- 1 fqlgy fqlgy 10 May 8 03:11 test.yaml -rw-r--r-- 1 fqlgy fqlgy 240 May 8 03:11 yaml_cpp_test.cpp 当我尝试运行“cmake .”时,出现一些错误,所以我删除了行CMakeFiles/CMakeOutput.log,CMakeLists.txt的内容是: CMAKE_MINIMUM_REQUIRED(VERSION 2.6) ADD_EXECUTABLE(yaml_cpp_test yaml_cpp_test.cpp) TARGET_LINK_LIBRARIES(yaml_cpp_test yaml-cpp) 以下输出符合预期: fqlgy@li407-86:~/yaml-cpp$ cmake . -- Configuring done -- Generating done -- Build files have been written to: /home/fqlgy/yaml-cpp fqlgy@li407-86:~/yaml-cpp$ make Scanning dependencies of target yaml_cpp_test [100%] Building CXX object CMakeFiles/yaml_cpp_test.dir/yaml_cpp_test.cpp.o Linking CXX executable yaml_cpp_test [100%] Built target yaml_cpp_test fqlgy@li407-86:~/yaml-cpp$ ./yaml_cpp_test HELLO 我确认某些版本的 yaml-cpp 库包含此问题(并且与不正确的链接无关)。 它相当脏,但我已经通过在代码中定义空函数来解决它,它看起来像 YAML::BadConversion::~BadConversion() { } void YAML::detail::node_data::convert_to_map(std::shared_ptr<YAML::detail::memory_holder>) { } 该方法并不完美(例如,因为如果使用另一个库版本,它会导致重复)。 就我而言,我在两台计算机上运行完全相同的代码,但仅在其中一台计算机上出现错误,这几乎让我发疯。这不是编译错误、链接错误什么的,我认为代码很脏或者其他什么。 我尝试了所有选项: 从源代码常规构建并使用 cmake .. => make => make install 安装 与 1 相同,带有 CC=$(which gcc) CXX=$(which g++) cmake -DBUILD_SHARED_LIBS=ON .. 从 apt 卸载默认包(我使用 ubuntu 16.04) 全部失败,直到我找到 Ilya Golshtein 的答案,然后在我将使用 yaml-cpp 的代码中,我在YAML::LoadFIle行之前添加了这段代码 YAML::BadConversion::~BadConversion() { } void YAML::detail::node_data::convert_to_map(std::shared_ptr<YAML::detail::memory_holder>) { } 这是唯一有效的解决方案 我来晚了,不知道我在做什么,但对于 Windows 上的用户,请确保您的 IDE 喜欢您的 mingw-g++。我的自动默认为草莓 Perl(?),当我将其更改为 mingw-g++ 时,一切都开始工作。我想这与版本控制有关? 这也困扰着我。我在 yaml-cpp 版本为“0.7.0”时遇到了它。我用“0.6.0”代替解决了这个问题。 就我而言,这是安装多个库的问题。我已经安装了 ROS,它似乎也随 yaml-cpp 一起提供。不同版本之间的冲突引发了未定义的引用错误。 卸载我添加的所有 yaml-cpp 版本解决了该问题。

回答 8 投票 0

如何在Qt项目中链接库?

我正在尝试将 libirimager 库中的 directshow 示例的一部分添加到我自己的 Qt 项目中。我无法链接 IRImager 类。 sdk 目录中只有头文件 IRImager.h。在我的 main.cpp 中,我刚刚添加了

回答 1 投票 0

对函数的未定义引用,但已全部定义

我在创建库后运行多个文件时遇到问题,在本例中我将其称为“calcola.h”。 对我来说似乎没问题,但是错误“未定义的错误 somma,错误:ld

回答 1 投票 0

在构建 OpenMPL 项目时未定义对“boost::timer”库的引用

我正在尝试构建 OpenMPL 项目。但是,boost 库会发生一些错误 [ 99%] 链接 CXX 可执行文件 OpenMPL CMakeFiles/OpenMPL.dir/main.cpp.o:在函数“main”中: main.cpp:(.text.

回答 0 投票 0

间接引用MSYS2的APR库中的符号

我最终正在尝试构建和利用使用 MinGW 构建的 log4cxx 库。我已经用 MSYS2 和 MinGW 构建了它。但是,当我尝试使用(链接)它时,我得到了一堆未定义的引用......

回答 0 投票 0

链接器中的 PCL 未定义引用

我正在尝试从点云数据中使用 SurfaceReconstruction,这是我的代码 #包括 #包括 #包括 #包括 我正在尝试从点云数据中使用 SurfaceReconstruction,这是我的代码 #include <pcl/point_types.h> #include <pcl/io/pcd_io.h> #include <pcl/io/ply_io.h> #include <pcl/surface/marching_cubes_hoppe.h> int main(int argc, char** argv) { // Open the input text file std::ifstream input_file("prereq/model.txt"); // Create a PCL point cloud object to store the points pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>); // Parse the text file line by line to extract the point coordinates std::string line; while (std::getline(input_file, line)) { std::istringstream iss(line); float x, y, z; if (!(iss >> x >> y >> z)) { // Handle parsing error break; } // Add the point to the PCL point cloud object cloud->push_back(pcl::PointXYZ(x, y, z)); } // Create a set of triangular meshes using the Marching Cubes algorithm pcl::PolygonMesh triangles; pcl::MarchingCubesHoppe<pcl::PointXYZ> mc; mc.setInputCloud(cloud); mc.setIsoLevel(0.025); mc.reconstruct(triangles); pcl::io::savePLYFile("output_mesh.ply", triangles); return 0; } 当我尝试使用命令构建它时 g++ hmm.cpp -o a.out -I/usr/include/pcl-1.12/ -I/usr/include/eigen3 -lpcl_common -lpcl_io -lpcl_surface -lpcl_visualization -lpcl_octree -lpcl_recognition -lpcl_segmentation -lpcl_registration -lpcl_tracking -lpcl_search -lpcl_common -lpcl_surface -lpcl_kdtree -lpcl_features -lpcl_filters 它给了我错误 /usr/bin/ld: /tmp/ccPoS1h1.o: in function `main': hmm.cpp:(.text+0x2d1): undefined reference to `pcl::MarchingCubesHoppe<pcl::PointXYZ>::~MarchingCubesHoppe()' /usr/bin/ld: hmm.cpp:(.text+0x3ba): undefined reference to `pcl::MarchingCubesHoppe<pcl::PointXYZ>::~MarchingCubesHoppe()' /usr/bin/ld: /tmp/ccPoS1h1.o:(.data.rel.ro._ZTVN3pcl18MarchingCubesHoppeINS_8PointXYZEEE[_ZTVN3pcl18MarchingCubesHoppeINS_8PointXYZEEE]+0x10): undefined reference to `pcl::MarchingCubesHoppe<pcl::PointXYZ>::~MarchingCubesHoppe()' /usr/bin/ld: /tmp/ccPoS1h1.o:(.data.rel.ro._ZTVN3pcl18MarchingCubesHoppeINS_8PointXYZEEE[_ZTVN3pcl18MarchingCubesHoppeINS_8PointXYZEEE]+0x18): undefined reference to `pcl::MarchingCubesHoppe<pcl::PointXYZ>::~MarchingCubesHoppe()' /usr/bin/ld: /tmp/ccPoS1h1.o:(.data.rel.ro._ZTVN3pcl18MarchingCubesHoppeINS_8PointXYZEEE[_ZTVN3pcl18MarchingCubesHoppeINS_8PointXYZEEE]+0x60): undefined reference to `pcl::MarchingCubes<pcl::PointXYZ>::performReconstruction(pcl::PolygonMesh&)' /usr/bin/ld: /tmp/ccPoS1h1.o:(.data.rel.ro._ZTVN3pcl18MarchingCubesHoppeINS_8PointXYZEEE[_ZTVN3pcl18MarchingCubesHoppeINS_8PointXYZEEE]+0x68): undefined reference to `pcl::MarchingCubes<pcl::PointXYZ>::performReconstruction(pcl::PointCloud<pcl::PointXYZ>&, std::vector<pcl::Vertices, std::allocator<pcl::Vertices> >&)' /usr/bin/ld: /tmp/ccPoS1h1.o:(.data.rel.ro._ZTVN3pcl18MarchingCubesHoppeINS_8PointXYZEEE[_ZTVN3pcl18MarchingCubesHoppeINS_8PointXYZEEE]+0x70): undefined reference to `pcl::MarchingCubesHoppe<pcl::PointXYZ>::voxelizeData()' /usr/bin/ld: /tmp/ccPoS1h1.o:(.data.rel.ro._ZTVN3pcl18MarchingCubesHoppeINS_8PointXYZEEE[_ZTVN3pcl18MarchingCubesHoppeINS_8PointXYZEEE]+0x78): undefined reference to `pcl::MarchingCubes<pcl::PointXYZ>::getGridValue(Eigen::Matrix<int, 3, 1, 0, 3, 1>)' /usr/bin/ld: /tmp/ccPoS1h1.o:(.data.rel.ro._ZTVN3pcl13MarchingCubesINS_8PointXYZEEE[_ZTVN3pcl13MarchingCubesINS_8PointXYZEEE]+0x60): undefined reference to `pcl::MarchingCubes<pcl::PointXYZ>::performReconstruction(pcl::PolygonMesh&)' /usr/bin/ld: /tmp/ccPoS1h1.o:(.data.rel.ro._ZTVN3pcl13MarchingCubesINS_8PointXYZEEE[_ZTVN3pcl13MarchingCubesINS_8PointXYZEEE]+0x68): undefined reference to `pcl::MarchingCubes<pcl::PointXYZ>::performReconstruction(pcl::PointCloud<pcl::PointXYZ>&, std::vector<pcl::Vertices, std::allocator<pcl::Vertices> >&)' /usr/bin/ld: /tmp/ccPoS1h1.o:(.data.rel.ro._ZTVN3pcl13MarchingCubesINS_8PointXYZEEE[_ZTVN3pcl13MarchingCubesINS_8PointXYZEEE]+0x78): undefined reference to `pcl::MarchingCubes<pcl::PointXYZ>::getGridValue(Eigen::Matrix<int, 3, 1, 0, 3, 1>)' collect2: error: ld returned 1 exit status 我什至尝试过 cmake cmake_minimum_required(VERSION 3.10) project(pointcloud-to-mesh) find_package(PCL 1.12 REQUIRED COMPONENTS common io surface) add_executable(pointcloud-to-mesh hmm.cpp) target_include_directories(pointcloud-to-mesh PRIVATE ${PCL_INCLUDE_DIRS}) target_link_libraries(pointcloud-to-mesh PRIVATE ${PCL_LIBRARIES}) GreedyProjectionTriangulation 和 Poisson 的相同类型的错误。 我在这里做错了什么?我使用 apt 安装了 pcl(我在 ubuntu 上) 不能将MarchingCubesHoppe与pcl::PointXYZ一起使用。你必须使用pcl::PointNormal或pcl::PointXYZRGBNormal或pcl::PointXYZINormal. 另见官方文档:https://pointclouds.org/documentation/classpcl_1_1_marching_cubes_hoppe.html#details

回答 1 投票 0

无法构建 GnuTLS,未定义对 gmp 的引用

我想试用 GnuTLS (3.6.15)。我安装了 p11-kit、nettle 和 gmp。对于 libtasn1 和 unistring,我使用了 ./configure 标志(--with-included-unistring 和 --with-included-libtasn1)。完整调用 ./

回答 3 投票 0

Protobuf 库的 CMake 编译错误:对 `google::protobuf::Message::GetTypeName() const' 的未定义引用

我正在尝试使用同时利用 Protobuf 和 Open3D 库的 CMake 编译一个项目。但是,在编译过程中,我遇到了以下错误: ➜ 构建 git:(d...

回答 0 投票 0

Qt 项目不编译,未定义引用

Main.cpp #包括 int main (int argc, char* argv[]) { QApplication应用程序(argc,argv); 返回 app.exec(); } 测试.pro 来源 += \ 主.cpp 大于(QT_MAJOR_VER ...

回答 1 投票 0

在 C++ 环境中添加 SDL2 库时出现“对‘WinMain@16’的未定义引用”

我一直在努力让 SDL2 在我的环境中工作,但没有成功。我正在使用带有 MinGW 的 Windows 10 Home,在 Eclipse IDE 中为 C/C++ 开发人员工作。 我从这个G下载了SDL2.26.4...

回答 0 投票 0

我在设置 sdl2 时在 vs 代码中遇到链接错误

我正在尝试将 sdl2 设置为 vs 代码,但出现以下错误: 警告:PowerShell 检测到您可能正在使用屏幕阅读器,并出于兼容性目的禁用了 PSReadLine。如果你...

回答 0 投票 0

创建对象和调用方法时出现未定义引用错误(VS Code)[重复]

我是 VS 代码的初学者,所以我无法解决这个问题,我一直收到此错误消息: C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-

回答 0 投票 0

旧的GCC不能自动找到新版本的libstdc++?

我正在尝试将名为 DocToText 的第 3 方库与 gcc 4.4.7 一起使用。 我编译了程序: g++ -I./doctotext/ -L./doctotext/ -Wl,-rpath=./doctotext -ldoctotext -o 示例 test_doctotext.c...

回答 3 投票 0

© www.soinside.com 2019 - 2024. All rights reserved.