标签: unresolved-external

无法解决的`R_X86_64_NONE`搬迁

我在CentOS 7上使用Devtoolset-7并且已经构建了Boost 1.65.1 w/it.但是当我链接我的应用程序时,我有以下内容:

/opt/rh/devtoolset-7/root/usr/libexec/gcc/x86_64-redhat-linux/7/ld: /opt/rh/devtoolset-7/root/usr/lib64/libboost_unit_test_framework.a(compiler_log_formatter.o)(.text._ZN5boost9unit_test5utils11string_castINS0_13basic_cstringIKcEEEESsRKT_[_ZN5boost9unit_test5utils11string_castINS0_13basic_cstringIKcEEEESsRKT_]+0x3c): unresolvable R_X86_64_NONE relocation against symbol `_ZTVSt9basic_iosIcSt11char_traitsIcEE@@GLIBCXX_3.4'
/opt/rh/devtoolset-7/root/usr/libexec/gcc/x86_64-redhat-linux/7/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
Run Code Online (Sandbox Code Playgroud)

搜索更多信息R_X86_64_NONE并没有给出任何有价值的结果:大多数类似的问题没有任何答案或精确解释这是什么以及如何解决它.

所以我的问题是:

  • 这个错误究竟意味着什么?
  • 是什么R_X86_64_NONE和为什么"没有任何重新定位"(根据bintils来源)ELF标题中存在的符号类型?

附录:

  • 链接单元测试可执行文件时出错,链接到我的静态库和Boosts的静态库(单元测试框架)
  • 所有静态库(Boost和我的一个)都内置了-fPIC选项

PS.我真的希望这个问题能够一次又一次地解决(已经打过几次,但这次更新到最新的binutils并没有帮助).(将对此问题的任何活动开始赏金)

c++ elf unresolved-external binutils

8
推荐指数
1
解决办法
1195
查看次数

未解决的外部问题

我有一个未解决的外部符号错误,这让我疯狂.简而言之,我有一个SDL_Surfaces包装类('DgSurface')和一个加载和存储DgSurfaces('DgSurfaceList')的类.尝试在我的项目中包含DgSurfaceList文件时出现链接问题.这是我的课程:

头文件"DgSurface.h"包含DgSurface类声明:

    #ifndef DGSURFACE_H
    #define DGSURFACE_H

    #include "SDL.h"
    #include <string>

    class DgSurface
    {
    public:

        //Constructor/destructor
        DgSurface(std::string N, SDL_Surface* I): image(I), name(N) {}
        DgSurface() {name = ""; image = NULL;}
        ~DgSurface();

        //Copy operations
        DgSurface(const DgSurface&);
        DgSurface& operator= (const DgSurface&);

        //Data members
        std::string name;       //The name of the image
        SDL_Surface* image;     //The image
    };

    #endif
Run Code Online (Sandbox Code Playgroud)

cpp文件"DgSurface.cpp"包含DgSurface定义:

#include "DgSurface.h"
#include "SDL.h"

//--------------------------------------------------------------------------------
//        Constructor
//--------------------------------------------------------------------------------
DgSurface::DgSurface(const DgSurface& other)
{
    //Copy name
    name = other.name;

    //Create new SDL_Surface 
    image = SDL_ConvertSurface(other.image, other.image->format, 0);
} …
Run Code Online (Sandbox Code Playgroud)

c++ linker sdl symbols unresolved-external

7
推荐指数
1
解决办法
4294
查看次数

由于"错误LNK2028:未解析的令牌......",我无法编译解决方案

我有一个用C++编程的DLL,以及用Visual C++编写的exe.

我将dll中的函数声明为:

string __declspec( dllexport ) ConfigureHAT(T_STRING pathFile);
Run Code Online (Sandbox Code Playgroud)

在exe项目中,我包含了所有头文件和dll文件.

我在dll中调用该函数:

string ret = ConfigureHAT("file.txt");
Run Code Online (Sandbox Code Playgroud)

当编译可执行项目时,它会因下一个错误而失败:

1> HATdllTester.obj:错误LNK2028:未解析的令牌(0A000317)"class std :: basic_string,class std :: allocator> __cdecl ConfigureHAT(class std :: basic_string,class std :: allocator>)"(?ConfigureHAT @@ $ $ FYA?AV?$ basic_string @ DU?$ char_traits @ D @ std @@ V?$ allocator @ D @ 2 @@ std @@ V12 @@ Z)在函数"private:void __clrcall HATdllTester :: mainWindow ::"中引用buttonConfigure_Click(类System :: Object ^,类System :: EventArgs ^)"(?buttonConfigure_Click @ mainWindow @ HATdllTester @@ $$ FA $ AAMXP $ AAVObject @ …

c++ unresolved-external visual-c++

7
推荐指数
1
解决办法
2万
查看次数

尝试针对旧STD库和Windows SDK进行编译时链接错误

我有一个在VS2005中编译的旧项目(可悲).它必须保留在VS2005中,以便它可以正确链接到另一个具有VS2005 CRT,MFC等的进程.

现在我需要使用旧的VS2005工具集在VS2015中编译这个项目.
我已将项目的VC++目录更改为所有STD和Windows SDK标头/库(包括目录,参考目录,库目录,源目录)的旧文件夹.

这个技巧曾经在使用VS2010时工作正常,但在VS2015上我遇到了一些奇怪的链接错误:

1>Project1.obj : error LNK2019: unresolved external symbol "void __stdcall `eh vector destructor iterator'(void *,unsigned int,unsigned int,void (__thiscall*)(void *))" (??_M@YGXPAXIIP6EX0@Z@Z) referenced in function "public: virtual void * __thiscall PluginInterface::`vector deleting destructor'(unsigned int)" (??_EPluginInterface@@UAEPAXI@Z)
1>     1>
1>StdAfx.obj : error LNK2001: unresolved external symbol "void __stdcall `eh vector destructor iterator'(void *,unsigned int,unsigned int,void (__thiscall*)(void *))" (??_M@YGXPAXIIP6EX0@Z@Z)
1>     1>
1>Project1.obj : error LNK2019: unresolved external symbol "void __cdecl operator delete(void *,unsigned int)" (??3@YAXPAXI@Z) referenced in function __unwindfunclet$?getInstance@Project1@@SAPAV1@XZ$0
1> …
Run Code Online (Sandbox Code Playgroud)

c++ linker visual-studio-2005 unresolved-external visual-studio-2015

7
推荐指数
1
解决办法
1439
查看次数

链接器错误:使用外部变量的函数模板中的未定义引用

我有一个包含两个文件的小项目:

主程序

#include <string>
template<int I>
int getint(int i)
{
    extern std::string var;
    return var.size() * i;
}

int main()
{
    return getint<2>(2);
}
Run Code Online (Sandbox Code Playgroud)

和子.cpp

#include <string>
extern std::string var;
std::string var = "Hello";
Run Code Online (Sandbox Code Playgroud)

但是当我编译项目时,链接器给出了错误:

-------------- Clean: Debug in test (compiler: GNU GCC Compiler)---------------

Cleaned "test - Debug"

-------------- Build: Debug in test (compiler: GNU GCC Compiler)---------------

mingw32-g++.exe -Wall -fexceptions -g  -c C:\Users\Fan\Downloads\test\test\main.cpp -o obj\Debug\main.o
mingw32-g++.exe -Wall -fexceptions -g  -c C:\Users\Fan\Downloads\test\test\sub.cpp -o obj\Debug\sub.o
mingw32-g++.exe  -o bin\Debug\test.exe obj\Debug\main.o obj\Debug\sub.o   
obj\Debug\main.o: In …
Run Code Online (Sandbox Code Playgroud)

c++ linker-errors unresolved-external function-templates

7
推荐指数
0
解决办法
185
查看次数

未解析的外部符号 __stdio_common_vswprintf

我正在编译使用 Microsoft Dmf 框架 (DmfK.lib) 的内核模式驱动程序

在上次 Visual Studio 更新之后,出现了一些奇怪的链接器错误:

EmulationTargetPDO.obj : error LNK2019: unresolved external symbol __stdio_common_vswprintf referenced in function _vsnwprintf_l
Utilities.lib(savedata.obj) : error LNK2001: unresolved external symbol __stdio_common_vswprintf
DmfK.lib(DmfUtility.obj) : error LNK2001: unresolved external symbol __stdio_common_vswprintf
EmulationTargetPDO.obj : error LNK2019: unresolved external symbol __stdio_common_vsprintf referenced in function _vsnprintf_l
DmfK.lib(DmfCore.obj) : error LNK2001: unresolved external symbol __stdio_common_vsprintf
DmfK.lib(Dmf_CrashDump.obj) : error LNK2019: unresolved external symbol __stdio_common_vsprintf_s referenced in function _vsprintf_s_l
Run Code Online (Sandbox Code Playgroud)

这是我使用的软件和套件版本(显示在 VS“关于”窗口中):

  • Microsoft Visual Studio Professional 2019 版本 16.10.0
  • Windows …

printf stdio wdk unresolved-external

7
推荐指数
1
解决办法
1436
查看次数

libpng中未解析的外部png_set_longjmp_fn

在动态加载libpng.dll时,从libpng13.dll升级到1.5版之后,编译器开始报告这个未解析的外部:png_set_longjmp_fn

我该怎么办呢?

unresolved-external libpng

6
推荐指数
2
解决办法
6199
查看次数

Python - 编译期间未解析的Py_Initialize

我已经静态编译了Python2.7而没有任何错误.要测试我的构建,我使用以下代码段:

#include "Python.h"
int main()
{
   Py_Initialize();
}
Run Code Online (Sandbox Code Playgroud)

我正在编译它:

$ gcc -static -I/path/to/python/header -L/path/to/my/staticpythonlib \ 
 -lpython2.7 -ldl -l_all_other_needed_lib /tmp/my_previous_snippet.c -o myouput
Run Code Online (Sandbox Code Playgroud)

但是,发生了错误.gcc声称着名undefined reference.

test.c :(.text + 0x1):对'Py_Initialize'的未定义引用

奇怪的是我使用带有详细标记的gcc(我不会在这里粘贴结果)并且编译器说,它使用的是我的libpython,但找不到引用.所以我列出了我的静态python2.7库的符号:

$ nm /path/to/pythonlib |grep Py_Initialize
frozenmain.o           U Py_Initialize
pythonrun.o  0000009e9 T Py_Initialize
pythonrun.o  000000052 T Py_Initialize_Ex
main.o                 U Py_Initialize
Run Code Online (Sandbox Code Playgroud)

我们可以看到,Py_Initializepythonrun.o中正确引用了它.但是我不知道编译器如何选择正确的目标文件.

我的问题是:

  1. 我怎么能确定gcc在我的.a lib中使用了正确的目标文件?
  2. 我的编译选项有什么问题吗?

谢谢你的帮助.

python gcc static-libraries unresolved-external

6
推荐指数
1
解决办法
5763
查看次数

如何解决错误LNK2019

我正在用C++发送一封简单的电子邮件.我从下面的链接下载了一个示例C++程序.http://cboard.cprogramming.com/cplusplus-programming/125655-sending-simple-email-cplusplus.html 示例程序在编译时似乎遇到以下错误.请帮我解决问题.

Error   8   error LNK2019: unresolved external symbol _send_mail referenced in function _wmain  

Error   9   error LNK2019: unresolved external symbol __imp__recv@16 referenced in function "int __cdecl connect_to_server(char const *)" (?connect_to_server@@YAHPBD@Z)    

Error   10  error LNK2019: unresolved external symbol __imp__connect@12 referenced in function "int __cdecl connect_to_server(char const *)" (?connect_to_server@@YAHPBD@Z) 

Error   11  error LNK2019: unresolved external symbol __imp__htons@4 referenced in function "int __cdecl connect_to_server(char const *)" (?connect_to_server@@YAHPBD@Z)    

Error   12  error LNK2019: unresolved external symbol __imp__socket@12 referenced in function "int __cdecl connect_to_server(char …
Run Code Online (Sandbox Code Playgroud)

c++ linker unresolved-external lnk2019

6
推荐指数
3
解决办法
10万
查看次数

什么是未定义的引用/未解析的外部符号错误以及如何在 Fortran 中修复它?

我正在尝试构建 Fortran 程序,但收到有关未定义引用或未解析的外部符号的错误。我看到了有关这些错误的另一个问题,但那里的答案大多特定于 C++。

使用 Fortran 编写时出现这些错误的常见原因是什么?如何修复/预防它们?


这是构建 Fortran 程序时出现的一系列错误的典型问题。如果您被推荐到这里,或者您的问题作为与此问题重复的问题而被关闭,您可能需要阅读几个答案中的一个或多个。从这个答案开始,它充当所提供解决方案的目录。

fortran linker-errors unresolved-external undefined-reference

6
推荐指数
2
解决办法
3578
查看次数