标签: unresolved-external

什么是未定义的引用/未解析的外部符号错误,我该如何解决?

什么是未定义的参考/未解决的外部符号错误?什么是常见原因以及如何修复/预防它们?

随意编辑/添加您自己的.

c++ c++-faq linker-errors unresolved-external undefined-reference

1418
推荐指数
32
解决办法
52万
查看次数

目标文件中未解析的外部符号

在Visual Studio中编码期间,我得到了一个未解决的外部符号错误,我不知道该怎么做.我不知道出了什么问题.你能破译我吗?我应该在哪里寻找什么样的错误?

1>Form.obj : error LNK2019: unresolved external symbol "public: class Field * __thiscall Field::addField(class Field *)" (?addField@Field@@QAEPAV1@PAV1@@Z) referenced in function "public: void __thiscall Form::parse(class std::basic_stringstream<char,struct std::char_traits<char>,class std::allocator<char> > &)" (?parse@Form@@QAEXAAV?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
1>Form.obj : error LNK2019: unresolved external symbol "public: virtual void __thiscall Field::parse(class std::basic_stringstream<char,struct std::char_traits<char>,class std::allocator<char> > &)" (?parse@Field@@UAEXAAV?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function "public: __thiscall InputField::InputField(class std::basic_stringstream<char,struct std::char_traits<char>,class std::allocator<char> > &)" (??0InputField@@QAE@AAV?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
1>Form.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall Field::prompt(void)" (?prompt@Field@@UAEXXZ)
1>Form.obj : error LNK2001: unresolved external …
Run Code Online (Sandbox Code Playgroud)

c++ unresolved-external visual-studio visual-c++

170
推荐指数
9
解决办法
47万
查看次数

未解析的外部符号__imp__fprintf和__imp____iob_func,SDL2

有人可以解释一下

__imp__fprintf

__imp____iob_func

未解决的外部手段?

因为我在尝试编译时遇到这些错误:

1>SDL2main.lib(SDL_windows_main.obj) : error LNK2019: unresolved external symbol __imp__fprintf referenced in function _ShowError
1>SDL2main.lib(SDL_windows_main.obj) : error LNK2019: unresolved external symbol __imp____iob_func referenced in function _ShowError
1>E:\Documents\Visual Studio 2015\Projects\SDL2_Test\Debug\SDL2_Test.exe : fatal error LNK1120: 2 unresolved externals
Run Code Online (Sandbox Code Playgroud)

我已经可以说问题不在于连接错误.我已经正确地链接了所有内容,但由于某种原因它无法编译.

我正在尝试使用SDL2.

我正在使用Visual Studio 2015作为编译器.

我已链接到链接器中的SDL2.lib和SDL2main.lib - >输入 - >附加依赖项,我确保VC++目录是正确的.

c++ unresolved-external sdl-2 visual-studio-2015

102
推荐指数
9
解决办法
11万
查看次数

未解决的外部符号LNK2019

首先,我知道这个问题已经存在于整个网站上,但我已经看了几乎所有这些问题,似乎无法找出问题所在.这是在VS 2012.谢谢.

//Socket.h
#pragma once

#include <iostream>
#include <WinSock2.h>

using namespace std;

const int STRLEN = 256;

class Socket
{
    protected:
        WSADATA wsaData;
        SOCKET mySocket;
        SOCKET myBackup;
        SOCKET acceptSocket;
        sockaddr_in myAddress;
    public:
        Socket();
        ~Socket();
        bool SendData( char* );
        bool RecvData( char*, int );
        void CloseConnection();
        void GetAndSendMessage();
};

class ServerSocket : public Socket
{
    public:
        void Listen();
        void Bind( int port );
        void StartHosting( int port );
};

class ClientSocket : public Socket
{
    public:
        void ConnectToServer( const char *ipAddress, …
Run Code Online (Sandbox Code Playgroud)

c++ linker linker-errors unresolved-external visual-studio

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

node-express app.get()在webstorm中标记为未解析

如果你遵循JetBrains公司在WebStorm入门Node.js的指示,节点表达特定的代码是否正确突出.但是,如果您创建自己的简单节点表达项目,例如使用node-express' 指南,则表示特定功能,例如app.get()带下划线并标有以下警告:

Unresolved function or method get()
Run Code Online (Sandbox Code Playgroud)

即使您启用以下库,也会发生这种情况Settings\JavaScript\Libraries:

  • Node.js Globals
  • Node.js v0.10.31核心模块
  • express-DefinitelyTyped(你需要下载)

如何配置WebStorm来解析节点表达功能,例如app.get()

unresolved-external express webstorm

34
推荐指数
3
解决办法
1万
查看次数

使用libcurl链接程序时未解析的符号

我知道这是编程问题,但我只是沮丧地想弄清楚我做错了什么..

我正在使用visual studio 2010并按照这里的所有步骤操作:http://curl.haxx.se/libcurl/c/visual_studio.pdf

当我尝试编译我的解决方案时,我不断收到此错误:

1>------ Build started: Project: LibCurl, Configuration: Debug Win32 ------
1>LibCurl.obj : error LNK2019: unresolved external symbol __imp__curl_easy_cleanup referenced in function _main
1>LibCurl.obj : error LNK2019: unresolved external symbol __imp__curl_easy_perform referenced in function _main
1>LibCurl.obj : error LNK2019: unresolved external symbol __imp__curl_easy_setopt referenced in function _main
1>LibCurl.obj : error LNK2019: unresolved external symbol __imp__curl_easy_init referenced in function _main
1>C:\Users\Kyle\Documents\Visual Studio 2010\libcurl\VisualStudio\LibCurl\Debug\LibCurl.exe : fatal error LNK1120: 4 unresolved externals
========== Build: 0 succeeded, 1 …
Run Code Online (Sandbox Code Playgroud)

c curl unresolved-external visual-studio

30
推荐指数
5
解决办法
4万
查看次数

未解决的外部符号 - Qt创建者

我必须缺少一个带头文件的基本概念,因为当我尝试从单独的源文件调用最简单的函数时,我得到一个错误:

main.obj:-1:错误:LNK2019:函数_main中引用的未解析的外部符号"void __cdecl buildDeck(int,int)"(?buildDeck @@ YAXHH @ Z)

加入deck.h

#ifndef DECK_H
#define DECK_H
#include <QString>


void buildDeck(int deckSize, int jokers);


struct card
{
    QString suit;
    QString color;
    int rank;
};

#endif // DECK_H
Run Code Online (Sandbox Code Playgroud)

deck.cpp

#include"mainwindow.h"
#include "deck.h"

void buildDeck(int deckSize, int jokers)
{
    int blackRed = deckSize-=jokers;
}
Run Code Online (Sandbox Code Playgroud)

main.cpp中

#include "mainwindow.h"
#include "deck.h"
#include <QApplication>
#include <QPushButton>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    MainWindow w;
    w.show();

    buildDeck(10,20);

    return a.exec();
}
Run Code Online (Sandbox Code Playgroud)

这给了我一个错误.但是,如果我将函数定义从deck.cpp移动到main.cpp的底部,那么应用程序将构建.

所有文件都包含在同一个项目中,并存储在同一目录中.

其他文件:

.pro文件

QT       += core …
Run Code Online (Sandbox Code Playgroud)

c++ qt unresolved-external

25
推荐指数
1
解决办法
4万
查看次数

使用向量和查找时,C++中未解析的外部

我在一个完全独立的项目中尝试了这个代码,它工作正常(唯一的区别是不工作的项目被导出为DLL).这是代码:

RTATMATHLIB.CPP

#include "stdafx.h"
#include "RTATMATHLIB.h"
#include <math.h>
#include <vector>
#include <algorithm>
#include <stdexcept>

using namespace std;

double someFunc(double** Y, int length)
{
    vector<double> myVector;

    for(int i = 0; i < length; i++)
    {
        double value = (*Y)[i];

        vector<double>::iterator it = find(myVector.begin(), myVector.end(), value);

        if(it != myVector.end())
        {
            continue;
        }
        else
        {
            myVector.push_back(value);
        }
    }
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

RTATMATHLIB.H

__declspec(dllexport) double someFunc(double** Y, int length);
Run Code Online (Sandbox Code Playgroud)

错误

Error   1   error LNK2019: unresolved external symbol __imp___CrtDbgReportW referenced in function "public: __thiscall std::_Vector_const_iterator<double,class …
Run Code Online (Sandbox Code Playgroud)

c++ find unresolved-external stdvector

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

'LIBCMT'与使用其他库+未解析的外部符号冲突

我有一个使用OpenGL 3.2(+ libs)和FreeType2的程序.然后用Boost和OpenSSL编写另一个程序.OpenGL方面是为了确保文本可以呈现,而boost/openssl程序是为了安全登录/游戏服务器.

两个程序都可以通过他们的自我运作.

然而,将Boost和OpenSSL添加到游戏(GL + freetype)项目导致它无法链接.

我已经链接了以下的库以及包含文件夹的文件夹.

glimg.lib glutil.lib glfw.lib opengl32.lib freetype.lib glew32.lib user32.lib libeay32.lib ssleay32.lib

链接器错误是.

1>LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library
1>libeay32.lib(cryptlib.obj) : error LNK2001: unresolved external symbol __imp__DeregisterEventSource@4
1>libeay32.lib(cryptlib.obj) : error LNK2001: unresolved external symbol __imp__ReportEventA@36
1>libeay32.lib(cryptlib.obj) : error LNK2001: unresolved external symbol __imp__RegisterEventSourceA@8
1>libeay32.lib(rand_win.obj) : error LNK2001: unresolved external symbol __imp__DeleteDC@4
1>libeay32.lib(rand_win.obj) : error LNK2001: unresolved external symbol __imp__DeleteObject@4
1>libeay32.lib(rand_win.obj) : error LNK2001: unresolved external symbol __imp__GetBitmapBits@12 …
Run Code Online (Sandbox Code Playgroud)

c++ linker-errors visual-studio-2010 unresolved-external linker-warning

17
推荐指数
2
解决办法
3万
查看次数

为什么这个虚拟析构函数会触发一个未解析的外部?

考虑以下:

Xh:

class X
{
    X();
    virtual ~X();
};
Run Code Online (Sandbox Code Playgroud)

X.cpp:

#include "X.h"

X::X()
{}
Run Code Online (Sandbox Code Playgroud)

尝试构建这个(我使用的是.dll目标,以避免在丢失的main上出现错误,我正在使用Visual Studio 2010):

错误1错误LNK2001:未解析的外部符号"private:virtual __thiscall X :: ~X(void)"(?? 1X @@ EAE @ XZ)

然而,小的修改导致成功构建:

XH:

class X
{
    inline X(); // Now inlined, and everything builds
    virtual ~X();
};
Run Code Online (Sandbox Code Playgroud)

要么

XH:

class X
{
    X();
    ~X(); // No longer virtual, and everything builds
};
Run Code Online (Sandbox Code Playgroud)

当.dtor是虚拟的或者.ctor没有内联时,是什么导致链接器中未解析的外部?

编辑:

或者,或许更有趣的是,如果我将析构函数设置为非虚拟,或者如果我内联构造函数,为什么我没有得到未解析的外部?

c++ destructor virtual-functions unresolved-external

15
推荐指数
3
解决办法
1万
查看次数