0

I have three projects in a visual studio solution in which the code consists of lots of template code. This therefore means I can't compile the code into a DLL or static library because then I can't use the template classes with new types anymore. One of the projects at the moments acts as the 'core' and the other two need to use the headers (by additional include directories) and source files of that core project and use its template classes. I want to find a way to automatically pass the source code files of that core project to the linker in the other projects so they can use the source code. I could copy the files but then im going to be updating the core lots and I do not want to keep copying and adding files to the other two projects. How could I do this? Im not using C-Make, only visual studio and I wish to keep it that way.

  • 1
    A template does not emit object code until it is instantiated. The usual way to share C++ templates is by having them in a header file, such as the vast majority of Boost. – Eljay Jul 19 '21 at 10:11
  • Isn't this problem solved by project references? See [visual c++: #include files from other projects in the same solution](https://stackoverflow.com/questions/601268/visual-c-include-files-from-other-projects-in-the-same-solution) – Botje Jul 19 '21 at 10:13
  • @Botje that requires compiling the code from the core project – Lucas Smith Jul 19 '21 at 10:17
  • @Eljay Doesnt work for me, and having to do template class etc.. every type is tedious. I want to be able to use template classes from the core project in the others inside the .cpp source functions without having needing to template class define it. – Lucas Smith Jul 19 '21 at 10:19
  • In that case then, you'll need to solve your project design without the use of templates that are exposed to the users in the API of your binaries. – Eljay Jul 19 '21 at 10:28

0 Answers0