Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't Build Jinja2Cpp on Windows with Visual Studio 2017 Anymore #75

Closed
DragonOsman opened this issue Oct 17, 2018 · 12 comments
Closed
Labels
question Further information is requested wontfix This will not be worked on

Comments

@DragonOsman
Copy link

Just now, just to check, I tried to build the library on Windows again by cloning fresh into Jinja2Cpp, updating the submodule, and then running cmake -DCMAKE_INSTALL_PREFIX=../install and got this result:

C:\Jinja2Cpp\build>cmake .. -DCMAKE_INSTALL_PREFIX=../install
-- Building for: Visual Studio 15 2017
-- The C compiler identification is MSVC 19.15.26730.0
-- The CXX compiler identification is MSVC 19.15.26730.0
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.15.26726/bin/Hostx86/x86/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.15.26726/bin/Hostx86/x86/cl.exe -- broken
CMake Error at C:/Program Files (x86)/CMake/share/cmake-3.10/Modules/CMakeTestCCompiler.cmake:52 (message):
  The C compiler

    "C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.15.26726/bin/Hostx86/x86/cl.exe"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: C:/Jinja2Cpp/build/CMakeFiles/CMakeTmp

    Run Build Command:"C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/MSBuild/15.0/Bin/MSBuild.exe" "cmTC_f8e1b.vcxproj" "/p:Configuration=Debug" "/p:VisualStudioVersion=15.0"
    Microsoft (R) Build Engine version 15.8.169+g1ccb72aefa for .NET Framework
    Copyright (C) Microsoft Corporation. All rights reserved.

    Build started 10/18/2018 1:51:09 AM.
    Project "C:\Jinja2Cpp\build\CMakeFiles\CMakeTmp\cmTC_f8e1b.vcxproj" on node 1 (default targets).
    PrepareForBuild:
      Creating directory "cmTC_f8e1b.dir\Debug\".
      Creating directory "C:\Jinja2Cpp\build\CMakeFiles\CMakeTmp\Debug\".
      Creating directory "cmTC_f8e1b.dir\Debug\cmTC_f8e1b.tlog\".
    InitializeBuildStatus:
      Creating "cmTC_f8e1b.dir\Debug\cmTC_f8e1b.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified.
    VcpkgTripletSelection:
      Using triplet "x86-windows" from "C:\vcpkg\installed\x86-windows\"
    ClCompile:
      C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.15.26726\bin\HostX86\x86\CL.exe /c /I"C:\Program Files (x86)\Visual Leak Detector\include" /I"C:\vcpkg\installed\x86-windows\include" /Zi /W3 /WX- /diagnostics:classic /Od /Ob0 /Oy- /D WIN32 /D _WINDOWS /D "CMAKE_INTDIR=\"Debug\"" /D _MBCS /Gm- /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"cmTC_f8e1b.dir\Debug\\" /Fd"cmTC_f8e1b.dir\Debug\vc141.pdb" /Gd /TC /analyze- /FC /errorReport:queue C:\Jinja2Cpp\build\CMakeFiles\CMakeTmp\testCCompiler.c
      Microsoft (R) C/C++ Optimizing Compiler Version 19.15.26730 for x86
      Copyright (C) Microsoft Corporation.  All rights reserved.

      cl /c /I"C:\Program Files (x86)\Visual Leak Detector\include" /I"C:\vcpkg\installed\x86-windows\include" /Zi /W3 /WX- /diagnostics:classic /Od /Ob0 /Oy- /D WIN32 /D _WINDOWS /D "CMAKE_INTDIR=\"Debug\"" /D _MBCS /Gm- /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"cmTC_f8e1b.dir\Debug\\" /Fd"cmTC_f8e1b.dir\Debug\vc141.pdb" /Gd /TC /analyze- /FC /errorReport:queue C:\Jinja2Cpp\build\CMakeFiles\CMakeTmp\testCCompiler.c
      testCCompiler.c

    Link:
      C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.15.26726\bin\HostX86\x86\link.exe /ERRORREPORT:QUEUE /OUT:"C:\Jinja2Cpp\build\CMakeFiles\CMakeTmp\Debug\cmTC_f8e1b.exe" /INCREMENTAL /NOLOGO /LIBPATH:"C:\Program Files (x86)\Visual Leak Detector\lib\Win32" /LIBPATH:"C:\vcpkg\installed\x86-windows\debug\lib" /LIBPATH:"C:\vcpkg\installed\x86-windows\debug\lib\manual-link" kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib "C:\vcpkg\installed\x86-windows\debug\lib\*.lib" /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /DEBUG /PDB:"C:/Jinja2Cpp/build/CMakeFiles/CMakeTmp/Debug/cmTC_f8e1b.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:"C:/Jinja2Cpp/build/CMakeFiles/CMakeTmp/Debug/cmTC_f8e1b.lib" /MACHINE:X86 /SAFESEH  /machine:X86 LDFLAGS=-static-libstdc++ -static-libgcc cmTC_f8e1b.dir\Debug\testCCompiler.obj
    LINK : warning LNK4044: unrecognized option '/static-libgcc'; ignored [C:\Jinja2Cpp\build\CMakeFiles\CMakeTmp\cmTC_f8e1b.vcxproj]
    LINK : fatal error LNK1104: cannot open file 'LDFLAGS=-static-libstdc++.obj' [C:\Jinja2Cpp\build\CMakeFiles\CMakeTmp\cmTC_f8e1b.vcxproj]
    Done Building Project "C:\Jinja2Cpp\build\CMakeFiles\CMakeTmp\cmTC_f8e1b.vcxproj" (default targets) -- FAILED.

    Build FAILED.

    "C:\Jinja2Cpp\build\CMakeFiles\CMakeTmp\cmTC_f8e1b.vcxproj" (default target) (1) ->
    (Link target) ->
      LINK : warning LNK4044: unrecognized option '/static-libgcc'; ignored [C:\Jinja2Cpp\build\CMakeFiles\CMakeTmp\cmTC_f8e1b.vcxproj]


    "C:\Jinja2Cpp\build\CMakeFiles\CMakeTmp\cmTC_f8e1b.vcxproj" (default target) (1) ->
    (Link target) ->
      LINK : fatal error LNK1104: cannot open file 'LDFLAGS=-static-libstdc++.obj' [C:\Jinja2Cpp\build\CMakeFiles\CMakeTmp\cmTC_f8e1b.vcxproj]

        1 Warning(s)
        1 Error(s)

    Time Elapsed 00:00:01.68




  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:2 (project)


-- Configuring incomplete, errors occurred!
See also "C:/Jinja2Cpp/build/CMakeFiles/CMakeOutput.log".
See also "C:/Jinja2Cpp/build/CMakeFiles/CMakeError.log".

When I did it before, it worked fine. Why is there this error now?

@flexferrum
Copy link
Collaborator

That's not a problem in Jinja2Cpp lib itself. Something wrong with compiler configuration/MSVC installation. This message shouldn't be shown during normal build setup process;

"C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.15.26726/bin/Hostx86/x86/cl.exe"

Look at this: https://ci.appveyor.com/project/flexferrum/jinja2cpp/build/job/p4g3g5gef22wtujk?fullLog=true

@flexferrum flexferrum added the question Further information is requested label Oct 17, 2018
@DragonOsman
Copy link
Author

DragonOsman commented Oct 17, 2018

I'll try repairing my installation of VS2017 and see if that fixes it. In the meantime, though: in my Dockerfile project, I got to compiling the part in the cache_storage::query function where it's calling insert_or_assign, and it gave me this error:

currency_converter.cpp: In member function 'const json& cache_storage::query(const std::map<std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char> >&, const char*)':
currency_converter.cpp:707:136: error: use of 'auto insert_or_assign(M&&, K&&, V&&) [with M = std::map<const std::map<std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char> >, std::pair<std::chrono::time_point<std::chrono::_V2::steady_clock, std::chrono::duration<long int, std::ratio<1, 1000000000> > >, nlohmann::basic_json<> > >&; K = const std::map<std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char> >&; V = std::pair<std::chrono::time_point<std::chrono::_V2::steady_clock, std::chrono::duration<long int, std::ratio<1, 1000000000> > >, nlohmann::basic_json<> >]' before deduction of 'auto'
    auto insert_result = insert_or_assign(m_cache, query_data, std::make_pair(std::chrono::steady_clock::now(), json::parse(res.body())));
                                                                                                                                        ^

I'm not using it before initializing it, though, am I? It's talking about code in the initialization step itself. So what should I do here?

This is the code it's talking about:

// Receive the HTTP response
http::read(socket, buffer, res, ec);
auto insert_result = insert_or_assign(m_cache, query_data, std::make_pair(std::chrono::steady_clock::now(), json::parse(res.body())));
found = insert_result.first;

@flexferrum
Copy link
Collaborator

I'm not using it before initializing it, though, am I? It's talking about code in the initialization step itself. So what should I do here?

Looks like you've made the forward declaration of the insert_or_assign function and use it before the actual definition.

@DragonOsman
Copy link
Author

DragonOsman commented Oct 18, 2018

So I shouldn't have made the function prototype? Or did I do it wrong? Should I have put the definition before the function I'm using it in, too?

@DragonOsman
Copy link
Author

DragonOsman commented Oct 18, 2018

I think instead of auto, the return type of the function should be as documented here: https://en.cppreference.com/w/cpp/container/map/insert_or_assign . That should help. The problem is that I don't know what to define the iterator template as here. What should I define it as?

@flexferrum
Copy link
Collaborator

flexferrum commented Oct 18, 2018

@DragonOsman , everything should be fine with auto.

So I shouldn't have made the function prototype? Or did I do it wrong?

In general, regarding to function templates, the full function template definition should be visible before any usage. There are some exceptions from this rule, but not in your case. So, will you explicitly specify the return type or replace it with auto it doesn't matter. Template function should be fully defined before the first usage.

@DragonOsman
Copy link
Author

I'll leave the function prototype, and just define the function before cache_storage::query. And I'll leave it as auto. If I end up having to do this, though: auto insert_or_assign(M&& map, K&& key, V&& value)-><return_type_goes_here>;, I'll still need to know what the type actually is. Could you please help me out here in that case? Thanks.

@flexferrum
Copy link
Collaborator

With C++14/C++17 you don't need to specify trailing return type for auto functions.

@DragonOsman
Copy link
Author

I want to try building Jinja2Cpp on Windows with MinGW g++ instead. How should I edit the CMakeLists.txt file for this?

@flexferrum
Copy link
Collaborator

MinGW build is currently not tested for Jinja2Cpp.

@DragonOsman
Copy link
Author

What about clang++ on Windows? I can install LLVM+Clang.

@DragonOsman
Copy link
Author

I'm subscribing to the CMake user mailing list. I'll try asking there for help on the issue that I originally opened this thread for.

@flexferrum flexferrum added the wontfix This will not be worked on label Oct 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants