I have a Visual Studio solution with multiple C++ projects, and I find managing the linker dependencies a bit cumbersome.
Every time I include a header file from an other project, I need to explicitly add the corresponding .obj
file in the linker settings.
I.e. in Properties>Linker>Input>Additional Dependencies:
..\Project1\$(Platform)\$(Configuration)\Obj1.obj
..\Project1\$(Platform)\$(Configuration)\Obj2.obj
..\Project2\$(Platform)\$(Configuration)\Obj3.obj
..\Project2\$(Platform)\$(Configuration)\Obj4.obj
Using wildcard characters would greatly simplify this task:
..\Project1\$(Platform)\$(Configuration)\*.obj
..\Project2\$(Platform)\$(Configuration)\*.obj
But unfortunately this also includes the two main.obj
files from Project1
and Project2
.
Is there a way to exclude these files from the linker input?
I tried to use the standard(?) Windows file-search options like this:
"..\Project1\$(Platform)\$(Configuration)\*.obj"-"..\Project1\$(Platform)\$(Configuration)\main.obj"
"..\Project2\$(Platform)\$(Configuration)\*.obj"-"..\Project2\$(Platform)\$(Configuration)\main.obj"
but apparently they are not supported here. In fact, it seems simply adding quotes around a valid linker path breaks everything.
I've also seen this question, and sure, I could do something like this, renaming or deleting the undesired files by a custom script, but I'd prefer to avoid it. What I want to do seems like a fairly reasonable thing; every project having its own main.obj
makes sense to me, linking some but not all .obj
s makes sense to me as well. There must be some standard VS way to say "link everthing, except for this one" to the linker.
But feel free to correct me of course, that's why I'm here. Thanks in advance.
p.s.: I'm currently using VS2012, but I'm interested in answers for any VS version, even for older ones (I won't downgrade just for this, but I am interested).