undefined-reference 相关问题

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

错误:以数组和函数指针作为参数的函数的“未定义引用”

每次调用force函数时,我都会得到一个未定义的引用; collect2:错误:ld 返回 1 退出状态。 以下是 main.cpp 中 main 函数上方的强制函数的声明: 无效...

回答 1 投票 0

对 raspicam 的未定义引用

我在 geany 编译器中的相机初始化中遇到了一些错误 g++ $(pkg-config opencv4 --cflags --libs) -o g++ $(pkg-config raspicam --cflags --libs) -ocameratestcameratest.cpp (在导演中...

回答 1 投票 0

未定义的引用

链接器错误: $ 制作 g++ -Wall -g main.cpp SDL_Helpers.cpp Game.cpp DrawableObject.cpp `sdl-config --cflags --libs` -lSDL_mixer /tmp/ccdxzrej.o:在函数“游戏”中: /home/brett/Desktop/SDL/Game.cp...

回答 3 投票 0

“对‘A::A(int,int)’的未定义引用:从包含的标头创建类的对象时

我正在尝试使用另一个文件中的对象,但尽管包含了适当的头文件,但我仍然收到未定义的引用错误。我在 Li 上使用带有 C++ CDT 插件的 Eclipse...

回答 3 投票 0

未定义使用 mingw 对 imp 的引用

我遇到的问题是构建项目时出现的“未定义引用‘_imp__...’”错误。我使用的是 Windows 7、MinGW、Eclipse 以及我没有制作的 .lib 和 .dll 文件,但我...

回答 2 投票 0

使用 extern 关键字未定义的引用变量

我在同一个文件夹中有两个C文件: 文件1.c #包括 整数a; int main() { a = 1; printf("%d",a); 返回0; } 文件2.c #包括 外部整数...

回答 1 投票 0

构建 GLEW 程序时未定义引用?

我设置了简单的 OpenGl 项目(Clion IDE,msys 的 g++ 编译器) 我下载了glfw和glew源文件,用mingw32-make手动编译它们。 由于链接问题仍然无法构建项目...

回答 1 投票 0

未定义对“WinMain@16”的引用?

我查看了其他解决方案,但我不知道为什么它这么说,因为我有一个 main. 我尝试过构建控制台应用程序和 GUI 应用程序。它应该是一个 GUI 应用程序(SDL)。 是不是一定要有...

回答 4 投票 0

在调试配置中使用 gcc 初始化静态 constexpr 自制字符串变量时出现未定义符号,C++14

我无法理解使用 gcc 的 C++14 中的链接器错误。 我的目的是拥有一个根据非类型模板参数公开名称的模板(一种

回答 1 投票 0

MinGW32 无法配置源:“未定义对‘信号’等的引用

去年我在 MinGW 上构建了一些源代码,没有任何问题。现在,当我尝试使用另一个参数重新配置此源时,我得到了(config.log 中 libjansson-2.10 的 ./configure 的部分输出):

回答 1 投票 0

链接器找不到 clGetPlatformIDs()?

我正在尝试使用 AMD OCL SDK 编译一个简单的 OpenCL 测试程序: #包括 #包括 int main() { cl_platform_id 平台; cl_device_id 设备; c...

回答 1 投票 0

未定义对构造函数的引用,即使构造函数是默认的并且所有内容都正确链接

我是 C++ 的初学者(做了一点点,但仍然相对较新),所以这可能是显而易见的事情,但我遇到了一个错误,我似乎无法在网上找到任何解决方案。 我是...

回答 1 投票 0

VScode 中未定义的引用错误

我正在测试如何在 C 中使用 extern ,因此我为 main.c、test.c、headfile.h 创建了三个文件。我想在 headfile.h 中声明变量和函数,在 test.c 中定义,然后打印出变量...

回答 3 投票 0

ld 失败,因为 libselinux 未定义对 gettid@GLIBC_2.30 的引用

我正在尝试从源代码构建 glibc 2.24。主机操作系统是WSL Ubuntu 20.04,编译器是gcc 9。 尝试链接 glibc 的 nss 模块时,ld 实用程序失败: /usr/bin/ld: /usr/lib/gcc/x86_64-

回答 3 投票 0

Zig 生成的 C 代码由于缺少函数(软浮点)而在链接阶段失败

我有一个用 Zig 编写的程序,但运行该程序的系统没有 Zig 编译器。 我将程序导出为 C 代码(通过 ofmt = c 功能),然后使用 gcc 或 clang 对其进行编译。 哪个

回答 1 投票 0

对 cv::aruco::getPredefinedDictionary(cv::aruco::PredefinedDictionaryType) 的未定义引用

我正在尝试在 Qt 中编写一个程序,该程序从 TCP 接收图像,然后在其中找到 ArUco 标记。 除了 ArUco 库之外,一切正常。一旦我添加了一个简单的线条定义...

回答 1 投票 0

friend 声明声明了一个非模板函数,未定义的引用

我有这样的模板类,其中包含一个friend方法: 模板 类图最终 { 私人的: std::array 顶点; std::数组 我有这样的模板类,其中包含一个friend方法: template<class T1, class T2, int n> class Graph final { private: std::array<T1, n> vertex; std::array<std::array<T2, n>, n> arcs; public: Graph(const std::array<T1, n> & v, const std::array<std::array<T2, n>, n> & a); friend std::ostream & operator<<(std::ostream & os, const Graph<T1, T2, n> & g); }; template<class T1, class T2, int n> Graph<T1, T2, n>::Graph(const std::array<T1, n> & v, const std::array<std::array<T2, n>, n> & a) : vertex(v) { ... } template<class T1, class T2, int n> std::ostream & operator<<(std::ostream & os, const Graph<T1, T2, n> & g) { ... } 该类用于保存图形。 Vertex是一个存储节点的数组,T1是对应的元素类型。 Arcs 是一个 n * n 的二维数组,存储节点之间的路径开销,T2 是对应的元素类型。(注意,n 是模板非类型参数。) 我尝试创建一个Graph并调用这样的朋友方法: void test() { using std::array; array<int, 5> vertex = {100, 200, 300, 400, 500}; array<int, 5> a = {2, 3, 2, 4, 5}; array<array<int, 5>, 5> arcs = {a, a, a, a, a}; Graph<int, int, 5> g(vertex, arcs); std::cout << g << std::endl; } 只得到错误: tree_mst.h:31:87: warning: friend declaration ‘std::ostream& meyok::operator<<(std::ostream&, const Graph<T1, T2, n>&)’ declares a non-template function [-Wnon-template-friend] friend std::ostream & operator<<(std::ostream & os, const Graph<T1, T2, n> & g); ^ tree_mst.h:31:87: note: (if this is not what you intended, make sure the function template has already been declared and add <> after the function name here) ../lib/libmtree.so: undefined reference to `operator<<(std::ostream&, Graph<int, int, 5ull> const&)' ../lib/libmtree.so: undefined reference to `Graph<int, int, 5ull>::Graph(std::array<int, 5ul> const&, std::array<std::array<int, 5ul>, 5ul> const&)' 为什么这里会弹出警告和错误。我该如何解决? friend声明为Graph的每个实例声明一个名为operator<<的常规非模板函数,并将此实例化作为参数。例如,您的程序使用 Graph<int, int, 5> - 当编译器第一次看到它时,它会生成一个声明 std::ostream & operator<<(std::ostream & os, const Graph<int, int, 5>& g); 请注意,这与您的 operator<< 函数模板是分开且不同的。 然后编译器会看到 std::cout << g 并执行重载决策来为 operator<< 选择最佳重载。由于非模板函数优于函数模板,因此在其他条件相同的情况下,选择由 friend 声明引入的函数。最后,链接器发现这个函数从未被实际实现过;因此出现错误。 最有可能的是,您的意思是与 operator<< 模板参数匹配的 Graph 函数模板的特化应该是该 Graph 特化的友元。你这样表达: // Forward declaration template<class T1, class T2, int n> class Graph; // Forward declaration template<class T1, class T2, int n> std::ostream & operator<<(std::ostream & os, const Graph<T1, T2, n> & g); template<class T1, class T2, int n> class Graph { public: friend std::ostream & operator<< <T1, T2, n>(std::ostream & os, const Graph<T1, T2, n> & g); }; 但是,完全避免 friend 并将 operator<< 委托给成员函数通常更简单: template<class T1, class T2, int n> class Graph { public: void print(std::ostream& os) const { /* actual output logic here */); }; template<class T1, class T2, int n> std::ostream& operator<<(std::ostream& os, const Graph<T1, T2, n>& g) { g.print(os); return os; }

回答 1 投票 0

log4cxx 对 `log4cxx::Logger::getLogger(char const*)' 的未定义引用

据我所知,我在 Ubuntu Netbeans 下有 2 个相同的 cpp 项目。 记录器测试项目 Cpp应用程序2 在两者的主文件中,我集成了以下代码: 编译结果

回答 1 投票 0

如何使用 CMake 链接 Clion 中的库?

我正在尝试用 C 显示图形,为此我想链接 SDL 库,但这是我第一次做这样的事情,我发现的一切都没有帮助。 我想...

回答 1 投票 0

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

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

回答 1 投票 0

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