Search code examples
linuxvisual-studiocross-platformstatic-librariesstatic-linking

MSB012 Warning in Visual Studio while trying to link Linux static lib with executable


I'm getting this error while building my static library remotely using the compilier on a Debian VM.

Warning MSB8012

TargetPath (D:\repo-path\VisualStudio\MyLibrary\bin\x64\Debug\libMyLibrary.a)

does not match the Library's OutputFile property value

(D:\repo-path\VisualStudio\MyLibrary\~\projects\MyLibrary\bin\x64\Debug\libMyLibrary.a).

This may cause your project to build incorrectly.

To correct this, please make sure that $(OutDir), $(TargetName) and $(TargetExt) property values match the value specified in %(Lib.OutputFile).

I can't find %(Lib.OutputFile) anywhere in the solution config, so I ahve no clue what it's saying.

I have a two solution project where one is a library and the other is an executable that depends on the library. I have the library set as a reference in the solution for the executable. I haven't done anything else to it because I'm not sure what else to do compiling remotely on linux.

When building the executable with the library referenced, I get this error

/home/user/projects/MyLibrary/../../VisualStudio/MyLibrary/bin/x64/Debug/MyLibrary.a:

No such file or directory

I know that the library binary needs to be on the remote machine so the compilier knows about it. I don't know how to get Visual Studio to put it there for how I'm doing the solution reference.


Now, I should explain the directory structure I have going here.
MyExecutable and MyLibrary are separate repos, and since MyLibrary is a dependency for MyExecutable, it's repo is a submodule for MyExecutable.

So the hierarchy looks like this

my-library\
   .git\
   src\
   VisualStudio\
      MyLibrary\
         MyLibrary.sln


my-executable\
   .git\
   src\
   my-library\
      .git\
      src\
   VisualStudio\
      MyExecutable\
         MyExecutable.sln
      MyLibrary\
         MyLibrary.sln

The point in structuring this way is so that the repos are IDE agnostic and because cmake can't build VS solutions that are Linux targeted because it assumes Windows platform. Visual Studio projects are put into a dir that is ignored.

I just manually spin up the VS solutions myself and add existing items.


Here's the solution config for MyLibrary enter image description here enter image description here enter image description here

And for MyExecutable enter image description here enter image description here enter image description here


EDIT: This relates to my problem: https://developercommunity.visualstudio.com/content/problem/196761/linux-c-project-doesnt-allow-to-specify-path-to-a.html


Solution

  • Discovered that all these problems are currently bugs in Visual Studio for Linux C++.

    https://developercommunity.visualstudio.com/content/problem/579152/linux-c-remote-libraries-do-not-archive-ie-compila.html