从引用项目的.lib文件获取LNK1104错误 [英] getting LNK1104 error from a referenced project's .lib file
问题描述
我有一个解决方案有两个项目: myProject
,一个DLL和 myProject_Tester
,一个Win32控制台应用程序
I have a solution with two projects: myProject
, a DLL, and myProject_Tester
, a Win32 console application that I'm using to debug the DLL.
当我构建解决方案时,我在错误列表中收到此错误消息:
When I build the solution, I get this error message in the Error List:
error LNK1104:
cannot open file 'U:\Software Development\c++ projects\myProject\Debug\myProject.lib'
U:\Software Development\c++ projects\myProject\myProject_Tester\LINK
myProject_Tester
$ b b
我添加了 myProject
作为 myProject_Tester
中的引用,但是当我编辑 myProject_Tester.cpp
,并尝试输入 #includemyProjectDLL.h
( myProject
)包含头文件, myProjectDLL.h
不会显示在Intellisense中。
I added myProject
as a reference in myProject_Tester
, but when I'm editing myProject_Tester.cpp
, and I try to enter #include "myProjectDLL.h"
(the header file for myProject
) to include the header file, myProjectDLL.h
doesn't show up in the Intellisense.
我还添加了 myProject_Tester $>的附加包含目录下的
U:\Software Development\c ++ projects\myProject\Debug
c $ c>。
I also added U:\Software Development\c++ projects\myProject\Debug
under Additional Include Directories for myProject_Tester
.
在 myProject_Tester
的属性中还有其他地方,它与 myProject
?
Is there somewhere else in the properties for myProject_Tester
that I need to configure something to connect it with myProject
?
编辑:这是我用于myProjectDLL.h的头文件:
Here is the header file I'm using for myProjectDLL.h:
//myProjectDLL.h
#ifdef MYPROJECT_EXPORTS
#define MYPROJECT_API __declspec(dllexport)
#else
#define MYPROJECT_API __declspec(dllimport)
#endif
namespace myProject
{
class FileOperator
{
public:
static int openDoc(int projectID,int docID);
};
}
推荐答案
其他包含目录设置正确。您的.h文件肯定不存在于Debug文件夹中。
You didn't set the Additional Include Directories setting correctly. Your .h file surely isn't present in the Debug folder. Make it U:\Software Development\c++ projects\myProject instead.
在构建myProject项目之后,确保.lib文件实际存在,否则请改用U:\Software Development\c ++ projects\myProject。如果它缺少,那么你忘了使用__declspec(dllexport)来告诉链接器导出你想要提供的函数或类。
Do make sure the .lib file actually exists after building the "myProject" project. If it is missing then you forgot to use __declspec(dllexport) to tell the linker to export the functions or classes that you want to make available.
并确保项目正以正确的顺序构建,myProject必须在控制台项目开始构建之前构建。如果需要,在解决方案资源管理器窗口中右键单击控制台项目,单击项目依赖关系,然后在对话框中勾选myProject。
And make sure that the projects are getting build in the correct order, "myProject" must be built before the console project starts building. If necessary, right-click the console project in the Solution Explorer window, click "Project Dependencies" and tick myProject in the dialog box.
这篇关于从引用项目的.lib文件获取LNK1104错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!