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

Offline lbertolotti

  • Multiple posting newcomer
  • *
  • Posts: 26
Re: Microsoft C/C++ compiller
« Reply #15 on: July 03, 2017, 10:46:31 pm »
Running on Windows 10 64-bit, Code::Blocks 16.01 Console Application

Toolchain executable:
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.10.25017\bin\HostX64\x64

Search directories:
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.10.25017\include
C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\ucrt

Debug Linker:
<Add library="../../../../Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.10.25017/lib/x64/libcpmt.lib" />
<Add library="../../../../Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.10.25017/lib/x64/libcmt.lib" />
<Add library="../../../../Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.10.25017/lib/x64/oldnames.lib" />
<Add library="../../../../Program Files (x86)/Windows Kits/10/Lib/10.0.15063.0/um/x64/Uuid.Lib" />
<Add library="../../../../Program Files (x86)/Windows Kits/10/Lib/10.0.15063.0/um/x64/kernel32.Lib" />
<Add library="../../../../Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.10.25017/lib/x64/libvcruntime.lib" />
<Add library="../../../../Program Files (x86)/Windows Kits/10/Lib/10.0.15063.0/ucrt/x64/libucrt.lib" />

Release linker:
<Add library="../../../../Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.10.25017/lib/x64/libcpmt.lib" />
<Add library="../../../../Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.10.25017/lib/x64/libcmt.lib" />
<Add library="../../../../Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.10.25017/lib/x64/oldnames.lib" />
<Add library="../../../../Program Files (x86)/Windows Kits/10/Lib/10.0.15063.0/um/x64/Uuid.Lib" />
<Add library="../../../../Program Files (x86)/Windows Kits/10/Lib/10.0.15063.0/um/x64/kernel32.Lib" />
<Add library="../../../../Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.10.25017/lib/x64/libvcruntime.lib" />
<Add library="../../../../Program Files (x86)/Windows Kits/10/Lib/10.0.15063.0/ucrt/x64/libucrt.lib" />

All files were obtained through Visuak Studio Build Tools 2017. Large projects will, of course, need more files.
Languages: C/C++, Python and R

Offline sodev

  • Multiple posting newcomer
  • *
  • Posts: 95
Re: Microsoft C/C++ compiller
« Reply #16 on: July 04, 2017, 04:22:20 am »
Why do you have these strange relative paths to the libraries? Actually why do you have paths to libraries at all? Usually you just specify search directories and add libraries by name only. Also you link runtime libraries explicit, this should be wrong, at least for the basic libraries, not sure about WinRT and the like. The compiler picks the proper ones itself depending on the used switches, e.g. /MT or /MD.

Offline cacb

  • Regular
  • ***
  • Posts: 355
Re: Microsoft C/C++ compiller
« Reply #17 on: July 04, 2017, 10:08:12 am »
Well, I have configured Code::Blocks to compile using Microsoft Visual Studio Build Tools 2017.

Can you share the configuration settings?

As mentioned, the settings are mostly in  default.conf

Offline lbertolotti

  • Multiple posting newcomer
  • *
  • Posts: 26
Re: Microsoft C/C++ compiller
« Reply #18 on: July 04, 2017, 04:18:07 pm »
Well, I have configured Code::Blocks to compile using Microsoft Visual Studio Build Tools 2017.

Can you share the configuration settings?

I already shared the configuration settings.

Why do you have these strange relative paths to the libraries? Actually why do you have paths to libraries at all? Usually you just specify search directories and add libraries by name only. Also you link runtime libraries explicit, this should be wrong, at least for the basic libraries, not sure about WinRT and the like. The compiler picks the proper ones itself depending on the used switches, e.g. /MT or /MD.

If you think you can do better, then show us how to do it.
Languages: C/C++, Python and R

Offline sodev

  • Multiple posting newcomer
  • *
  • Posts: 95
Re: Microsoft C/C++ compiller
« Reply #19 on: July 04, 2017, 07:30:01 pm »
You have to differentiate between two types of compiler configuration, the global one and the project specifc one. In the global configuration i put everything that is required to build for a specific target environment, in the project one (which are multiple in fact) i put everything required for the specific project configuration, in my case its Debug and Release.

I dont have Visual Studio 2017 and i dont build for x64, i have Visual Studio 2015 and i build for x32 with the Windows XP toolkit, so my paths are different than yours and i need some extra settings, but this should outline the steps anyway.

Code: [Select]
Global Configuration
Compiler settings / Other compiler options
/FS  -> required for parallel build to work

Compiler settings / #defines
_USING_V110_SDK71_  -> required for Windows XP toolkit

Search directories / Compiler
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\include  -> required for Windows XP toolkit
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt

Search directories / Linker
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\lib
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\lib  -> required for Windows XP toolkit
C:\Program Files (x86)\Windows Kits\10\lib\10.0.10240.0\ucrt\x86

Search directories / Resource compiler
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\include  -> required for Windows XP toolkit
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt

Toolchain executables / Compiler's installation directory
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC

Toolchain executables / Additional Paths
C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\bin

Other Settings / Advanced options / Link object files to executable
$linker /nologo /subsystem:windows,5.01 $libdirs /out:$exe_output $libs $link_objects $link_resobjects $link_options  -> required for Windows XP toolkit

Other Settings / Advanced options / Link object files to console executable
$linker /nologo /subsystem:console,5.01 $libdirs /out:$exe_output $libs $link_objects $link_resobjects $link_options  -> required for Windows XP toolkit

Now the following project settings are almost like the defaults that Visual Studio uses itself (note: the command line compiler DOES NOT use these as defaults, thats why i have to specify them)

Code: [Select]
Debug Configuration
Compiler settings / Compiler Flags
/Zi
/W4
/Od
/fp:precise
/GR
/RTCsu
/Gm
/MDd

Compiler settings / Other compiler options
/EHsc

Compiler settings / #defines
_CRT_SECURE_NO_DEPRECATE  -> to get rid of annoying warnings of otherwise perfect standard compliant code
_DEBUG
UNICODE
_UNICODE

Linker settings / Other linker options
/DEBUG
/INCREMENTAL
/MANIFEST
/DYNAMICBASE
/NXCOMPAT
/MANIFESTUAC:"level='asInvoker' uiAccess='false'"

Code: [Select]
Release Configuration
Compiler settings / Compiler Flags
/W4
/O2
/fp:precise
/GR
/MD

Compiler settings / Other compiler options
/EHsc

Compiler settings / #defines
_CRT_SECURE_NO_DEPRECATE  -> to get rid of annoying warnings of otherwise perfect standard compliant code
NDEBUG
UNICODE
_UNICODE

Linker settings / Other linker options
/INCREMENTAL:NO
/MANIFEST
/DYNAMICBASE
/NXCOMPAT
/MANIFESTUAC:"level='asInvoker' uiAccess='false'"

This is enough to build simple Hello World console applications. Depending on your project you need to add additional search directories for the compiler and linker and add your libraries to link with, but you only add them by name, e.g. you add under Link libraries kernel32 and uuid without path, they are searched for in the paths you defined in the Global Configuration.