How to use clang with Visual Studio and stlib? - visual-studio

I have installed prebuilt llvm + clang for windows 3.6.2, and Visual Studio 2015. Now in VS 2015, you can create projects and set compiler to clang. It seems the installation of clang has registered the compilers to the settings. Everything else works fine, except I cannot use and standard libraries.
The compiler setting for clang is LLVM-vs2014 under properties->general->platform tools
For instance, when compiling this code
#include <iostream>
int main(int argc, char ** argv) {
return 0; }
if I delete the #include line, everything works fine.
any idea?
The output message from VS is:
1>------ Build started: Project: TT, Configuration: Debug Win32 ------
1>clang-cl.exe : warning : argument unused during compilation: '/ZI'
1>clang-cl.exe : warning : argument unused during compilation: '/Gm'
1>clang-cl.exe : warning : argument unused during compilation: '/GS'
1>clang-cl.exe : warning : argument unused during compilation: '/fp:precise'
1>clang-cl.exe : warning : argument unused during compilation: '/FdDebug\vc140.pdb'
1> In file included from main.cpp:1:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\iostream:6:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\istream:6:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\ostream:6:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\ios:6:
1
> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xlocnum:7:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\cmath:656:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xtgmath.h:8:
1>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xtr1common(231,22): error : use of undeclared identifier 'char16_t'
1> struct _Is_integral<char16_t>
1> ^
1>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xtr1common(237,22): error : use of undeclared identifier 'char32_t'
1> struct _Is_integral<char32_t>
1> ^
1> In file included from main.cpp:1:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\iostream:6:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\istream:6:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\ostream:6:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\ios:6:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xlocnum:10:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\streambuf:6:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xiosbase:6:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xlocale:8:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\stdexcept:6:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\exception:7:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\type_traits:6:
1>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xstddef(408,14): error : use of undeclared identifier 'char16_t'
1> struct hash<char16_t>
1> ^
1>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xstddef(414,14): error : use of undeclared identifier 'char32_t'
1> struct hash<char32_t>
1> ^
1> In file included from main.cpp:1:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\iostream:6:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\istream:6:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\ostream:6:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\ios:6:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xlocnum:10:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\streambuf:6:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xiosbase:6:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xlocale:8:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\stdexcept:7:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xstring:6:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xmemory0:8:
1>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\limits(615,33): error : use of undeclared identifier 'char16_t'
1> template<> class numeric_limits<char16_t>
1> ^
1>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\limits(905,33): error : use of undeclared identifier 'char32_t'
1> template<> class numeric_limits<char32_t>
1> ^
1> In file included from main.cpp:1:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\iostream:6:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\istream:6:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\ostream:6:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\ios:6:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xlocnum:10:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\streambuf:6:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xiosbase:6:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xlocale:8:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\stdexcept:7:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xstring:6:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xmemory0:10:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xutility:8:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\utility:7:
1>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\iosfwd(267,21): error : use of undeclared identifier 'char16_t'
1> struct char_traits<char16_t>
1> ^
1>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\iosfwd(276,21): error : use of undeclared identifier 'char32_t'
1> struct char_traits<char32_t>
1> ^
1> In file included from main.cpp:1:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\iostream:6:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\istream:6:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\ostream:6:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\ios:6:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xlocnum:10:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\streambuf:6:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xiosbase:6:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xlocale:8:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\stdexcept:7:
1>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xstring(2623,22): error : use of undeclared identifier 'char16_t'
1> typedef basic_string<char16_t, char_traits<char16_t>, allocator<char16_t> >
1> ^
1>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xstring(2623,53): error : expected unqualified-id
1> typedef basic_string<char16_t, char_traits<char16_t>, allocator<char16_t> >
1> ^
1>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xstring(2625,22): error : use of undeclared identifier 'char32_t'
1> typedef basic_string<char32_t, char_traits<char32_t>, allocator<char32_t> >
1> ^
1>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xstring(2625,53): error : expected unqualified-id
1> typedef basic_string<char32_t, char_traits<char32_t>, allocator<char32_t> >
1> ^
1> In file included from main.cpp:1:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\iostream:6:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\istream:6:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\ostream:6:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\ios:6:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xlocnum:10:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\streambuf:6:
1> In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xiosbase:6:
1>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xlocale(1004,30): error : use of undeclared identifier 'char16_t'
1> class _CRTIMP2_PURE codecvt<char16_t, char, _Mbstatet>
1> ^
1>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xlocale(1328,30): error : use of undeclared identifier 'char32_t'
1> class _CRTIMP2_PURE codecvt<char32_t, char, _Mbstatet>
1> ^
1> 14 errors generated.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Clang 3.6 doesn't support the C++11 keywords char16_t and char32_t in Microsoft mode (see the source). However good news, 3.7 does and will be released in three weeks (August 21) according to the LLVM website. In the meanwhile you could install a 3.7 release candidate or a snapshot build.

Related

Missing mspdbcore.dll when compiling arm or arm64 programs with cl.exe from VS 2017

My attempts to compile the simplest of C program to ARM, directly with cl.exe on a Win10 x86-64 environment always results in the following error:
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.14.26428\bin\HostX64\arm\cl.exe" /c 1.c
1.c
c1: fatal error C1356: unable to find mspdbcore.dll
Note that everything works fine if I target x86 code: "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.14.26428\bin\HostX86\x86\cl.exe" /c 1.c
I can compile and link this program just fine if doing it from within VS. Am I missing something on the PATH? It also seems that I only have two versions of mspdbcore.dll, one in Hostx64/x64 and another one in Hostx86/x86; nothing in the arm/arm64 equivalent folders.
File: 1.c:
int main(void) {
return 0;
}
Okay, it turned out the problem was connected to missing or incorrect environment variables after all...
I set up custom overrides for PATH, INCLUDE, LIB, and LIBPATH matching the values provided by the "VC++ Directories" options of a sample ARM VS project, and things are now compiling smoothly.
Edit #1: Settings I used, for VS2017: (They can be found in the "VC++ Directories" options widget I mentioned above)
set PATH=C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.14.26428\bin\HostX86\arm;C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.14.26428\bin\HostX86\x86;C:\Program Files (x86)\Windows Kits\10\bin\10.0.17134.0\x86;C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools;C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\tools;C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\ide;C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin
set INCLUDE=C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.14.26428\include;C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.14.26428\atlmfc\include;C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\VS\include;C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\ucrt;C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um;C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\shared;C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\winrt;C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\cppwinrt;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\Include\um
set LIB=C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.14.26428\lib\ARM;C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.14.26428\atlmfc\lib\ARM;C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\VS\lib\ARM;C:\Program Files (x86)\Windows Kits\10\lib\10.0.17134.0\ucrt\arm;C:\Program Files (x86)\Windows Kits\10\lib\10.0.17134.0\um\arm;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\lib\um\arm;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\Lib\um\arm
set LIBPATH=C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.14.26428\atlmfc\lib\ARM;C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.14.26428\lib\ARM;C:\Program Files (x86)\Windows Kits\10\References
Some VS directories have mspdbcore.dll, and some don't. Declaring the path in LIBPATH doesn't fix it.
For example, .\bin\Hostx64\x64\ and .\bin\Hostx86\x86\ have mspdbcore.dll, but .\bin\Hostx64\x86\ does not, so if you want to run the 32-bit compiler on a 64-bit system, use .\bin\Hostx86\x86\cl.exe, not .\bin\Hostx64\x86\cl.exe.

Specify include directories for resources in command line

I am trying to build cURL on Windows using the following line:
nmake vc-x64 mode=dll VC=10 MACHINE=x64
Now I have done this setup before building:
set PATH=C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64;%PATH%
set INCLUDE="C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\include";"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include"
set LIB="C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\lib\amd64";"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib\amd64"
set LIBPATH="C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\lib\amd64"
set PATH="C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Bin\x64";%PATH%)
set INCLUDE="C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Include";%INCLUDE%
set LIB="C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Lib\x64";%LIB%
I get the following error:
rc /dDEBUGBUILD=0 /Fo ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-w
inssl-obj-lib\libcurl.res ..\lib\libcurl.rc
Microsoft (R) Windows (R) Resource Compiler Version 6.1.7600.16385
Copyright (C) Microsoft Corporation. All rights reserved.
..\lib\libcurl.rc(22) : fatal error RC1015: cannot open include file 'winver.h'.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A
\Bin\x64\rc.EXE"' : return code '0x1'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 10.0
\VC\bin\amd64\nmake.EXE"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 10.0
\VC\bin\amd64\nmake.EXE"' : return code '0x2'
Stop.
It does not seem to find the file "winver.h" despite the fact that this file is in the directory "C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Include", and that this directory is in my INCLUDE variable.
It looks like rc does not take in account the variable INCLUDE to find the include paths. Is there a way to add an include path for the rc command? Unless this is something completely different of course.

How do I avoid the "unresolved external symbol _mainCRTStartup" error when using the MSVC toolchain (ex: CL.EXE) from within an MSYS environment?

How do I avoid the unresolved external symbol _mainCRTStartup error when using the MSVC toolchain (ex: CL.EXE) from within an MSYS environment?
Details:
I started a "VS2013 x64 Native Tools Command Prompt" and the launched C:\msys64\msys2.exe from there.
In my MSYS session I get results like this:
user#host MSYS /c/libpostal/libpostal
$ "/c/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/amd64/vcvars64.bat"
user#host MSYS /c/libpostal/libpostal
$ cl "-nologo" "conftest.c" "-link" "-SUBSYSTEM:CONSOLE"
conftest.c
LINK : error LNK2001: unresolved external symbol _mainCRTStartup
conftest.exe : fatal error LNK1120: 1 unresolved externals
user#host MSYS /c/libpostal/libpostal
$ cat conftest.c
/* confdefs.h */
#define PACKAGE_NAME "libpostal"
#define PACKAGE_TARNAME "libpostal"
#define PACKAGE_VERSION "1.0.0"
#define PACKAGE_STRING "libpostal 1.0.0"
#define PACKAGE_BUGREPORT ""
#define PACKAGE_URL ""
#define PACKAGE "libpostal"
#define VERSION "1.0.0"
/* end confdefs.h. */
int
main ()
{
;
return 0;
}
user#host MSYS /c/libpostal/libpostal
$ echo $PATH
/c/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin:/usr/local/bin:/usr/bin:/bin:/opt/bin:/c/Windows/System32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0/:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl
If I try to put the same "cl" command into the "VS2013 x64 Native Tools Command Prompt", I get the expected result instead:
C:\libpostal\libpostal>cl "-nologo" "conftest.c" "-link" "-SUBSYSTEM:CONSOLE"
conftest.c
C:\libpostal\libpostal>cl "/nologo" "conftest.c" "/link" "/SUBSYSTEM:CONSOLE"
conftest.c
C:\libpostal\libpostal>conftest.exe
C:\libpostal\libpostal>echo %PATH%
C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow;C:\Program Files (x86)\MSBuild\12.0\bin\amd64;C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\BIN\amd64;C:\Windows\Microsoft.NET\Framework64\v4.0.30319;C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\VCPackages;C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE;C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools;C:\Program Files (x86)\HTML Help Workshop;C:\Program Files (x86)\Microsoft Visual Studio 12.0\Team Tools\Performance Tools\x64;C:\Program Files (x86)\Microsoft Visual Studio 12.0\Team Tools\Performance Tools;C:\Program Files (x86)\Windows Kits\8.1\bin\x64;C:\Program Files (x86)\Windows Kits\8.1\bin\x86;C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools\x64\;C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow;C:\Program Files (x86)\MSBuild\12.0\bin\amd64;C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\BIN\amd64;C:\Windows\Microsoft.NET\Framework64\v4.0.30319;C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\VCPackages;C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE;C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools;C:\Program Files (x86)\HTML Help Workshop;C:\Program Files (x86)\Microsoft Visual Studio 12.0\Team Tools\Performance Tools\x64;C:\Program Files (x86)\Microsoft Visual Studio 12.0\Team Tools\Performance Tools;C:\Program Files (x86)\Windows Kits\8.1\bin\x64;C:\Program Files (x86)\WindowsKits\8.1\bin\x86;C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools\x64\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Microsoft Dynamics AX\60\Client\Bin\;C:\Program Files\Microsoft Dynamics AX\60\BusinessConnector\Bin\;C:\Program Files (x86)\Microsoft SQL Server\Client SDK\ODBC\110\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\120\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\ManagementStudio\;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files(x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\Git\cmd;C:\D\dmd2\windows\bin;C:\msys64;C:\msys64\usr\local\bin;C:\msys64\usr\bin;C:\msys64\bin;C:\msys64\opt\bin
This happened while I was trying to use cccl to build a posix project (libpostal) using the MSVC toolchain so I can link it with other MSVC code. As such, any answers involving Visual Studio GUI will probably not be very helpful: I need to figure out how to make it work from within the MSYS2/MSYS64 environment.
In the MSYS example I intentionally moved /c/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin to the beginning of my $PATH to avoid selecting the wrong executables. I originally received the same results (exact same error message) when it was at the end of the $PATH instead.
After checking everything in agonizing detail, I found the problem:
When C:\msys64\msys2.exe is executed from the "VS2013 x64 Native Tools Command Prompt", the $PATH variable will end up containing /c/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin, but that is the wrong directory for 64-bit work. Instead the path should contain /c/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/amd64. Once I did that substitution, cl.exe worked fine.
Running vcvars64.bat from within the MSYS environment will not fix the $PATH. The above substitution has to be done manually or from a custom startup script like ~/.bashrc.

Unable to build - Migrating VC++ code from VS2010 to VS2013

I am trying to migrate my source from VS2010 to VS2013. It is giving me sleepless nights. I'm getting the below attached compilation error. Please help me out in identifying which compilation switch I'm missing out. I have saved my .sln file from VS2013 to get it adapted to the new environment.
My current compilation settings are as follows:
PlatformToolset: Visual Studio 2013 - Windows XP (v120_xp)
Command Line:
/Yu"stdafx.h" /FR"DebugU\" /GS /TP /analyze- /W3 /Zc:wchar_t /I"..\Common" /Zi /Gm- /Od /Fd".\DebugU/" /fp:precise /D "_PUGIXML" /D "_DEBUG" /D "_USRDLL" /D "_CRT_SECURE_NO_WARNINGS" /D "_BIND_TO_CURRENT_VCLIBS_VERSION" /D "_VC80_UPGRADE=0x0700" /D "_USING_V110_SDK71_" /D "_WINDLL" /D "_UNICODE" /D "UNICODE" /errorReport:prompt /WX /Zc:forScope /RTC1 /Gd /Oy- /showIncludes /MTd /Fa".\DebugU/" /EHsc /nologo /Fo".\DebugU/" /Fp".\DebugU/xxxxxxxx.pch"
Compilation Log with "ShowIncludes"
1> pugixml.cpp
1> Note: including file: d:\vistasonicpoc\common\pugixml.hpp
1> Note: including file: d:\vistasonicpoc\common\pugiconfig.hpp
1> Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\exception
1> Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xstddef
1> Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\cstddef
1> Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\yvals.h
1> Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xkeycheck.h
1> Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\crtdefs.h
1> Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\use_ansi.h
1> Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\initializer_list
1> Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xtr1common
1>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xtr1common(421): error C2159: more than one storage class specified
1> C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xtr1common(421) : see reference to class template instantiation 'std::_Has_result_type<_Ty>' being compiled
1>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xtr1common(421): error C3557: a function cannot have both a return type and a late-specified return type
1>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xtr1common(421): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xstddef(203): error C3557: a function cannot have both a return type and a late-specified return type
1>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xstddef(203): warning C4042: 'std::plus<void>::operator ()' : has bad storage class
1>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xstddef(203): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xstddef(218): error C3557: a function cannot have both a return type and a late-specified return type
1>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xstddef(218): warning C4042: 'std::minus<void>::operator ()' : has bad storage class
1>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xstddef(218): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xstddef(233): error C3557: a function cannot have both a return type and a late-specified return type
1>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xstddef(233): warning C4042: 'std::multiplies<void>::operator ()' : has bad storage class
1>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xstddef(233): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xstddef(248): error C3557: a function cannot have both a return type and a late-specified return type
1>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xstddef(248): warning C4042: 'std::equal_to<void>::operator ()' : has bad storage class
1>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xstddef(248): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xstddef(263): error C3557: a function cannot have both a return type and a late-specified return type
1>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xstddef(263): warning C4042: 'std::less<void>::operator ()' : has bad storage class
1>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xstddef(263): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
I had the same problem and found out that the flag /Zc:auto was set to /Zc:auto- and this was causing all the errors.
You don't seem to have it specified in the command line but it could help someone else having the same type of error.
Zc:auto

Can't link to fftw library using visual C++ express on windows 64 bit

I'm trying to link to the fftw library using visual c++ express, but am getting linker errors when I try to compile. I generated the lib files as the site (http://fftw.org/install/windows.html) explains by creating .lib "import libraries" using the lib.exe program.
I added the .lib files to "Program Files (x86)\Microsoft Visual Studio 9.0\VC\lib", and fftw3.h to "Program Files (x86)\Microsoft Visual Studio 9.0\VC\include". I then put the dll files in "Windows/system32" folder. I linked the libraries by adding them (libfftw3f-3.lib, libfftw3-3.lib, libfftw3l-3.lib) to additional dependencies on the linker/input preferences. When I try to compile I get the following errors:
process_wav.obj : error LNK2019: unresolved external symbol __imp__fftwf_destroy_plan referenced in function _main
process_wav.obj : error LNK2019: unresolved external symbol __imp__fftwf_plan_dft_r2c_1d referenced in function _main
I searched on stack overflow but most of the answers explain that the libraries need to be added to additional dependencies to be found. When I put /verbose:lib on command line options I get the following:
f
fdf
1>Linking...
1>Searching libraries
1> Searching libfftw3f-3.lib:
1> Searching libfftw3-3.lib:
1> Searching libfftw3l-3.lib:
1> Searching F:\Program Files\Mega-Nerd\libsndfile-win32-bin-1.1.7\libsndfile-1.lib:
1> Searching F:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\odbc32.lib:
1> Searching F:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\odbccp32.lib:
1> Searching F:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\kernel32.lib:
1> Searching F:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\user32.lib:
1> Searching F:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\gdi32.lib:
1> Searching F:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\winspool.lib:
1> Searching F:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\comdlg32.lib:
1> Searching F:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\advapi32.lib:
1> Searching F:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\shell32.lib:
1> Searching F:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\ole32.lib:
1> Searching F:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\oleaut32.lib:
1> Searching F:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\uuid.lib:
1> Searching F:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\lib\MSVCRTD.lib:
1> Searching F:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\lib\OLDNAMES.lib:
1> Searching F:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\lib\msvcprtd.lib:
1> Searching libfftw3f-3.lib:
1> Searching libfftw3-3.lib:
1> Searching libfftw3l-3.lib:
1> Searching F:\Program Files\Mega-Nerd\libsndfile-win32-bin-1.1.7\libsndfile-1.lib:
1> Searching F:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\odbc32.lib:
1> Searching F:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\odbccp32.lib:
1> Searching F:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\kernel32.lib:
1> Searching F:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\user32.lib:
1> Searching F:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\gdi32.lib:
1> Searching F:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\winspool.lib:
1> Searching F:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\comdlg32.lib:
1> Searching F:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\advapi32.lib:
1> Searching F:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\shell32.lib:
1> Searching F:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\ole32.lib:
1> Searching F:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\oleaut32.lib:
1> Searching F:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\uuid.lib:
1> Searching F:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\lib\MSVCRTD.lib:
1> Searching F:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\lib\OLDNAMES.lib:
1> Searching F:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\lib\msvcprtd.lib:
1> Searching libfftw3f-3.lib:
1> Searching libfftw3-3.lib:
1> Searching libfftw3l-3.lib:
1> Searching F:\Program Files\Mega-Nerd\libsndfile-win32-bin-1.1.7\libsndfile-1.lib:
1> Searching F:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\odbc32.lib:
1> Searching F:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\odbccp32.lib:
1>Finished searching libraries
It seems to find the libraries but does not know who to find the function names in them. I got the code from a website which also uses this library, interestingly the function names do not appear in "fftw3.h" but I don't think this is the cause of the problem.
Any help would be greatly appreciated as I'm not sure where to turn now.
Thanks.
The following steps work for me in Visual Studio 2008 ( from http://itkcorner.blogspot.com/2012/01/inclusion-de-fftw-en-visual-studio-2008.html );
Download the file “fftw-3.3dll32.zip from fftw org website (http://www.fftw.org/install/windows.html)
In order to link to these .dll files from Visual C++, you need to create .lib "import libraries" for them, and can do so with the "lib" command that comes with VC++. In particular, run:
lib /def:libfftw3-3.def
In “Tools > Visual Studio 2008 Command Prompt” without opening any project, just Visual. Once you are in the console, you go with the ‘cd’ command to the root where the folder is placed and once there you run the three lines above, and then the ‘lib files are created.
Copy the folder where the libs are created and then copy it inside the project folder where we want to use it and rename the folder to “FFTW_LIBS”. In this folder the necessary files are the ones that have the ‘.dll’ , ‘.lib’ and the ‘fftw3.h’.
Inclusion of the libs in the project: “Project > Properties > Configuration Properties > Linker > Entry > Additional dependencies” and then we include the three new libs files:
libfftw3-3.lib
Inclusion of the path where the libs are:
a. “Project > Properties > Configuration Properties > Linker > General > Additional libs directory” , and there we write “./FFTW_LIBS”.
b. “Project > Properties > Configuration Properties > Depuration > Environment” , and there we write “./FFTW_LIBS”.
Inclusion of the path where the ‘.dll’ file is. In “Project > Properties > Configuration Properties > Depuration > Environment”. In the variable ‘enviroment’ we have to specify where the file ‘libfftw3-3.dll’ and we write “PATH = .\FFTW_LIBS”
After all of this steps, you just have to add “ #include fftw3.h” and use the fftw functions!
I will introduce a slight modification to Antonio's steps:
Following worked for me on Windwos 10, Visual Studio 2017, 32bit application, x64 computer:
Download precompiled FFTW 3.3.5 Windows DLLs and extract the .zip file
http://www.fftw.org/install/windows.html
Open a developer cmd prompt for VS 2017 RC and go to the extracted
folder
Run the lib application as follows to create the import libraries
(.lib files) from the .dll libraries:
lib /def:libfftw3-3.def
lib /def:libfftw3f-3.def
lib /def:libfftw3l-3.def
Copy the following files into a new folder, call that new folder fftw_lib:
fftw3.h
libfftw3-3.lib
libfftw3f-3.lib
libfftw3l-3.lib
libfftw3-3.dll
libfftw3f-3.dll
libfftw3l-3.dll
Copy the "fftw_lib" folder into your project's folder
Tell the linker to include the .lib files in your project:
Project > Properties > Configuration Properties > Linker > Entry > Additional dependencies =
libfftw3-3.lib
libfftw3f-3.lib
libfftw3l-3.lib
Add the libraries' path to the Linker and Compiler:
Project > Properties > Configuration Properties > Linker > General > Additional libs directory =
C:\Users\Username\Documents\Visual Studio 2017\Projects\MP_2\MP_2\fftw_lib
Project > Properties > Configuration Properties > C/C++> General > Additional include directories =
C:\Users\Username\Documents\Visual Studio 2017\Projects\MP_2\MP_2\fftw_lib
Include the path where the dll libs are:
Project > Properties > Configuration Properties > Debugging > Environment =
PATH=C:\Users\Username\Documents\Visual Studio 2017\Projects\MP_2\MP_2\fftw_lib
The End!
Maybe at runtime it will ask you for fftw dlls missing. I got that case and simply putted 'em into system32 folder.
I am using Visual Studio 2013 Express on 64-bit Windows 7 and had the same issue as you while trying to build for x64. The problem was that I generated the .lib and .exp using lib.exe from "Developer Command Prompt for VS2013" shell. When I regenerated .lib and .exp from "VS2013 x64 Cross Tools Command Prompt" shell, then all references were resolved.

Resources