添加了对 .lib 项目的引用 - 项目不使用.cpp文件
Added reference to .lib project - project not using .cpp file?
我对C++还是新手,所以如果我误解了什么,请原谅我。
我有一个包含 sql 连接类的C++库,我想在项目中使用它。我有:
- 将其添加到同一解决方案
- 在"框架和参考"中添加了对它的引用
- 包含在主项目的 stdafx .cpp 中的库头文件中
- 将库项目的目录作为包含目录添加到主项目中
但是在编译项目时,我仍然遇到许多unresolved external symbol
错误。
如果我包含库项目的 *.cpp 文件,它可以正常工作,但我认为您不必这样做。
这些是我得到的确切错误:
2>Link:
2> sqlConnector.obj : MSIL .netmodule or module compiled with /GL found; restarting link with /LTCG; add /LTCG to the link command line to improve linker performance
2> Creating library .ReleaseMainProject.lib and object .ReleaseMainProject.exp
2>LINK : warning LNK4098: defaultlib 'mfc100u.lib' conflicts with use of other libs; use /NODEFAULTLIB:library
2>LINK : warning LNK4098: defaultlib 'mfcs100u.lib' conflicts with use of other libs; use /NODEFAULTLIB:library
2>MainProject.obj : error LNK2001: unresolved external symbol "public: bool __thiscall SQLQuery::AddParameter(class ATL::CStringT<char,class StrTraitMFC_DLL<char,class ATL::ChTraitsCRT<char> > >)" (?AddParameter@SQLQuery@@QAE_NV?$CStringT@DV?$StrTraitMFC_DLL@DV?$ChTraitsCRT@D@ATL@@@@@ATL@@@Z)
2>MainProject.obj : error LNK2001: unresolved external symbol "public: void __thiscall SQLQuery::SetQuery(class ATL::CStringT<char,class StrTraitMFC_DLL<char,class ATL::ChTraitsCRT<char> > >)" (?SetQuery@SQLQuery@@QAEXV?$CStringT@DV?$StrTraitMFC_DLL@DV?$ChTraitsCRT@D@ATL@@@@@ATL@@@Z)
2>MainProject.obj : error LNK2001: unresolved external symbol "public: bool __thiscall SQLQuery::Open(class ATL::CStringT<char,class StrTraitMFC_DLL<char,class ATL::ChTraitsCRT<char> > >)" (?Open@SQLQuery@@QAE_NV?$CStringT@DV?$StrTraitMFC_DLL@DV?$ChTraitsCRT@D@ATL@@@@@ATL@@@Z)
2>MainProject.obj : error LNK2001: unresolved external symbol "public: void __thiscall SQLQuery::SetConnectionString(class ATL::CStringT<char,class StrTraitMFC_DLL<char,class ATL::ChTraitsCRT<char> > >)" (?SetConnectionString@SQLQuery@@QAEXV?$CStringT@DV?$StrTraitMFC_DLL@DV?$ChTraitsCRT@D@ATL@@@@@ATL@@@Z)
2>sqlConnector.obj : error LNK2001: unresolved external symbol "public: void __thiscall CAMTrace::SetEXEName(wchar_t const *)" (?SetEXEName@CAMTrace@@QAEXPB_W@Z)
2>sqlConnector.obj : error LNK2001: unresolved external symbol "public: void __thiscall CAMTrace::Trace(wchar_t const *,int,int)" (?Trace@CAMTrace@@QAEXPB_WHH@Z)
2>.ReleaseMainProject.exe : fatal error LNK1120: 6 unresolved externals
您需要
做的是将库二进制文件(*.lib)文件添加到项目的链接器输入中。
为此,您需要指定在何处查找文件,该文件是下的一个条目
链接器/常规/附加库目录
之后,您将库添加到链接器输入下
链接器/输入/其他依赖项
相关文章:
- 如何在 VSCODE 中设置项目文件夹并链接所有 CPP 文件
- 使用 Premake5 构建库,每个构建没有单独的项目文件
- CMake 如何强制third_party库将项目文件包含在当前项目源目录中?
- 当包含头文件的文件不在根项目文件夹中时,如何包含它
- Qt创建者:加载位于子目录中的项目文件
- 配置过程项目文件中的错误可能无效
- 哪些 Netbeans 8.2 项目文件应提交到C++项目的版本控制?
- C++错误LNK2005和不同项目文件的常规继承
- 为什么我的QTRPT项目文件未在QTCreator中运行
- 严重性代码说明项目文件行抑制状态错误 C2676 二进制">>":"std::ifstream"
- 如何在运行qmake时将变量传递到qmake项目文件
- 如何使用QPixmap,以便在地址中只需要使用项目文件夹
- CMake 插入不带文件夹前缀的项目文件
- QT无法解析项目文件
- 将静态库链接行添加到我的QT项目文件没有区别
- CMAKE QT创建者:将标题文件添加到项目文件中
- Qt C++:将所有库文件包含在项目文件夹中
- 对单元测试(googletest)和项目/文件夹/文件的混淆
- C++项目文件夹外部依赖项仅包含 .h 和 .hpp 文件
- 有没有办法将文件包含在C++中的所有项目文件中