c ++-LNK2001无法解析的外部符号

时间:2019-12-02 16:30:09

标签: c++ class static lnk2001

已解决-> Object file location of Visual Studio C++ project

我的C ++ dll中出现LNK2001错误,我不知道为什么得到它。 我正在使用Visual Studio Community 2019

未解决的外部符号“ public:静态无效__cdecl UI :: d3d :: utils_t1 :: draw_box(struct IDirect3DDevice9 *,int,int,unsigned int,unsigned int,unsigned int,unsigned long)”(?draw_box @ utils_t1 @ d3d @ UI @@ SAXPAUIDirect3DDevice9 @@ HHIIIK @ Z)

  • 两个文件都在同一文件夹中
  • 两个文件都包含在解决方案中
  • Visual Studio显示它已声明

utils.hpp

#ifndef D3DUTILS_H
#define D3DUTILS_H

#include <cstdint>
#include <vector>
#include <d3d9.h>
#include <d3dx9.h>

#include "../../Math/vector.hpp"

#pragma comment(lib, "d3dx9.lib")

namespace UI {
    namespace d3d {
        class utils_t1 {
        public:
            static void fill_rgb(LPDIRECT3DDEVICE9 device, int32_t x, int32_t y, uint32_t width, uint32_t height, D3DCOLOR color);
            static void draw_box(LPDIRECT3DDEVICE9 device, int32_t x, int32_t y, uint32_t width, uint32_t height, uint32_t thickness, D3DCOLOR color);
        };
    }
}

#endif // !D3DUTILS_H

utils.cpp

#include "pch.h"
#include "utils.hpp"

namespace UI {
    namespace d3d {
        void utils_t1::fill_rgb(LPDIRECT3DDEVICE9 device, int32_t x, int32_t y, uint32_t width, uint32_t height, D3DCOLOR color) {

            D3DRECT rec = {
                x,
                y,
                x + width,
                y + height
            };
            device->Clear(1, &rec, D3DCLEAR_TARGET, color, 0, 0);
        }

        void utils_t1::draw_box(LPDIRECT3DDEVICE9 device, int32_t x, int32_t y, uint32_t width, uint32_t height, uint32_t thickness, D3DCOLOR color) {

            fill_rgb(device, x, y, width, thickness, color);
            fill_rgb(device, x, y + height, width, thickness, color); 
            fill_rgb(device, x, y, thickness, height + thickness, color); 
            fill_rgb(device, x + width, y, thickness, height + thickness, color); 
        }
    }
}

应该不重要,但是我对它的调用[不同的文件,相同的目录]

auto color = D3DCOLOR_ARGB(255, 17, 27, 38);
utils_t1::draw_box(device, 15, 15, 250, 400, 3, color);

我的意思是声明了该函数,为什么我得到LNK2001。

致谢

АімАssііт

0 个答案:

没有答案