Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio: Link executable

Lets say I have: a static library project called "LIB" a application project called "LIBAPP" a application project called "APP" a application project called "APPTEST"

When i add "LIB" to LIBAPP Project Dependencies, Visual Studio automatically links "LIBAPP" against LIB. But when i add APP to APPTEST Project Dependencies, it doesnt.

Since i am doing unit tests of APP's classes in APPTEST, i have to link against APP, therefore i am currently manually linking against all *.obj files of APP (hundreds...)

Since i have to change the link targets of APPTEST everytime i add or remove a *.cpp file from APP, this isnt a nice solution.

So is there a way to force Visual Studio to do this for me automatically, like it does when adding a static library Project Dependency ?

like image 366
smerlin Avatar asked Feb 26 '26 08:02

smerlin


1 Answers

You can't "link against APP", as you've discovered.

One solution is to put all of APP's code into its own library, leaving APP as single source file that runs a function in that library. The you can make APPTEST another single source file that links against the new APP library.

like image 136
RichieHindle Avatar answered Feb 27 '26 22:02

RichieHindle