C++ 两个相同的项目:一个有未解析的外部,另一个没有

C++ 两个相同的项目:一个有未解析的外部,另一个没有,c++,visual-studio,C++,Visual Studio,我有两个VS 2017项目,在结构上是相同的 他们都: 在版本x64中编译 位于project/folder/project1和project/folder/project2 在my/library/here/中导入导致问题的特定库。此路径在ProjtProjts> C++ > > >中附加定义,包括目录 它们在project1.h和project2.h中的导入如下: 导致这些错误的函数都位于my_problem\u library.pb.h(这是自动生成的,我可以添加) 我会错过另一个重要

我有两个VS 2017项目,在结构上是相同的

他们都:

  • 在版本x64中编译
  • 位于
    project/folder/project1
    project/folder/project2
  • my/library/here/
    中导入导致问题的特定库。此路径在ProjtProjts> C++ > > >中附加定义,包括目录
  • 它们在
    project1.h
    project2.h
    中的导入如下:
导致这些错误的函数都位于
my_problem\u library.pb.h
(这是自动生成的,我可以添加)

我会错过另一个重要的东西吗?为什么这对project1有效而对project2无效


非常欢迎您的所有见解。

\u declspec(dllimport).
错误意味着您需要链接到dll的导入库。因此,问题在于您在
链接器->输入->附加依赖项中添加了什么或没有添加什么,您可以进行区分(例如使用BeyondCompare)以找出真正的区别。似乎您没有链接到包含GameInfo::GameInformation和LogFinisher::operator=(…)实际代码的库。@StackOverflown这是什么意思
my\u problem\u library.pb.h
包含函数头etc@JessicaChambers头文件通常有函数/类声明,它没有实际的代码。编译器或实际上的链接器需要实际的库进行链接,以便构建最终的可执行文件或库。库的形式通常为libraryname.lib,您可以将其添加到Visual Studio中的“附加依赖项”字段中,
#pragma once

#undef UNICODE

#define WIN32_LEAN_AND_MEAN

#include <iostream>
#include <map>
#include <random>
#include <cstdlib>
#include <windows.h>
#include <winsock2.h>
#include <ws2tcpip.h>
#include <stdlib.h>
#include <stdio.h>
#include <string>

#include <windows.h>
#include <winsock2.h>
#include <ws2tcpip.h>

#include "my_problem_library.pb.h"

// Need to link with Ws2_32.lib
#pragma comment( lib, "Ws2_32.lib" )

#define DEFAULT_BUFLEN 512
#define DEFAULT_PORT "6000"
error LNK2001: unresolved external symbol "public: virtual __cdecl GameInfo::GameInformation::~GameInformation(void)" (??1GameInformation@GameInfo@@UEAA@XZ)
error LNK2001: unresolved external symbol "protected: __cdecl GameInfo::GameInformation::GameInformation(class google::protobuf::Arena *)" (??0GameInformation@GameInfo@@IEAA@PEAVArena@protobuf@google@@@Z)
error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __cdecl google::protobuf::internal::LogFinisher::operator=(class google::protobuf::internal::LogMessage &)" (__imp_??4LogFinisher@internal@protobuf@google@@QEAAXAEAVLogMessage@123@@Z)
...
fatal error LNK1120: 13 unresolved externals