Author Topic: Microsoft C/C++ compiller  (Read 705 times)

Offline lbertolotti

  • Multiple posting newcomer
  • *
  • Posts: 20
Microsoft C/C++ compiller
« on: July 01, 2017, 11:36:31 pm »
What is the best way of configuring a Microsoft C/C++ compiller on Code::Blocks?

I'm getting:
main.o : fatal error LNK1143: invalid or corrupt file: no symbol for COMDAT section 0xB
Languages: C/C++, Python and R

Online oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 10054
Re: Microsoft C/C++ compiller
« Reply #1 on: July 01, 2017, 11:58:37 pm »
Try reading this: http://wiki.codeblocks.org/index.php/FAQ-Compiling_(errors)#Q:_How_do_I_troubleshoot_a_compiler_problem.3F

Also next time when you ask for help please provide more details like:
1. full build log
2. version information for cb, compiler, os, etc
3. which compiler you've set up inside the cb's compiler settings
<debugger plugin maintainer>
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline lbertolotti

  • Multiple posting newcomer
  • *
  • Posts: 20
Re: Microsoft C/C++ compiller
« Reply #2 on: July 02, 2017, 03:07:59 am »
1.
Code: [Select]
-------------- Build: Debug in example_mic (compiler: Microsoft Compiller)---------------

link.exe /nologo /LIBPATH:"..\..\..\..\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\ucrt" /LIBPATH:"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include" /out:bin\Debug\example_mic.exe  obj\Debug\main.obj  /debug
LINK : fatal error LNK1104: cannot open file 'msvcprtd.lib'
Process terminated with status 1104 (0 minute(s), 0 second(s))
1 error(s), 0 warning(s) (0 minute(s), 0 second(s))

2.
Code::Blocks 16.01
Windows 10

3.
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC
« Last Edit: July 02, 2017, 03:10:52 am by lbertolotti »
Languages: C/C++, Python and R

Online oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 10054
Re: Microsoft C/C++ compiller
« Reply #3 on: July 02, 2017, 09:43:47 am »
This is obviously wrong: /LIBPATH:"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include"
You need to pass path where libraries are stored and not where the include files are stored.
Interestingly enough there is no guide how to set vc++ in the wiki any more.  :( :o
<debugger plugin maintainer>
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline lbertolotti

  • Multiple posting newcomer
  • *
  • Posts: 20
Re: Microsoft C/C++ compiller
« Reply #4 on: July 02, 2017, 04:09:08 pm »
This is obviously wrong: /LIBPATH:"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include"
You need to pass path where libraries are stored and not where the include files are stored.
Interestingly enough there is no guide how to set vc++ in the wiki any more.  :( :o

Now I'm gettings this:

Code: [Select]
-------------- Clean: Debug in example_mic (compiler: Microsoft Compiller)---------------

Cleaned "example_mic - Debug"

-------------- Build: Debug in example_mic (compiler: Microsoft Compiller)---------------

cl.exe /nologo /W3 /EHsc  /MDd /Zi /D_DEBUG    /I"..\..\..\..\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\ucrt" /I"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\lib" /c main.cpp /Foobj\Debug\Users\lucao\Desktop\example_mic\main.obj
main.cpp
main.cpp(1): fatal error C1083: Cannot open include file: 'iostream': No such file or directory
Process terminated with status 2 (0 minute(s), 0 second(s))
0 error(s), 0 warning(s) (0 minute(s), 0 second(s))

Languages: C/C++, Python and R

Online oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 10054
Re: Microsoft C/C++ compiller
« Reply #5 on: July 02, 2017, 04:36:52 pm »
I don't know what you're doing, but you've swapped the paths for includes and libraries.

The /I options must point to the include folders and /LIBPATH options must point to the library folders.
<debugger plugin maintainer>
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline lbertolotti

  • Multiple posting newcomer
  • *
  • Posts: 20
Re: Microsoft C/C++ compiller
« Reply #6 on: July 02, 2017, 05:25:05 pm »
I don't know what you're doing, but you've swapped the paths for includes and libraries.

The /I options must point to the include folders and /LIBPATH options must point to the library folders.

Yeah, the "Search Directories" option is the one managing the include folders, the "Linker Settings" is the one managing the library folders.

Well, I guess this build log is now ok:
Code: [Select]
-------------- Build: Debug in example_mic (compiler: Microsoft Compiller)---------------

Target is up to date.
Nothing to be done (all items are up-to-date).

The libraries linked where: msvcprtd.lib, msvcrtd.lib, oldnames.lib, ucrtd.lib, vcruntimed.lib, ucrtd.lib, kernel32.Lib
The search directories are:
..\..\..\..\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\ucrt
..\..\..\..\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include

But now "Build and run" wants the VCRUNTIME140D_APP.dll.
Languages: C/C++, Python and R

Online oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 10054
Re: Microsoft C/C++ compiller
« Reply #7 on: July 02, 2017, 05:46:38 pm »
But now "Build and run" wants the VCRUNTIME140D_APP.dll.
You have to install the proper vc runtime in order for your program to be able to find this dll.
<debugger plugin maintainer>
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline lbertolotti

  • Multiple posting newcomer
  • *
  • Posts: 20
Re: Microsoft C/C++ compiller
« Reply #8 on: July 02, 2017, 11:22:39 pm »
In debug mode the compiler wants VCRUNTIME140D_APP.dll, in release mode it wants VCRUNTIME140_APP.dll. I have the latter in Windows\InfusedApps.
Languages: C/C++, Python and R

Online oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 10054
Re: Microsoft C/C++ compiller
« Reply #9 on: July 03, 2017, 01:32:59 am »
<debugger plugin maintainer>
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Krice

  • Multiple posting newcomer
  • *
  • Posts: 35
Re: Microsoft C/C++ compiller
« Reply #10 on: July 03, 2017, 12:58:55 pm »
What is the best way of configuring a Microsoft C/C++ compiller on Code::Blocks?

Is there any reason to use it? What is the problem with gcc?

Offline cacb

  • Regular
  • ***
  • Posts: 345
Re: Microsoft C/C++ compiller
« Reply #11 on: July 03, 2017, 03:16:50 pm »

I have a writeup for MSCV2013 here. Newer versions of MSVC will need some adaptions.

Online oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 10054
Re: Microsoft C/C++ compiller
« Reply #12 on: July 03, 2017, 08:33:49 pm »
Is there any reason to use it? What is the problem with gcc?
Uses different abi, so building plugins for other softwares is hard.
Also it produces different symbols, so debugging mixed applications (gcc and vc++) is hard.
Hopefully clang for windows will make it possible to use good free compiler and target the same runtime as vc++.
<debugger plugin maintainer>
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline lbertolotti

  • Multiple posting newcomer
  • *
  • Posts: 20
Re: Microsoft C/C++ compiller
« Reply #13 on: July 03, 2017, 09:17:15 pm »
Newer versions of MSVC will need some adaptions.

Well, I have configured Code::Blocks to compile using Microsoft Visual Studio Build Tools 2017.
Code: [Select]
-------------- Build: Debug in example_mic (compiler: Microsoft VC 2017)---------------

Target is up to date.
Nothing to be done (all items are up-to-date).


-------------- Run: Debug in example_mic (compiler: Microsoft VC 2017)---------------

Checking for existence: C:\Users\lucao\Desktop\example_mic\bin\Debug\example_mic.exe
Executing: "C:\Program Files (x86)\CodeBlocks/cb_console_runner.exe" "C:\Users\lucao\Desktop\example_mic\bin\Debug\example_mic.exe"  (in C:\Users\lucao\Desktop\example_mic\.)
Process terminated with status 0 (0 minute(s), 1 second(s))

Where is the Code::Blocks global compiler settings file stored?
Languages: C/C++, Python and R

Online oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 10054
Re: Microsoft C/C++ compiller
« Reply #14 on: July 03, 2017, 10:12:58 pm »
It depends. Most of the settings are stored in default.conf in you appdata/codeblocks folder. But some of the compiler settings are stored in separate files inside this folder.
<debugger plugin maintainer>
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]