+ 1

Installing MSVC2015 Correctly for C++/CLI in CodeBlocks

I wanted to try learning C++/CLI, but as I don't have Visual Studio, I decided to get the compiler for CodeBlocks itself. I downloaded VS2015 BuldTools, ensured a valid install of all the components and the .NET Framework 4.6.1, and then completed the setup of the comiler's include folders and libraries. I then added the /clr directive in the Other Compiler Options. I then tried to compile the following code : #using <mscorlib.dll> using namespace System; int main(array<String^>^args) { Console::WriteLine("Hello world"); return 0; } But I got a single error - LINK||fatal error LNK1104: cannot open file 'MSCOREE.lib'| How to correct this error? I tried searching the net, but could not find any solution. Perhaps it may be that I missed some library folder, but these are what I have included under linker settings : C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\lib C:\Program Files (x86)\Windows Kits\8.1\Lib C:\Program Files (x86)\Windows Kits\10\Lib C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A Did I miss some folder? I am not sure...

16th Dec 2017, 5:27 PM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
10 Respuestas
+ 4
@~swim~ Thank You very much for the help, as that was perhaps the final missing folder. I am now able to compile codes with /clr option, but I face another problem. I am unable to detect any errors in my codes, even if there are some present. The compiler automatically runs the last successful uild version for me, and never notifies me of any error if it exists. How can I disable this 'Last Build Program Running'? I have just started with C++/CLI and to truly get a hang of it I must be notified of any error, But the compiler is not doing so. Why is this happening?
19th Dec 2017, 6:12 AM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 3
@~swim~ My problem is something else. Suppose I write : Console.Writeline(0); instead of Console::WriteLine("0");, I expect atleast 2 errors to be displayed in the build messages : 1) Console is a static class, cannot use '.' (In a better language of course). 2) No method called Writeline found in the Console Class. But instead, the Compiler returns no errors, and just runs the last built version that ran perfectly. I know this as when I changed the Arguments of WriteLine, I got the argument passed earlier instead on the screen. I don't expect the compiler to notify me of Logical errors, but I must be notified of Syntax Errors, Semantic Errors in some cases, Ambiguities, Access levels, undeclared variables, etc. And if the code is being compiled for the first time and has errors, the compiler simply stops compiling. Please help me get the errors back!
19th Dec 2017, 11:35 AM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 3
@~swim~ Ok. I didn't get that earlier. Ill just try and let you know. Thank You very much for your help.
23rd Dec 2017, 12:56 PM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 2
Just this : cl /clr a.cpp
18th Dec 2017, 5:02 PM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 2
@James 1) Yes, I could setup debugger to GDB/CDB. I didn't set breakpoints myself, I just linked the exe files. But do we have to set the debugger even for syntax errors that are to be detected before compilation? I don't think I did that with my GCC compiler, but it works fine... 2) I just wanted to try it in CodeBlocks, as the option was given, and perhaps the compiler tab meant that any compiler is supported. Basically I wanted an IDE in which I could switch from GCC to MSVC anytime.
19th Dec 2017, 6:45 PM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 2
@~swim~ Nope, it still exists, and so I just compile codes using the command client for now. I can see the build log tab. Shall I post the command used for compilation here?
23rd Dec 2017, 12:33 PM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 2
@~swim~ How will the build log notify me of the errors?
23rd Dec 2017, 12:38 PM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 1
@~swim~ 1) Ill have to check, as I have searched the linked folders and couldn't find any. Will a downloaded version work too? 2) I don't think so, but it may be. But even then, the linked folders contain libraries inside for both 64 and 32 bit versions. So am I to link the folders inside these? 3) I just made a c++ file, set the new compiler as default, added /clr to the other compiler settings, and tried compiling the code. I can't find any C++/CLI application template inside the templates menu, when I do 'Create New Project'. All I have is Win32 GUI Application, Console Application, and some other projects related to SDL, SFML, Qt, etc.
18th Dec 2017, 7:10 AM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 1
@~swim~ Ill link the folder NETFXSD now, as I found it just now. Also, I was able to compile a code saved in notepad using the Visual Studio Native Tools Command Prompt with the /clr option, easily.
18th Dec 2017, 4:28 PM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
0
@~swim~ When I build the obj file from the Native Tools Command Client, I am notified of any errors that exist like this: Error Line 15 - Expected ; after Console::WriteLine() Line 20 - No instance of 'Console' found named 'Console' etc. But when I run the code from the IDE, I just get : Build Failed - 0h 0m 1s. Can it be that the stderr for the compiler is not linked to the IDE somehow? I did enable \Wall and the others, still getting nothing on the message tab. Even declaration of a variable but not using it is a warning in VS, but i can't see it. Can I link the IDE's exe to out.txt or any other file as well?
20th Dec 2017, 5:39 AM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar