简体   繁体   中英

Cannot Link between 2 projects in the same solution, and i dont have a .Lib File for additional dependencies

I have a main project and which there I implement some classes and functionality and also a main.cpp to run everything.

Now I try to add another project to test my main project, so I create another project in the same solution which will be my Unit Test Catch 2 for my original project.

Now I try to reference my original project inside my test project - didn't work. I also try to add in linker input dependencies my whole original folders, the debug folder and the cpp folder - didn't work.

Finally I understand that I try to search for lib file of the Original project to refer inside my Test project but cannot find lib file. Is there another way to link between the two projects so I can call classes and functions inside my Test project and test them?

You can only link to another project if that project is build as a library. Your project is currently build as an application, so you cannot do this, unless you reorganize your project into a library and an application.

If you do not want to this, you can also add the sources files you want to test to your test project. Do not copy the files but reference the existing files in the unit test project.

Right click on "Header files" or "Source files" of your test project in the Solution Explorer, then "Add", "Existing item...". Now these sources files will also by compiled and linked when building your test project.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM