question

HyukMyeong-3703 avatar image
0 Votes"
HyukMyeong-3703 asked HyukMyeong-3703 commented

How to change the order of ProjectReference tag in vcproj or vcxproj?

I'm using MS Visual Studio 2019 to build a c++ project
I have a solution and three projects in it
one is for the executable and others are for the static libraries

Now I want to change the order of linking the libraries for the executable
And finally found that they are linked in the order of its order in project.vcxproj
I changed the order manually with text editor and finally succeeded to get the result

But I don't know how to do it in Visual Studio GUI
If the libraries are described as below in my project.vcxproj
Can I change the order of the libraries with Visual Studio GUI?

bash
...
  <ItemGroup>
    <ProjectReference Include="..\ALibrary\ALibrary.vcxproj">
      <Project>{dbc3f07c-3bf9-4582-99c8-cbd8fe344e5c}</Project>
    </ProjectReference>
    <ProjectReference Include="..\BLibrary\BLibrary.vcxproj">
      <Project>{fbbe1fd4-e968-40d8-aab8-e2a54e9c9268}</Project>
    </ProjectReference>
  </ItemGroup>
...

vs-general
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

DylanZhu-MSFT avatar image
0 Votes"
DylanZhu-MSFT answered HyukMyeong-3703 commented

Hi HyukMyeong,

In visual studio, the items are default sorted by alphabetically in solution explorer, and there are no related options to customize it.

By the way, from your requirement, you can define different aliases for your same namespace with same class and same method in different libraries.

Best Regards,
Dylan


If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Viorel-1 avatar image
0 Votes"
Viorel-1 answered HyukMyeong-3703 edited

Check if this helps: right-click the Solution in Solution Explorer, go to “Project Dependencies…”, then select “BLibrary” from dropdown list and check the “ALibrary” checkbox. Then go to “Build Order” tab to verify the order.

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@Viorel-1 thank you for your answer, bud sadly I couldn't change the order of ProjectReference tags in project.vcxproj
Actually what I want to do is selecting foo() function in the libraries by controlling linking order as below
(I think this approach is not good though and maybe this is not a right way to use vc++ linker)
but somehow this is now achieved by manually modifying project.vcxproj
and I'm wondering whether it can be done in GUI as well

< project >
void foo();
int main()
{
foo();
}

< ALibrary >
void foo() { ... }

< BLibrary >
void foo() { ... }

0 Votes 0 ·