Click here to Skip to main content
15,890,336 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
The IDE I am using to develop C++ code "wraps up" application in "project".
I have two such "projects" and they both use common class , let me call it "COMMON". .
The projects are "under construction" and "COMMON" class is periodically changed in each project - independently.
I woudl like to have another project where I would like to keep / have updated "COMMON" class and instead of each project having separate copies of the such class make a reference to the third project "COMMON" class.

In theory I just need to add "#include COMMON" and I have done that and it compiles OK.

BUT
the linker is complaining " missing reference..."

I do not know HOW to option the linker

I am familiar with linking libraries, but "COMMON" is C++ class and NOT a library.

So - how do I "link" "COMMON" class in another project?

PS
Verbose output of the linker can be posted if it helps.

What I have tried:

There are few different ways to add "include COMMON" and they work.
Posted
Updated 26-Jan-20 4:16am

You make "COMMON" a library / dll and add a "reference" to it in your other projects.

Odds are, you have more that 1 class that is a candidate for a "common" / shared library.
 
Share this answer
 
Comments
Vaclav_ 25-Jan-20 14:29pm    
After further research I woudl add - I am missing link to object file - perhaps impossible to link object files between projects.

I was hoping I do not have to make it a library.

Which would "generate" another question - how does "normal project" links to object files?
In addition to Gerry's suggestion, you could just include the source module from one project into the other. You did not tell us which IDE you are using, but I am assuming here that you are using Visual Studio.

In the Project explorer window, right click on the relevant source folder and select "Add existing". In the open dialog, navigate to the relevant file and select it. The file will now be included in your source set, although it will remain in its original location.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900