c++ - 两个相同的项目:一个有未解决的外部问题,另一个没有
问题描述
我有两个 VS 2017 项目,它们在结构上是相同的。
他们两个:
- 在版本 x64 中编译
- 位于
project/folder/project1
和project/folder/project2
- 在
my/library/here/
. 此路径在 Project properties > C++ > General > Additional include 目录中定义 project1.h
它们的进口情况project2.h
如下:
#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"
在 project1 中,代码编译没有任何问题。它使用与 project2 完全相同的功能my_problem_library
,但是当我编译 project2 时,我得到了这些错误:
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
导致这些错误的函数都位于my_problem_library.pb.h
(这是自动生成的,我可能会添加)。
我错过了另一个进口吗?为什么这适用于 project1 而不是 project2?
欢迎所有见解。
解决方案
推荐阅读
- html - 在通过 Chrome DevTools 挑选 CSS 代码后,找出网页中哪些地方使用了 CSS 代码?
- c# - 如何将带有所有颜色的richtextbox的文本保存到json中以在之后放回
- archlinux - config.fish 检查我是否在主目录中?
- postgresql - 如何在 Postgres RDBMS 中为没有重叠和竞争条件的用户创建时间块条目(日历事件)
- typescript - 在打字稿中打印类型对象
- javascript - 如何在 Ant Table List 上正确设置切换开关?
- list - 在 Python 3 中混合 n 个大小为 m 的列表以创建一个矩阵(m*m*m*..n 次)
- c# - 我无法从 C# 向 GMAIL 发送电子邮件
- python - Pandas/xarray - 基于另一个数据帧动态水平移动值
- sql - MS ACCESS 报告中的求和函数太复杂