Unknown Objective-C runtime 'microsoft' - windows

I'm trying to compile an app with WinObjC. I'm using Visual Studio 2017 version 15.7.6 and WinObjC prerelease v0.2.180221 from NuGet.
The very first source file it tries to compile, and every subsequent one fails with the error message:
clang.exe : error : unknown or ill-formed Objective-C runtime 'microsoft'
What am I doing wrong?

You seems trying to use side loaded clang compiler, that not gonna work unfortunately, since for WinObjC have been used modified clang with custom ObjectiveC runtime added.
To build your project successfully, you must add latest WinObjC nuget packages of version v0.2.180221-dev-20180516000001 to your project along with this https://www.nuget.org/packages/WinObjC.Compiler/ compiler package, it includes proper clang forked from original clang v6.0.1. Supported VS version is v15.4.5-15.8.9
UPDATE 1
To use latest Visual Studio starting from v15.9 up to the current VS2019 v16.X, you might find useful this topic with guide how to modify your project to make it run.

Related

Unable to compile llvm pass on Windows using Visual studio

Im learning how to use the llvm toolchain on Windows.
I compiled and installed llvm using the following cmake command
cmake -S llvm -B build -DLLVM_ENABLE_PROJECTS="clang;lld" -DLLVM_USE_LINKER=lld -DLLVM_TARGETS_TO_BUILD=X86 -DCMAKE_INSTALL_PREFIX="C:\llvm" -Thost=x64
Running the INSTALL project in the solution created in the build folder installed llvm in c:\llvm.
To test my llvm installation i created a new Visual Studio project and placed a Directory.build.props file in the project root with the following contents:
<Project>
<PropertyGroup>
<LLVMInstallDir>C:\llvm</LLVMInstallDir>
<LLVMToolsVersion>14.0.0</LLVMToolsVersion>
</PropertyGroup>
</Project>
I set the project toolchain to LLVM (clang-cl) in project settings and successfully compiled a hello world program.
Now i wanna use llvm for it's intended use and play around with some passes. So i downloaded https://github.com/tsarpaul/llvm-string-obfuscator.
Running cmake -Bbuild -DLLVM_DIR=C:\llvm\lib\cmake\llvm\ generated a Visual Studio solution in .\build.
So far so good i tought. This is similar to the steps required to compile llvm itself.
But running the BUILD_ALL project in the generated solution gave me 105 linker errors.
I have pasted the entire error output here: https://pastebin.com/TAizbAEi.
I have a feeling the required libraries in C:\llvm\lib are not visible to Visual Studio. But i have no idea how to proceed. Could anyone point me in the right direction on how to use llvm with visual studio correctly?
Solved by adding to the cmake file:
llvm_map_components_to_libnames(llvm_libs core)
target_link_libraries(LLVMStringObfuscator ${llvm_libs})
Now the dll build.
I still have problems using opt.exe
PS C:\Users\Administrator\source\repos> C:\llvm\bin\opt.exe -load-pass-plugin=.\11philip22\llvm-string-obfuscator\build\StringObfuscator\Release\LLVMStringObfuscator.dll -passes="string-obfuscator-pass"
C:\llvm\bin\opt.exe: .\11philip22\llvm-string-obfuscator\build\StringObfuscator\Release\LLVMStringObfuscator.dll:1:1: error: expected top-level entity
MZÉ    ╕ # ║ ┤ ═!╕L═!This program cannot be run in DOS mode.
But that's a new problem for another thread :)

ASP.NET CORE 2.1 Preview "SharedCompilationId" parameter is not supported by the "Csc" task

I am trying run the project with views in separate class library on Mac OSX as described in below article
https://blogs.msdn.microsoft.com/webdev/2018/03/01/asp-net-core-2-1-razor-ui-in-class-libraries/
The problem is that I cannot build the class library project with Visual Studio Community 7.4 on Mac OS.
Project builds with command line (donet build) without problems but when I try to build it with Visual Studio it throws two errors:
/usr/local/share/dotnet/sdk/NuGetFallbackFolder/microsoft.aspnetcore.razor.design/2.1.0-preview1-final/build/netstandard2.0/Microsoft.AspNetCore.Razor.Design.Compilation.targets(10,10): Error MSB4064: The "SharedCompilationId" parameter is not supported by the "Csc" task. Verify the parameter exists on the task, and it is a settable public instance property. (MSB4064)
/usr/local/share/dotnet/sdk/NuGetFallbackFolder/microsoft.aspnetcore.razor.design/2.1.0-preview1-final/build/netstandard2.0/Microsoft.AspNetCore.Razor.Design.Compilation.targets(5,5): Error MSB4063: The "Csc" task could not be initialized with its input parameters. (MSB4063)
When I change RazorCompileOnBuild to false or remove Content from Content Build project compiles without errors.
Go to Nuget Console and add:
Install-Package Microsoft.Net.Compilers -Version 2.8.2
You will no longer get above mentioned error.
I had this problem on the build server but not locally.
The solution:
Install the updated Visual Studio on the build server. In my case 2017.15.4
As I find you can solve this issue in two ways.
Solution 1
Add Microsoft.Net.Compilers compilers package to the project.
Solution 2
Build the project using the command line. dotnet build
In my case, I had installed the .NET Core 2.1 SDK, but not the runtime.
Strange how Microsoft don't include the runtime in the SDK.
If you face this problem there are three steps you need to take:
Ensure that Nuget package and Target Framework match.
Ensure that the referenced runtime and sdk are installed.
Ensure that Visual Studio is up to date.

Xamarin Studio 6 incompatible with NUnit 3.2.1

I've downloaded the latest copy of xamarin studio which is 6.0 build 3668. I've built a tiny console app and I'm trying to run some unit tests through the UI in xamarin, but I get a message saying that nunit 3.2.1 is unsupported. I have a fake script which does work when run in the terminal.
Full error message is here : Skipped loading assembly test because it references an unsupported version of the nunit.framework, 3.2.1.0.
Can anyone help please ?
I have also faced the problem: "Error CS0246: The type or namespace name 'NUnit' could not be found".
It's because the .dll file is not loaded in the references of the solution.
In my case, I am using Monodevelop/Xamarin Studio 7.8.4,
having multiple NUnit dlls in the monodevelop.UnitTest directory.
Duo to this reason, I had to add reference manually.
As I am using the Ubuntu 18.04 distribution, the nunit.framework.dll assembly was locketed at: usr/lib/monodevelop/Addins/MonoDevelop.UnitTesting/NUnit2/nunitframework.dll
So, I just added this assembly to the my project and the unit test was working fine.
Note: here I have added nunit.framework 2.6.4 assembly.

Xamarin Studio cannot find an assembly which is not existing and throws compile error "Error executing task ResolveAssemblyRefernce"

I'm getting the following error when I try to compile my project:
Error executing task ResolveAssemblyReference: Could not load file or assembly '//DataLayer/bin/Debug/EntityFramework.Extended.dll' or one of its dependencies. The system cannot find the file specified. (DataLayer)
I used to use this dependency, together with EntityFramework, that is true, but I removed both of it. This all happened via nuget. A check on the project with grep:
grep -r -i EntityFramework *
reveals that the string only exists in two files inside comments, nothing else, so why am I getting this exception?
I feel the easiest thing to do right now is to start a new project and configure it properly without EntityFramework.Extended from the beginning, but I still would like to have an answer, in case I encounter similar problems in the future.
A small remark - I use Xamarin studio in OS X to develop a .Net web application in mono. I have the latest version, Xamarin Studio 5.2 with Mono 3.4 and am compiling the project by using .Net 4.0 profile.

Where is llvm-config in Windows?

I am open to either a Visual Studio answer or a MinGW answer. I just finished building LLVM 3.2 using CMake and Visual Studio 2010. Everything went smoothly, but I have no llvm-config. Do I need it? Every example I see on the intertubes makes use of that tool. If I don't need it, how do I configure my project to make use of LLVM?
To be clear, I am not trying to use LLVM tools/compilers (like clang and whatnot). I am trying to write C++ code that uses the LLVM libraries to produce LLVM IR and even compile that stuff. I setup my include and lib folders. I ran llvm-config in Linux and saw a long list of macros and libraries.
I have a wonderful folder full of goodies. It just has no llvm-config in there: C:\Program Files (x86)\LLVM\
llvm-config does not exist in windows prebuilt binaries. You need to compile from the source code to get it.
Grab CMAKE > 3.5 , install it and make sure you add it to PATH.
Download Visual Studio 2019
Donwload the source code (9.0.1 is the latest as I'm writing this)
Extract the source code
Cd into the root of the llvm source-code
In cmd, type cmake . this will generate Visual Studio 2019 sln.
open sln file(LLVM.sln), change the build type to Rlease, build the whole project
navigate to your Rlease\bin, and there you have your llvm-config.exe
If you have built the LLVM in debug version all the executables (including llvm-config) have been placed in your build directory (containing Visual Studio project and solution files) in bin/Debug/ subdirectory. In case of release build replace Debug with Release.
If you are interested in using LLVM on Windows more than building it, check out Windows snapshot builds.

Resources