- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我只是不明白为什么我可以在类上使用公共(public)变量,但在尝试使用 getLicenceRefused 方法时出现链接错误。我不确定问题是不是因为我之前遇到的 CString 复制构造函数问题所以把参数去掉了,但我仍然得到同样的错误。
所以类正在编译和链接(因为我可以使用成员变量),当我尝试调用任何函数时我得到这个错误。
我已尽力做到尽可能全面,如果我遗漏了一些重要的东西或包含了太多内容,我深表歉意。
我只是偶尔使用 c++(很抱歉,如果我的术语是基于 java 的),因为它正在维护旧代码,这里没有人使用 c++ 来维持他们的技能水平。这两个类都是内部类(由现在离开的人写的:)),这两个类在同一个解决方案的不同项目中。 ConfigurationDialog 项目依赖于 CServerSettings 项目。这是我的调用代码
int CConfigurationDialog::testConnection(CString connectionName, CString origin)
{
CServerConnection* connection = getConnection();
// these 2 lines of code work and return the correct result, it is the body of the function with problems
auto result = connection->m_licencesRefused.find(origin);
bool connRefused = (result != connection->m_licencesRefused.end());
if(connection->getLicenceRefused(origin)) // this is the line with the link error
类定义
class CServerConnection
{
public:
CServerConnection();
CServerConnection( LPCTSTR connectionName );
void setLicenceRefused(CString origin, bool value);
bool getLicenceRefused(CString origin);
void setLicenceRequested(CString origin, bool value);
bool getLicenceRequested(CString origin);
void clearAllLicences();
CString getLoggedOnOrigin();
void setURLNotFound(bool notFound);
bool getURLNotFound();
public:
bool m_initialised;
CString m_connectionName;
CString m_lastError;
CString m_password;
CString m_company;
CString m_username;
CString m_sessionID;
public:
std::set<CString> m_licencesRefused;
bool m_urlNotFound;
};
类主体(我不能包含整个文件,因为它超过 1000 行并且包含几个类):
CServerConnection::CServerConnection(LPCTSTR connectionName)
{
m_initialised = false;
m_connectionName = connectionName;
m_lastError = _T( "" );
m_urlNotFound = false;
}
CServerConnection::CServerConnection()
{
m_initialised = false;
m_connectionName = _T( "" );
m_lastError = _T( "" );
m_urlNotFound = false;
}
void CServerConnection::setLicenceRefused(CString origin, bool value)
{
if(value)
{
m_licencesRefused.insert(origin);
}
else
{
m_licencesRefused.erase(origin);
}
}
bool CServerConnection::getLicenceRefused(CString origin)
{
auto result = m_licencesRefused.find(origin);
return (result != m_licencesRefused.end());
}
void CServerConnection::setLicenceRequested(CString origin, bool value)
{
if(value)
{
m_licencesRequested.insert(origin);
}
else
{
m_licencesRequested.erase(origin);
}
}
bool CServerConnection::getLicenceRequested(CString origin)
{
auto result = m_licencesRequested.find(origin);
return (result != m_licencesRequested.end());
}
void CServerConnection::clearAllLicences()
{
m_licencesRefused.clear();
setLicenceRefused(XL_FINANCE_ORIGIN, false);
setLicenceRefused(XL_POP_ORIGIN, false);
m_licencesRequested.clear();
setLicenceRequested(XL_FINANCE_ORIGIN, false);
setLicenceRequested(XL_POP_ORIGIN, false);
}
CString CServerConnection::getLoggedOnOrigin()
{
if(getLicenceRequested(XL_FINANCE_ORIGIN) && !getLicenceRefused(XL_FINANCE_ORIGIN))
{
return XL_FINANCE_ORIGIN;
}
if(getLicenceRequested(XL_POP_ORIGIN) && !getLicenceRefused(XL_POP_ORIGIN))
{
return XL_POP_ORIGIN;
}
return _T("");
}
void CServerConnection::setURLNotFound(bool notFound)
{
m_urlNotFound = notFound;
}
bool CServerConnection::getURLNotFound()
{
return m_urlNotFound;
}
和错误:
error LNK2019: unresolved external symbol "public: bool __thiscall CServerConnection::getLicenceRefused(class ATL::CStringT<wchar_t,class StrTraitMFC_DLL<wchar_t,class ATL::ChTraitsCRT<wchar_t> > >)" (?getLicenceRefused@CServerConnection@@QAE_NV?$CStringT@_WV?$StrTraitMFC_DLL@_WV?$ChTraitsCRT@_W@ATL@@@@@ATL@@@Z) referenced in function "private: int __thiscall CConfigurationDialog::testConnection(class ATL::CStringT<wchar_t,class StrTraitMFC_DLL<wchar_t,class ATL::ChTraitsCRT<wchar_t> > >,class ATL::CStringT<wchar_t,class StrTraitMFC_DLL<wchar_t,class ATL::ChTraitsCRT<wchar_t> > >)" (?testConnection@CConfigurationDialog@@AAEHV?$CStringT@_WV?$StrTraitMFC_DLL@_WV?$ChTraitsCRT@_W@ATL@@@@@ATL@@0@Z)
最佳答案
头文件提供了足够的信息让您声明变量。就此而言,只需编译(但不链接)代码。当您链接时,链接器必须解决例如函数引用,例如对 ServerConnection::getLicenceRefused
的引用,通过引入相关的机器代码。
您必须告诉链接器要链接哪个库或目标文件以引入该机器代码。
getLicenseRefused
中的小写首字母表示它不是 Microsoft 代码,尽管它可能是从 C++ 访问的属性。除非熟悉的人碰巧看到并做出回应,否则您必须自己弄清楚库或目标文件。通常这涉及到查看文档,但根据具体情况,它可能就像向项目中添加一个 .cpp 文件一样简单;随便。
附录:在我写完上面的内容之后,OP 已经提供了该类的源代码。
所以这可能只涉及将该 .cpp 文件添加到项目中。
关于c++ - MFC visual c++ LNK2019链接错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30985569/
几天前我问了一个类似的问题,它帮助我找到了 __declspec() 的正确方向,但我又被卡住了。我会尽可能清楚。希望有人能告诉我我做错了什么。它可能是一些小而简单的东西。 项目信息: jc:
我想在某些特定路径中创建某些文件的快捷方式(.lnk)。例如在 ("H:\happy\hi\new.lnk") 中创建我的文件 ("D:\New folder\new.exe") 的快捷方式我想用 p
This question already has answers here: What is an undefined reference/unresolved external symbol er
这个问题在这里已经有了答案: What is an undefined reference/unresolved external symbol error and how do I fix it?
我的 disk-on-key 中有一个可执行文件,位于 dir\program\prog.exe我想在 DoK 的根目录上有一个可执行文件的快捷方式,即 prog.lnk 将引用 dir\progra
我一直在寻找一种在 C# 中创建文件快捷方式的简单方法,但我只找到了执行此操作的外部 dll。这实际上非常令人惊讶,没有内置的方法可以做到这一点.. 无论如何,我知道 lnk 文件只是具有特定命令和给
我一直在寻找问题的解决方案,遇到了 JasonMArcher 回答的帖子,想知道我是否可以更具体地满足我的需求。 我们最近更换了一个新服务器,由于它的名称从//sbcmaster 更改为//sbcse
我有一堆.lnk文件,需要根据快捷方式指向的目标来区别对待它们。我发现很少有其他语言如何做到这一点,但与使用powershell做到这一点无关。 我已经试过了: $sh = New-Object -C
我在使用C++创建快捷方式时遇到问题。.lnk文件已创建,但是目标具有无效路径。 您能解释一下为什么这段代码没有创建正确的快捷方式吗?有人可以帮我修复我的代码吗? 这是代码 // RepChrome.
rmap_utils.h #ifndef UTILS_RANGE_MAP_H #define UTILS_RANGE_MAP_H #include #include #include #incl
这个问题在这里已经有了答案: Can't set value of static object field (error LNK2001: unresolved external symbol) (
我刚刚使用 NuGET 包管理器安装了 SFML 包。安装后。我从它的官方页面运行了一个基本程序。只需复制和粘贴。 #include int main() { sf::RenderWindo
这个问题在这里已经有了答案: Can't set value of static object field (error LNK2001: unresolved external symbol) (
这个问题已经有答案了: Windows shortcut (.lnk) parser in Java? (9 个回答) 已关闭 6 年前。 我在Windows的“最近的项目”中有一些文件夹/文件。我想
首先,对不起我的英语..如何将现有的快捷方式包含到我的解决方案中? 当我尝试将现有项目添加到我的项目中时,visual studio 似乎尝试添加链接目标,而不是链接本身,因为它给我以下错误: 找不到
我们有一个充满指向文件夹的快捷方式(.lnk 文件)的网络驱动器,我需要在 C# Winforms 应用程序中以编程方式遍历它们。 我有哪些实用选择? 最佳答案 添加 IWshRuntimeLibra
我正在编写 32 位服务应用程序,我希望能够在其中为登录用户 启动“开始”菜单项。我确实设法通过模拟用户并使用 CreateProcessAsUser 和命令行启动选定的 .lnk 文件来完成此任务:
当您尝试打开不再有效的快捷方式文件 (.lnk) 时,Windows 会提示您:“此快捷方式已被更改或移动,因此此快捷方式将不再正常工作。”是否有 python 代码可用于检测此类快捷方式是否不再有效
我有一个名为 Siemens NX 的程序的多个版本。 NX 使用环境变量进行配置。我需要 NX 10.0 使用一组与使用系统环境变量的 NX 7.5 不同的环境变量。因此,我编写了一个批处理文件来设
我有一个打开 *.postfix 文件的 c# 程序。 如果用户运行指向我的文件类型的 (.lnk) 快捷方式,我的程序将打开目标。 那么,我的程序怎么知道它是由 (.lnk) 快捷方式启动的(并获取
我是一名优秀的程序员,十分优秀!