Reputation: 5208
I normally work with C#. In C# I can have a hierarchy, and they reference each other.
I am trying to do the same in VC++, but I dont know how. I don't have much experience with C++ in general.
I have:
I tried adding TestProject1 as reference of TestProject2:
Right Clikc on the TestProject1-> Properties -> Common Properties -> Framework and References -> Add New Reference -> Selected TestProject2
But this results in an error, because TestProject2 is not built as a lib.
From what I can see only a list of obj files are generated.
What is the correct way to reference TestProject2 in TestProject1 so I can use its classes?
Update: How I solved it
I solved the issues by following SOReader instructions, but I added the lib in a different way:
Upvotes: 1
Views: 146
Reputation: 6017
It's not so easy as it is in C#.
You must have TestProject1
build as static library if you want to simply include it to another project. After this you go to dependent project properties and add lib
file to linker and headers folder for headers lookup.
Assuming Dll
has its include .h
file in its root folder (which actually should not have) you simply add an entry to Additional Include Directories to point the place where Dll root folder is.
Now you can just write #include <theheaderfile.h>
in you cpp file in Main application to reference exported functionality.
Here are few others locations in msdn that might help: import/export, static libraries, hpp vs h
Upvotes: 1