1

Long story short : I had some functions I thought could be useful in a library instead of just copying the functions from one project to the next one. So I created a library project and put my header file and cpp file in the project, referenced it with my second project (in the same solution) and everything is working fine.

Here's my problem. I want to add an other set of functions in different files. So I created a new header file and a new cpp file, but now I don't seem to be able to include the new header file. the other one works fine, but the new one can't be included and VS gives me these error codes :

E1696   cannot open source file "2ndFunctionSet.h"                  [2ndProjectName]        [FileNameA]
C1083   include : '2ndFunctionSet.h' : No such file or directory    [2ndProjectName]        [FileNameA]

Here's a summary of the current structure of the solution :

SolutionName
|---project > CommonLibraries
|   |---{header files}
|   |   |---baseFunctions.h
|   |   |---2ndFunctionSet.h
|   |---{source files}
|       |---baseFunctions.cpp
|       |---2ndFunctionSet.cpp
|
|---project > 2ndProjectName
    |---{header files}
    |   |---someClass.h
    |   |---mainCode.h
    |---{source files}
        |---someClass.cpp
        |---mainCode.cpp

both cpp files from the common libray include their header files and the stdafx.h default precompilation file and both seem to be constructed similarly.

Can you please help me understand what I have done wrong? I haven't been doing c++ for a while, so it is likely I did a procedure error when creating my library project or when I created the new function set file.

3
  • Add the library header folder to your Additional Include Directories for your other projects. Commented May 9, 2018 at 23:19
  • Are you sure that 2ndFunctionSet.h and baseFunctions.h are in the same folder? Can you check with file explorer? Sometimes Visual Studio shows files in wrong paths. Commented May 10, 2018 at 0:57
  • I don't understand the downvote, but anyways... Thanks @thomas-sablik for pointing it out. turns out that the first file were still in the second project folder. So it was not supposed to work either. Commented May 10, 2018 at 18:58

1 Answer 1

1

The files are not in the same folder.

You should also check if the files that are "working" are in the proper folder :

  • Go on your file explorer
  • Check the library project's folder
  • If the files are in the wrong folder
    • Move them in the correct project folder
    • Add reference to the new files' location

Now on "How to include those files in a project of the same solution" :

  • Go in your "2ndProjectName" project's properties
  • "Configuration Properties" > "c/c++" > "General"
  • In "Additional include directory" : click > edit and go reach for the library project folder.
  • In the Solution Explorer, go in your "2ndProjectName" project
  • Right click on "References" > "Add Reference"
  • Make sure your library project is checked
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.