包含的库仍会导致"undefined reference"错误
Included libraries still cause "undefined reference" error
我已经在我的 Ubuntu 系统上安装了这个 http://www.sfml-dev.org/index.php 库。这些文件存储在/usr/local/include 中。
我的Eclipse确实在"包含GNU C++"下包含这些文件>>但是如果我构建程序,编译器会抱怨未定义的引用。
#include <SFML/System.hpp>
#include <iostream>
int main()
{
sf::Clock Clock;
return 0;
}
原因:
undefined reference to `sf::Clock::Clock()' main.cpp
猜猜我错过了什么?
我的第一个建议是对的。
这里记录了,你必须像这样编译:
g++ -c clock.cpp
g++ -o clock clock.o -lsfml-system
所以请将 -lsfml 系统添加到库中。
根据 SFML 教程,您需要使用 "-l" 指令链接到库。因此,请确保 eclipse 代表您执行此操作,如果没有,请尝试覆盖标志。
相关文章:
- 我的项目不会像"undefined reference to `grpc::g_core_codegen_interface'"那样使用未定义的引用错误进行编译
- Visual Studio Code "undefined reference to `WinMain@16'"
- 使用 MATLAB 编码器生成C++代码:编译错误"undefined reference to `rgb2gray_tbb_real64'"
- 为什么创建友元类的实例会导致"undefined reference to"错误?
- Tensorflow c++ api undefined reference to 'tflite::D efaultErrorReporter()'
- 为什么在使用 SDL2 时仍然收到'undefined reference'链接器错误?
- OpenCV undefined reference to 'cv::imread(cv::String const&, int)'
- Libcurl c++ "undefined reference to" (Windows/MinGW/g++)
- 尝试使用 extern "C" 调用 C 中的C++方法,得到"undefined reference to"对象的链接器错误
- build error : undefined reference to `yyFlexLexer::yyFlexLex
- 安卓 NDK 制造。数百"undefined reference error"
- 当我尝试进行TPC-E测试时,实用程序抱怨"undefined reference"
- 声明和定义函数静态会产生"undefined reference to function_name()"
- C++ : "undefined reference to"可能是因为CMake文件
- 包含<iostream>时"Undefined reference"错误
- CMake 'undefined reference' CERN-ROOT 的错误
- 生成错误:"cannot find target for file"和"undefined reference"
- AppData\Local\Temp\cc59LXDc.o:test1.cpp: undefined reference to 'constructNewObjectOfClass
- YAML-cpp 编译错误:"undefined reference to YAML::LoadFile"
- 添加 cpp11 插件时出现错误消息"Undefined reference to boost (...)"