Illegal characters in path when linking c++ object

2020-04-17 06:19发布

问题:

I have created a c++ app with visual studio 2015 for windows.I also like to run this app on linux distros so I installed on windows the Visual C++ for Linux Development plug-in. I also created an Ubuntu 16.04 VM to target. The ssh connection was successful as well as the file transfer to the linux relevant folders. The compilation completed successfully but since I also use shared libraries when the linking process began I got the following error:

 Illegal characters in path 

for the line

Ld Condition="'@(RemoteLink)' != ''"

of the file:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Application Type\Linux\1.0\Linux.Common.targets

I also tried it on Visual studio 2017 but the same result. I enter the library path both on VC++ directories and in the field "Shared library search path" of the linker but the error persisted. How can this be fixed?

回答1:

As noted by Bernie, this message appears when there is a linker error, typically g++ can't find a library. Its been discussed here.

Turn up the build output level and all will be revealed. In Tools/Options/Projects and Solutions/Build and Run set MSBuild project output verbosity to Normal.



回答2:

I had had the same problem today after having migrated a Linux C++ project from Netbeans IDE to Visual Studio 2017.

Surprisingly this linker error message 'illegal characters in path' disappeared when I completed the required linker options at VS2017 (menu: project properties / Linker / Command line).

I my case I had to add the '-lrt' option. At netbeans IDE I got the error message 'undefined reference to 'clock_gettime'' when not using the '-lrt' option.

At Visual Studio it seems that the linker error message fails or is messed up and therefore I just got that 'illegal characters in path' message.

So possibly it could help you if you look for the explicit linker options you gave to the windows project version and try to add it also to the linux version?