Getting LNK1104 error from project .lib file.

I have a solution with two projects: myProject , DLL and myProject_Tester , the Win32 console application that I use to debug the DLL.

When I create a 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 

I added myProject as a reference in myProject_Tester , but when I edit myProject_Tester.cpp and I try to enter #include "myProjectDLL.h" (the header file for myProject ) to include the header file, myProjectDLL.h does not appear in Intellisense.

I also added U:\Software Development\c++ projects\myProject\Debug in the Additional Include Directories section for myProject_Tester .

Is there somewhere else in the properties for myProject_Tester that I need to configure something to associate it with myProject ?

EDIT: Here is the header file that I use 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); }; } 
+1
source share
1 answer

You have not set the correct settings for additional directories. Your .h file, of course, is not in the Debug folder. Do it U: \ Software Development \ C ++ projects \ myProject.

Make sure that the .lib file really exists after the creation of the myProject project. If it is missing, you forgot to use __declspec (dllexport) to tell the linker to export the functions or classes that you want to make available.

And make sure that the projects are assembled in the correct order, "myProject" must be created before the console project starts. If necessary, right-click the project console in the Solution Explorer, select Project Dependencies, and check myProject in the dialog box.

+3
source

Source: https://habr.com/ru/post/955820/


All Articles