【发布时间】:2018-11-13 16:50:33
【问题描述】:
头文件 TCP.h
class CTCPcomm {
public:
CTCPcomm(bool bOverLapped = false, long lTimeOut = 0);
~CTCPcomm(void);
TCP.cpp 类
CTCPcomm::CTCPcomm ( bool bOverLapped, long lTimeout ) {
.......
}
CTCPcomm::~CTCPcomm ( void ) {
.......
}
这是为 plc_test.cpp 调用的
int main(){
CTCPcomm m_TCPcon(true, lTimeout);
.......
}
这给了我错误,
Severity Code Description Project File Line Suppression State Error LNK2019 unresolved external symbol "public: __thiscall CTCPcomm::CTCPcomm(bool,long)" (??0CTCPcomm@@QAE@_NJ@Z) referenced in function "void __cdecl `dynamic initializer for 'm_TCPcon''(void)" (?? __Em_TCPcon@@YAXXZ) plc_test
Severity Code Description Project File Line Suppression State Error LNK2019 unresolved external symbol "public: __thiscall CTCPcomm::~CTCPcomm(void)" (??1CTCPcomm@@QAE@XZ) referenced in function "void __cdecl `dynamic atexit destructor for 'm_TCPcon''(void)" (??__Fm_TCPcon@@YAXXZ) plc_test
我使用 Visual Studio 2015,并将其编译为 .exe 文件。 我已经阅读了很多帖子,但他们说将执行类型更改为 .lib 但我希望这个项目是一个可执行文件,所以我想坚持使用 .exe 如果编译为 .lib 而不是 .exe,为什么它编译时没有错误? 如果我想将它作为.exe执行而没有错误应该怎么做?
【问题讨论】:
-
你的项目中真的有 TCP.cpp 吗?
-
是的。这是我项目的一部分
标签: c++ visual-c++ visual-studio-2015