ANGLE build for Windows 10 target and msvc toolchain

399 views
Skip to first unread message

Shawn Zhang

unread,
Nov 17, 2020, 9:21:38 AM11/17/20
to angleproject
Good morning everyone. I am so glad that there is such a group and I can ask question on using ANGLE.

It seems that the default ninja build is configured to output both static and shared libraries for Linux platform. I have been trying to build ANGLE for Windows 10 target and using MSVC toolchain, by adding the parameters in out/Debug/args.gn, parameters like correct me if I am not doing the right things):
target_os = "win"
target_cpu = "x64"
visual_studio_path = "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional"
visual_studio_version = "2019"
wdk_path = "C:\Program Files (x86)\Windows Kits\10"
windows_sdk_path = "C:\Program Files (x86)\Windows Kits\10"

But when I run: autoninja -C out/Debug, I have following error message:
ninja: Entering directory `out/Debug'
[1/1] Regenerating ninja files
FAILED: build.ninja
../../buildtools/win/gn.exe --root=../.. -q gen .
ERROR at //build/toolchain/win/BUILD.gn:418:38: This is not a string.
                                     visual_studio_runtime_dirs,
                                     ^-------------------------
Instead I see a list = []
See //build/toolchain/win/BUILD.gn:476:3: whence it was called.
  win_toolchains("x86") {
  ^----------------------
See //BUILD.gn:49:3: which caused the file to be included.
  group("all") {
  ^-------------
ninja: error: rebuilding 'build.ninja': subcommand failed

It looks like there is a type conflicts in the args.gn. I would appreciate it very much of any help on the build issue.

Thanks.

Geoff Lang

unread,
Nov 17, 2020, 12:36:44 PM11/17/20
to shouqing...@gmail.com, angleproject
We don't actively test msvc with a custom visual studio path so I'm not surprised that's broken, sorry about that.  Can you try narrowing down which arg caused the problem by starting with a simple args.gn and adding more args until it breaks/works?

Something like:
is_clang=false

--
You received this message because you are subscribed to the Google Groups "angleproject" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angleproject...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/angleproject/4707b796-5b3b-453e-b493-9158e078bb03n%40googlegroups.com.

Shawn Zhang

unread,
Nov 17, 2020, 2:02:54 PM11/17/20
to angleproject
Hi Geoff, thanks for the reply. 

It seems that it is this line in args.gn that is causing the error:

visual_studio_path =  "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional"

Is it because the string is not properly formated?

Thanks.

Geoff Lang

unread,
Nov 17, 2020, 2:12:56 PM11/17/20
to shouqing...@gmail.com, angleproject
It's possibly a bug from our build files from Chromium. Can you look for this file in angle:


and change 

visual_studio_runtime_dirs = []

to

visual_studio_runtime_dirs = ""

No guarantee if that will be enough but we can file a bug if it fixes your issue.

Shawn Zhang

unread,
Nov 17, 2020, 3:21:23 PM11/17/20
to angleproject

Thanks for the suggestion. It indeed fixes that particular issue, and you may wanna go ahead to file a bug for that.

But I am having new issues:
ninja: Entering directory `out\Debug'
[1/1] Regenerating ninja files
FAILED: build.ninja
../../buildtools/win/gn.exe --root=../.. -q gen .
ERROR at //build/toolchain/win/BUILD.gn:414:24: Script returned non-zero exit code.
  win_toolchain_data = exec_script("setup_toolchain.py",
                       ^----------
Current dir: C:/angle/out/Debug/
Command: C:/Users/s.zhang/depot_tools/bootstrap-3_8_0_chromium_8_bin/python/bin/python.exe C:/angle/build/toolchain/win/setup_toolchain.py "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional" "C:\Program Files (x86)\Windows Kits\10"  win x86 environment.x86
Returned 2 and printed out:

Usage setup_toolchain.py <visual studio path> <win sdk path> <runtime dirs> <target_os> <target_cpu> <environment block name|none>

See //build/toolchain/win/BUILD.gn:476:3: whence it was called.
  win_toolchains("x86") {
  ^----------------------
See //BUILD.gn:49:3: which caused the file to be included.
  group("all") {
  ^-------------
ninja: error: rebuilding 'build.ninja': subcommand failed

Geoff Lang

unread,
Nov 17, 2020, 5:03:13 PM11/17/20
to shouqing...@gmail.com, angleproject
This is unfortunately going beyond my understanding of the toolchain files, we inherit these from Chrome. The best place to ask next is file a bug with crbug.com/new and describe the issue. If you link me the bug I can help route it.

Jamie Madill

unread,
Nov 17, 2020, 5:09:22 PM11/17/20
to Geoff Lang, shouqing...@gmail.com, angleproject
Something is going wrong detecting VS. You shouldn't need to set any of those extra MSVS GN variables. Ensure DEPOT_TOOLS_WIN_TOOLCHAIN=0 in your environment, and then check to see if your VS install dir matches any in this pattern:

def DetectVisualStudioPath():
  """Return path to the installed Visual Studio.
  """

  # Note that this code is used from
  # build/toolchain/win/setup_toolchain.py as well.
  version_as_year = GetVisualStudioVersion()

  # The VC++ >=2017 install location needs to be located using COM instead of
  # the registry. For details see:
  # https://blogs.msdn.microsoft.com/heaths/2016/09/15/changes-to-visual-studio-15-setup/
  # For now we use a hardcoded default with an environment variable override.
  for path in (
      os.environ.get('vs%s_install' % version_as_year),
      os.path.expandvars('%ProgramFiles(x86)%' +
                         '/Microsoft Visual Studio/%s/Enterprise' %
                         version_as_year),
      os.path.expandvars('%ProgramFiles(x86)%' +
                         '/Microsoft Visual Studio/%s/Professional' %
                         version_as_year),
      os.path.expandvars('%ProgramFiles(x86)%' +
                         '/Microsoft Visual Studio/%s/Community' %
                         version_as_year),
      os.path.expandvars('%ProgramFiles(x86)%' +
                         '/Microsoft Visual Studio/%s/Preview' %
                         version_as_year),
      os.path.expandvars('%ProgramFiles(x86)%' +
                         '/Microsoft Visual Studio/%s/BuildTools' %
                         version_as_year)):
    if path and os.path.exists(path):
      return path

If you don't have any program files directory that matches these (for 2019/16.0 or 2017/15.0) then the generator will fail.

Shawn Zhang

unread,
Nov 18, 2020, 9:46:23 AM11/18/20
to angleproject
Thanks Jamie for the information.

I started with no args setting for msvc. Bu running the autoninja command on Windows, the generated static libraries, like libEGL and libGLESv2 were not recognized by visual studio (2019). The complaint was that the libs were corrupt or invalid. I used dumpbin to check the libs, the result is "warning LNK4048: Invalid format file; ignored"

I ran objdump on linux to check the same library,  the output is of file format pe-x86-64. So the output format is not for windows.

When I looked at vs_toolchain.py, line 57

if ((_HostIsWindows() or os.path.exists(json_data_file))
      and depot_tools_win_toolchain):

What it is saying is that when depot_tools_win_toolchain is "1" the logics below will be executed. But we set "DEPOT_TOOLS_WIN_TOOLCHAIN" to zero? Is there a conflict?

Thanks.

Shawn Zhang

unread,
Nov 18, 2020, 9:58:45 AM11/18/20
to angleproject
Is there a sample configuration for Windows 10 target, or what do you suggest to configure the build system to have the Windows 10 as target and msvc as toolchain?

Your help is greatly appreciated!

Jamie Madill

unread,
Nov 18, 2020, 10:09:27 AM11/18/20
to shouqing...@gmail.com, angleproject
Hi Shawn,

Most likely it's because of a difference in build settings, like x64 vs x86, and Debug vs Release. I'd recommend using ANGLE as a shared library.

Good luck!

Shawn Zhang

unread,
Nov 18, 2020, 10:12:43 AM11/18/20
to angleproject
Thanks and will give it a try!

Shawn Zhang

unread,
Nov 18, 2020, 11:40:34 AM11/18/20
to angleproject
So I cleared all other args settings except:
is_clang = false
is_debug = true
target_os = "win"
target_cpu = "x64"

in order to generate libs for "win" and "x64" on the target, the autoninja complained about unresolved externals in protobuf:
FAILED: protobuf_lite.dll protobuf_lite.dll.lib protobuf_lite.dll.pdb
C:/Users/s.zhang/depot_tools/bootstrap-3_8_0_chromium_8_bin/python/bin/python.exe ../../build/toolchain/win/tool_wrapper.py link-wrapper environment.x64 False link.exe /nologo /IMPLIB:./protobuf_lite.dll.lib /DLL /OUT:./protobuf_lite.dll /PDB:./protobuf_lite.dll.pdb @./protobuf_lite.dll.rsp
message_lite.obj : error LNK2001: unresolved external symbol "protected: char const * __cdecl google::protobuf::internal::EpsCopyInputStream::InitFrom(class google::protobuf::io::ZeroCopyInputStream *)" (?InitFrom@EpsCopyInputStream@internal@protobuf@google@@IEAAPEBDPEAVZeroCopyInputStream@io@34@@Z)

extension_set.obj : error LNK2001: unresolved external symbol "protected: char const * __cdecl google::protobuf::internal::EpsCopyInputStream::InitFrom(class google::protobuf::io::ZeroCopyInputStream *)" (?InitFrom@EpsCopyInputStream@internal@protobuf@google@@IEAAPEBDPEAVZeroCopyInputStream@io@34@@Z)

generated_message_table_driven_lite.obj : error LNK2001: unresolved external symbol "protected: char const * __cdecl google::protobuf::internal::EpsCopyInputStream::InitFrom(class google::protobuf::io::ZeroCopyInputStream *)" (?InitFrom@EpsCopyInputStream@internal@protobuf@google@@IEAAPEBDPEAVZeroCopyInputStream@io@34@@Z)

generated_message_util.obj : error LNK2001: unresolved external symbol "protected: char const * __cdecl google::protobuf::internal::EpsCopyInputStream::InitFrom(class google::protobuf::io::ZeroCopyInputStream *)" (?InitFrom@EpsCopyInputStream@internal@protobuf@google@@IEAAPEBDPEAVZeroCopyInputStream@io@34@@Z)

implicit_weak_message.obj : error LNK2001: unresolved external symbol "protected: char const * __cdecl google::protobuf::internal::EpsCopyInputStream::InitFrom(class google::protobuf::io::ZeroCopyInputStream *)" (?InitFrom@EpsCopyInputStream@internal@protobuf@google@@IEAAPEBDPEAVZeroCopyInputStream@io@34@@Z)

message_lite.obj : error LNK2001: unresolved external symbol "private: struct std::pair<char const *,bool> __cdecl google::protobuf::internal::EpsCopyInputStream::DoneFallback(char const *,int)" (?DoneFallback@EpsCopyInputStream@internal@protobuf@google@@AEAA?AU?$pair@PEBD_N@std@@PEBDH@Z)

extension_set.obj : error LNK2001: unresolved external symbol "private: struct std::pair<char const *,bool> __cdecl google::protobuf::internal::EpsCopyInputStream::DoneFallback(char const *,int)" (?DoneFallback@EpsCopyInputStream@internal@protobuf@google@@AEAA?AU?$pair@PEBD_N@std@@PEBDH@Z)

generated_message_table_driven_lite.obj : error LNK2001: unresolved external symbol "private: struct std::pair<char const *,bool> __cdecl google::protobuf::internal::EpsCopyInputStream::DoneFallback(char const *,int)" (?DoneFallback@EpsCopyInputStream@internal@protobuf@google@@AEAA?AU?$pair@PEBD_N@std@@PEBDH@Z)

generated_message_util.obj : error LNK2001: unresolved external symbol "private: struct std::pair<char const *,bool> __cdecl google::protobuf::internal::EpsCopyInputStream::DoneFallback(char const *,int)" (?DoneFallback@EpsCopyInputStream@internal@protobuf@google@@AEAA?AU?$pair@PEBD_N@std@@PEBDH@Z)

implicit_weak_message.obj : error LNK2001: unresolved external symbol "private: struct std::pair<char const *,bool> __cdecl google::protobuf::internal::EpsCopyInputStream::DoneFallback(char const *,int)" (?DoneFallback@EpsCopyInputStream@internal@protobuf@google@@AEAA?AU?$pair@PEBD_N@std@@PEBDH@Z)

message_lite.obj : error LNK2001: unresolved external symbol "private: char const * __cdecl google::protobuf::internal::EpsCopyInputStream::SkipFallback(char const *,int)" (?SkipFallback@EpsCopyInputStream@internal@protobuf@google@@AEAAPEBDPEBDH@Z)

extension_set.obj : error LNK2001: unresolved external symbol "private: char const * __cdecl google::protobuf::internal::EpsCopyInputStream::SkipFallback(char const *,int)" (?SkipFallback@EpsCopyInputStream@internal@protobuf@google@@AEAAPEBDPEBDH@Z)

generated_message_table_driven_lite.obj : error LNK2001: unresolved external symbol "private: char const * __cdecl google::protobuf::internal::EpsCopyInputStream::SkipFallback(char const *,int)" (?SkipFallback@EpsCopyInputStream@internal@protobuf@google@@AEAAPEBDPEBDH@Z)

generated_message_util.obj : error LNK2001: unresolved external symbol "private: char const * __cdecl google::protobuf::internal::EpsCopyInputStream::SkipFallback(char const *,int)" (?SkipFallback@EpsCopyInputStream@internal@protobuf@google@@AEAAPEBDPEBDH@Z)

implicit_weak_message.obj : error LNK2001: unresolved external symbol "private: char const * __cdecl google::protobuf::internal::EpsCopyInputStream::SkipFallback(char const *,int)" (?SkipFallback@EpsCopyInputStream@internal@protobuf@google@@AEAAPEBDPEBDH@Z)

message_lite.obj : error LNK2001: unresolved external symbol "private: char const * __cdecl google::protobuf::internal::EpsCopyInputStream::AppendStringFallback(char const *,int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > *)" (?AppendStringFallback@EpsCopyInputStream@internal@protobuf@google@@AEAAPEBDPEBDHPEAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)

extension_set.obj : error LNK2001: unresolved external symbol "private: char const * __cdecl google::protobuf::internal::EpsCopyInputStream::AppendStringFallback(char const *,int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > *)" (?AppendStringFallback@EpsCopyInputStream@internal@protobuf@google@@AEAAPEBDPEBDHPEAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)

generated_message_table_driven_lite.obj : error LNK2001: unresolved external symbol "private: char const * __cdecl google::protobuf::internal::EpsCopyInputStream::AppendStringFallback(char const *,int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > *)" (?AppendStringFallback@EpsCopyInputStream@internal@protobuf@google@@AEAAPEBDPEBDHPEAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)

generated_message_util.obj : error LNK2001: unresolved external symbol "private: char const * __cdecl google::protobuf::internal::EpsCopyInputStream::AppendStringFallback(char const *,int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > *)" (?AppendStringFallback@EpsCopyInputStream@internal@protobuf@google@@AEAAPEBDPEBDHPEAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)

implicit_weak_message.obj : error LNK2001: unresolved external symbol "private: char const * __cdecl google::protobuf::internal::EpsCopyInputStream::AppendStringFallback(char const *,int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > *)" (?AppendStringFallback@EpsCopyInputStream@internal@protobuf@google@@AEAAPEBDPEBDHPEAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)

message_lite.obj : error LNK2001: unresolved external symbol "private: char const * __cdecl google::protobuf::internal::EpsCopyInputStream::ReadStringFallback(char const *,int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > *)" (?ReadStringFallback@EpsCopyInputStream@internal@protobuf@google@@AEAAPEBDPEBDHPEAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)

extension_set.obj : error LNK2001: unresolved external symbol "private: char const * __cdecl google::protobuf::internal::EpsCopyInputStream::ReadStringFallback(char const *,int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > *)" (?ReadStringFallback@EpsCopyInputStream@internal@protobuf@google@@AEAAPEBDPEBDHPEAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)

generated_message_table_driven_lite.obj : error LNK2001: unresolved external symbol "private: char const * __cdecl google::protobuf::internal::EpsCopyInputStream::ReadStringFallback(char const *,int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > *)" (?ReadStringFallback@EpsCopyInputStream@internal@protobuf@google@@AEAAPEBDPEBDHPEAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)

generated_message_util.obj : error LNK2001: unresolved external symbol "private: char const * __cdecl google::protobuf::internal::EpsCopyInputStream::ReadStringFallback(char const *,int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > *)" (?ReadStringFallback@EpsCopyInputStream@internal@protobuf@google@@AEAAPEBDPEBDHPEAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)

implicit_weak_message.obj : error LNK2001: unresolved external symbol "private: char const * __cdecl google::protobuf::internal::EpsCopyInputStream::ReadStringFallback(char const *,int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > *)" (?ReadStringFallback@EpsCopyInputStream@internal@protobuf@google@@AEAAPEBDPEBDHPEAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)

.\protobuf_lite.dll : fatal error LNK1120: 5 unresolved externals

Please advise what went wrong and how to fix it.
Thanks


Geoff Lang

unread,
Nov 18, 2020, 12:41:42 PM11/18/20
to shouqing...@gmail.com, angleproject
Try building just the libGLESv2 and libEGL targets.

Jamie Madill

unread,
Nov 18, 2020, 12:44:34 PM11/18/20
to Geoff Lang, shouqing...@gmail.com, angleproject
Yeah, I actually saw those protobuf errors myself when building. Not sure what setting is messing it up.

Filed https://anglebug.com/5365 . Would second Geoff's suggestion and only build libGLESv2 / libEGL, or just 'angle'.

Shawn Zhang

unread,
Nov 18, 2020, 1:46:12 PM11/18/20
to angleproject
Thanks Jamie and Geoff. How to build just one library using Ninja?

Jamie Madill

unread,
Nov 18, 2020, 1:47:56 PM11/18/20
to shouqing...@gmail.com, angleproject
"ninja -C out/Debug angle" will build all you need

Reply all
Reply to author
Forward
0 new messages