Devpartner Instrumentation for Code coverage causing linker errors - code-coverage

So I've got a Visual studio 2005 solution that contains a C# project (test driver - creates exe) and 7 C++ Projects (dll's).
This solution builds fine up to this point.
I have DevPartner studio 8.2 installed. I am trying to generate test coverage on the entire solution which requires me to instrument native c++ code during builds. when I turn this DevPartner option on, the build produces linker errors.
Does anyone have experience with this?
For example:
Error 25 error LNK2001: unresolved external symbol "public: __thiscall IntLong::IntLong(class BufObjBase *,int,int,unsigned char,wchar_t const *,bool)" (??0IntLong##QAE#PAVBufObjBase##HHEPB_W_N#Z) X.obj

A co-worker figured this out.
In case anyone else runs into this problem:
There is a dependency chain in the project between dlls, other dlls, and libraries. Under a normal build, visual studio is smart enough to find the libraries. With DevPartner inserting its instrumentation, it isn't.
Make sure all additional dependencies are explicitly specified in (properties on project getting the link error) -> Linker -> input -> Additional Dependencies.

Related

Dependencies define the same class

I am using a library cv_bridge (http://wiki.ros.org/cv_bridge) that defines a class Exception. This library depends on the library OpenCV which also defines a class Exception. Visual Studio 17 fails to build:
Error LNK2005 "public: __cdecl std::exception::exception(class std::exception const &)" (??0exception#std##QEAA#AEBV01##Z) already defined in cv_bridge.lib(cv_bridge.dll) my_project_name C:\my_project_path\MSVCRTD.lib(throw_bad_alloc.obj)
Error LNK2005 "public: virtual char const * __cdecl std::exception::what(void)const " (?what#exception#std##UEBAPEBDXZ) already defined in cv_bridge.lib(cv_bridge.dll) my_project_name C:\my_project_path\MSVCRTD.lib(throw_bad_alloc.obj)
I need to link OpenCV in order to link cv_bridge, but I don't see how I can get around this multiple symbol problem.
Is there a way around this issue aside from re-building one of the libraries? Maybe some VS17 build settings that I can configure to handle this?
Some more context: The cv_bridge package is part of the larger ROS framework, and I've used it many times within the ROS framework on Ubuntu. Now I'm trying to build a DLL in Windows to invoke from some C# code. Is it possible the ROS framework build system can bypass this issue in an ad-hoc way, and I just need to reproduce that in Windows somehow?
I don't think this issue is caused the the same defination of the class, since the two different exception classes are in different namespace.
You may try to change the configuration of the project, add the libraries to "Ignore Specific Library".
"Configuration Properties -> Linker -> Ignore Specific Library"
Add "msvcprtd.lib;MSVCRTD.lib" libraries.

Xamarin iOS Could not AOT the assembly Microsoft.EntityFrameworkCore.Migrations.Migration

We've added migrations to our xamarin forms project and ever since then we can't deploy it to an iOS device. It will run on the simulator fine but will fail with AOT errors on deploying to device.
It seems to be a fairly wide spread topic over the web but none of the ideas so far have made a difference. We're using EntityFrameworkCore v2.2.6 along with xamarin.forms v4.1.0.
I've tried adding the -v -v -v for more details on the build log but still just get:
Error Could not AOT the assembly '/Users/MyUser/Library/Caches/Xamarin/mtbs/builds/MyCompany.Mobile.iOS/8fcd0a31c7f6e1a671890e2462fe729f/obj/iPhone/Debug/mtouch-cache/3-Build/MyCompany.Data.Persistence.dll' MyCompany.Mobile.iOS
Any ideas what else I should try?
I haven't try these but it could fix your issue
IOS Build -> General -> and uncheck the option Incremental Build.
Disable LLVM.
Remove all unnecesary classes, methods from your MyCompany.Data.Persistence.dll so it wont generate heavy code.
Change Linking to Link All Assemblies
Xamarin.Android applications use a linker to reduce the size
The default value is SdkOnly
None: No linking will be attempted.
SdkOnly: Linking will be performed on the base class libraries only, not user's assemblies.
Full: Linking will be performed on base class libraries and user assemblies. For more details refer here.. Note: if you are facing an issue with linking such as
"GetAdditionalResourcesFromAssemblies" task failed unexpectedly. System.IO.FileNotFoundException: . Perhaps it doesn't exist in the Mono for Android profile?
then recheck your xamarin.Android project settings and set the below tag,
true
It Should Solve Your Problem.

Autofac Build() throws exception on latest Xamarin iOS when Linker configured to Link All

After upgrading to Visual Studio 16.3.0 (Visual Studio for Mac 8.3.1805) Autofac throwns an exeception when doing builder.Build() in a project that previously worked:
The type 'Autofac.Features.Indexed.KeyedServiceIndex'2' does not
implement the interface 'Autofac.Features.Indexed.IIndex'2'
With this release of Visual Studio (and maybe earlier versions too), iOS is compiled using Mono 6.4.0.198 and I suspected that this might be what is introducing the braking change. Alternatively the linker behaves differently with the latest tool-chain. All I can say is that this used to work and now it doesn't.
Following these guidelines is not sufficient: Cross-Platform and Native Applications
To work around the issue, first make sure that Autofac is installed both in the iOS project, Android and the .NET Standard shared project, then choose one of these two options:
Set the linker to Don't link or Link Framework SDK's Only
Or, you can; add --linkskip=Autofac (case sensitive!) to the Additional mtouch arguments in iOS Build found in the iOS project properties.
Or, you can; create a Custom Linker Configuration file, which I btw think is the best option if you need linking. It's a little bit more work, but when using a Linker Description file the compiler will give you usable feedback when you build, if you've made a mistake like misspelling an assembly etc. Also, the Linker Description file has an identical format across Android and iOS.
Note: Option 2 and 3 will only increase your app size a small amount, as it will ensure that all of the Autofac assembly is included in your app package, while all other assemblies not specified as part of 2 or 3 will continue to be linked.
I assume that the needs for one of these work-arounds is an indication that Autofac is currently not linker safe.

Xamarin+Monotouch: Could not AOT the assembly '.../obj/iPhone/Release/mtouch-cache/Build/Touch.exe' (MT3001)

I'm getting the following error during compilation when "Linker Behavior: Link All Assemblies" option is enabled:
Error MT3001: Could not AOT the assembly
'.../obj/iPhone/Release/mtouch-cache/Build/Touch.exe' (MT3001)
What is interesting that with "Link Nothing" or "Link SDK Assemblies Only" solution is compiled just fine.
Any thoughts how to fix or at least diagnose this issue?
I'm using Xamarin Studio + MonoTouch (latest stable releases)
Thanks!
Look at the full build output (you'll find it in the Errors pad in Xamarin Studio, there's a button you can click to show it).
Feel free to ask again if you don't understand what's happening in the build output.

Linker error LNK2019 (unresolved symbol) with OpenCV 2.4, CvBlob library, and Visual Studio 2012 RC

I've spent the last hour or two trying to hunt this problem down and can't seem to get it right. I am using OpenCV with MS VS 2012 RC, and to this point it has worked quite well (one bug dealing with the newer Mat container, but fine otherwise). I have a previously written application I am trying to port (from GCC/G++), which used the cvblob.dll library from here. I have recompiled the cvblob library with VS2012 (my previous version was compiled with MinGW and worked flawlessly), and managed to create both a DLL and an import library .LIB.
The application compiles properly, but the one spot where I use the cvblob library is now my source of error, because the linker cannot find the symbol for the cvLabel function in the library. This is the complete error message I get from VS2012:
ConsoleApplication1.cpp
1> Generating Code...
1>imageinput.obj : error LNK2019: unresolved external symbol _cvLabel referenced in function "public: class std::vector,class std::allocator > > _thiscall ImageInput::getROI(class cv::Mat,class cv::Mat)" (?getROI#ImageInput##QAE?AV?$vector#V?$Rect#H#cv##V?$allocator#V?$Rect_#H#cv###std###std##VMat#cv##0#Z)
1>C:\Users\Jake\Documents\Visual Studio 2012\Projects\ConsoleApplication1\Debug\ConsoleApplication1.exe : fatal error LNK1120: 1 unresolved externals
I'm not certain whether this is a problem with the cvblob library itself, my current binary for it, or just the process I used to compile it. I will gladly furnish any information I can upon request. Thanks in advance for your advice!
You obviously didn't link needed library in project settings. Try to add all OpenCV/CvBlob libs in linker properties of your prooject. See docs.
Also look at this discussion.

Resources