s2geometry icon indicating copy to clipboard operation
s2geometry copied to clipboard

Error while building on windows

Open keyliaran opened this issue 7 years ago • 21 comments

C:\Users\shkil\Downloads\s2geometry-master\s2geometry-master\src\s2/third_party/absl/container/internal/layout.h(352): error C2971: std::tuple_element:

keyliaran avatar Jun 06 '18 18:06 keyliaran

What compiler version? Can you paste more of the error log?

@danielhlarkin had the Windows version working at one point.

jmr avatar Jun 06 '18 19:06 jmr

@danielhlarkin @jmr Microsoft Visual Studio Community 2015v. 14.0.25421.03 Update 3 And here is the full log https://pastebin.com/ysq2MTuv

keyliaran avatar Jun 07 '18 11:06 keyliaran

Thanks for posting the full log. I'll look into it and see if I can figure out what's going on there.

dhly-etc avatar Jun 07 '18 12:06 dhly-etc

@danielhlarkin What version did you test with?

jmr avatar Jun 21 '18 19:06 jmr

@jmr Sorry, I have not had a chance to look into this yet. I don't actually have a Windows box of my own to play around with at the moment, but I should have one within the next few weeks. I believe the prior building/testing was done with MSVC 2015, but I do not have an exact version handy.

dhly-etc avatar Jun 26 '18 14:06 dhly-etc

I have the same issue using MSVC 14.3. I found a post on stackoverflow that illuminated the issue (it's an MSVC compiler bug). I applied the suggested workaround in pull request #42

I'm not suggesting it necessarily be merged. I'm mostly putting it up so @keyliaran might be able to continue on building the project, and maybe @danielhlarkin can evaluate a proper fix (that may or may not contain parts of what I posted).

AndrewAtAvenza avatar Jul 19 '18 18:07 AndrewAtAvenza

I just installed Visual Studio 2017 (specifically MSVC 15.7.5) and tried building master without my changes and it compiles without problem. So whatever the bug was, they fixed it sometime in the 2017 time frame.

AndrewAtAvenza avatar Jul 20 '18 14:07 AndrewAtAvenza

@AndrewAtAvenza May I have a question?While building the project in Visual Sutdio 2017, there was a error "E2512 The parameter of the function test macro must be a simple identifier" in the line 535/617 of "attributes.h". I am looking forward to your help, thanks a lot.

rsdggs avatar Oct 08 '18 13:10 rsdggs

Sorry, its been busy at work. I'll try it and take a look today and get back to you.

AndrewAtAvenza avatar Oct 11 '18 13:10 AndrewAtAvenza

Okay, that will be great, thank you.

rsdggs avatar Oct 11 '18 13:10 rsdggs

I just re-pulled and went through the (excruciating) process of configuring cmake. I finally spat out a 64-bit VS2017 solution and built the s2 project without any errors.

What version of VS2017 are you running? I'm running 15.8.0 currently.

AndrewAtAvenza avatar Oct 11 '18 13:10 AndrewAtAvenza

It was running on the 15.8.3, the error above appeared when I tried to run the project in console application, for the aim to debug the source code.

rsdggs avatar Oct 11 '18 14:10 rsdggs

I'm not sure what causes that. I can get the s2 library to build no problem; I have trouble with the s2testing because I didn't include GTest and that means s2testing won't build. Sadly, because of that, the examples term_index & point_index don't build either because they rely on S2Testing to generate random points. I could probably lift that code over manually though.

That all said, I looked for attributes.h and found where it's include -- raw_loggin.cc. I don't have any trouble building that file so I don't seem to be encountering the same problem you are.

The lines you cite as problematic both include ABSL_HAVE_CPP_ATTRIBUTE, which basically just wraps __has_cpp_attribute. ABSL_HAVE_CPP_ATTRIBUTE would be #define'd as nothing if you didn't have __has_cpp_attribute though. On my machine, the compiler fails the check (which makes sense, it's looking for clang attributes) and instead lights up:

#define ABSL_XRAY_ALWAYS_INSTRUMENT #define ABSL_XRAY_NEVER_INSTRUMENT #define ABSL_XRAY_LOG_ARGS(N)

Hmm, actually, dumb question: are you trying to build on Windows with clang? I'm not, and if you are, that is probably the difference.

AndrewAtAvenza avatar Oct 11 '18 14:10 AndrewAtAvenza

Thanks for your such detailed commemt, which is much helpful for me. I will try what you have sugeested. And I tried build on Windows with&without clang respectively.Besides, there may be other reasons of the error, I will make my best to find out them.

rsdggs avatar Oct 11 '18 15:10 rsdggs

@AndrewAtAvenza May I have a question?While building the project in Visual Sutdio 2017, there was a error "E2512 The parameter of the function test macro must be a simple identifier" in the line 535/617 of "attributes.h". I am looking forward to your help, thanks a lot.

@AluxRay Any solutions to this yet ?

mohapatras avatar Jan 16 '20 04:01 mohapatras

Hi, I could make a new issue, but this is named so aptly.

I have managed to set up a decent build config under Windows 10, including the latest update with the abseil libs (compiled with -DCMAKE_CXX_STANDARD=17 -DCMAKE_POSITION_INDEPENDENT_CODE=ON) from just a few days ago. With a conda environment for cmake and "Visual Studio 16 2019" MSVC compiler and activating this "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\Common7\Tools\VsDevCmd.bat" -arch=amd64

A compile error arises from S2Testing code:

C:\dev\build\s2geometry\src\s2\s2testing.cc(69): error C3861: 'srandom': identifier not found C:\dev\build\s2geometry\src\s2\s2testing.cc(73): error C3861: 'srandom': identifier not found C:\dev\build\s2geometry\src\s2\s2testing.cc(98): error C3861: 'random': identifier not found

I can't figure out which libraries or dependencies are missing, I don't understand where the functions come from. The build would complete successfully otherwise. Is that from std:: and missing on Windows?

allixender avatar Nov 18 '21 15:11 allixender

That will be deleted soon and replaced with absl random functions. I'll bump it up my priority list.

jmr avatar Nov 18 '21 15:11 jmr

In the meantime, you can probably just add

#include <stdlib.h>

at the top and it should work.

AndrewAtAvenza avatar Nov 18 '21 15:11 AndrewAtAvenza

Thanks for the swift reply. I'll put at the top of s2testing.cc (or s2testing.h)?

I am now getting linker errors. But I assume that is only related to the project configs, because they seem to relate to a few absl libs.

s2.lib(s2cell_index.obj) : error LNK2001: unresolved external symbol "private:
static void const * const absl::hash_internal::MixingHashState::kSeed" (?kSeed@
MixingHashState@hash_internal@absl@@0QEBXEB) [C:\dev\build\s2geometry\build\pyt
hon\_pywraps2.vcxproj]
s2.lib(s2closest_cell_query.obj) : error LNK2001: unresolved external symbol "p
rivate: static void const * const absl::hash_internal::MixingHashState::kSeed"
(?kSeed@MixingHashState@hash_internal@absl@@0QEBXEB) [C:\dev\build\s2geometry\b
uild\python\_pywraps2.vcxproj]
s2PYTHON_wrap.obj : error LNK2001: unresolved external symbol "private: static
void const * const absl::hash_internal::MixingHashState::kSeed" (?kSeed@MixingH
ashState@hash_internal@absl@@0QEBXEB) [C:\dev\build\s2geometry\build\python\_py
wraps2.vcxproj]
s2.lib(s2polygon.obj) : error LNK2001: unresolved external symbol "private: sta
tic void const * const absl::hash_internal::MixingHashState::kSeed" (?kSeed@Mix
ingHashState@hash_internal@absl@@0QEBXEB) [C:\dev\build\s2geometry\build\python
\_pywraps2.vcxproj]
s2.lib(s2region_coverer.obj) : error LNK2001: unresolved external symbol "priva
te: static void const * const absl::hash_internal::MixingHashState::kSeed" (?kS
eed@MixingHashState@hash_internal@absl@@0QEBXEB) [C:\dev\build\s2geometry\build
\python\_pywraps2.vcxproj]
s2.lib(s2min_distance_targets.obj) : error LNK2001: unresolved external symbol
"private: static void const * const absl::hash_internal::MixingHashState::kSeed
" (?kSeed@MixingHashState@hash_internal@absl@@0QEBXEB) [C:\dev\build\s2geometry
\build\python\_pywraps2.vcxproj]
s2.lib(s2polygon.obj) : error LNK2019: unresolved external symbol "enum absl::c
ontainer_internal::ctrl_t const * const absl::container_internal::kEmptyGroup"
(?kEmptyGroup@container_internal@absl@@3QBW4ctrl_t@12@B) referenced in function
 "public: __cdecl absl::container_internal::raw_hash_set<struct absl::container
_internal::FlatHashSetPolicy<class S2Loop const *>,struct absl::container_inter
nal::HashEq<class S2Loop const *,void>::Hash,struct absl::container_internal::H
ashEq<class S2Loop const *,void>::Eq,class std::allocator<class S2Loop const *>
 >::~raw_hash_set<struct absl::container_internal::FlatHashSetPolicy<class S2Lo
op const *>,struct absl::container_internal::HashEq<class S2Loop const *,void>:
:Hash,struct absl::container_internal::HashEq<class S2Loop const *,void>::Eq,cl
ass std::allocator<class S2Loop const *> >(void)" (??1?$raw_hash_set@U?$FlatHas
hSetPolicy@PEBVS2Loop@@@container_internal@absl@@UHash@?$HashEq@PEBVS2Loop@@X@2
3@UEq@523@V?$allocator@PEBVS2Loop@@@std@@@container_internal@absl@@QEAA@XZ) [C:
\dev\build\s2geometry\build\python\_pywraps2.vcxproj]
s2.lib(s2region_coverer.obj) : error LNK2001: unresolved external symbol "enum
absl::container_internal::ctrl_t const * const absl::container_internal::kEmpty
Group" (?kEmptyGroup@container_internal@absl@@3QBW4ctrl_t@12@B) [C:\dev\build\s
2geometry\build\python\_pywraps2.vcxproj]
s2.lib(s2boolean_operation.obj) : error LNK2001: unresolved external symbol "en
um absl::container_internal::ctrl_t const * const absl::container_internal::kEm
ptyGroup" (?kEmptyGroup@container_internal@absl@@3QBW4ctrl_t@12@B) [C:\dev\buil
d\s2geometry\build\python\_pywraps2.vcxproj]
s2.lib(s2cell_index.obj) : error LNK2001: unresolved external symbol "enum absl
::container_internal::ctrl_t const * const absl::container_internal::kEmptyGrou
p" (?kEmptyGroup@container_internal@absl@@3QBW4ctrl_t@12@B) [C:\dev\build\s2geo
metry\build\python\_pywraps2.vcxproj]
s2.lib(s2text_format.obj) : error LNK2019: unresolved external symbol "unsigned
 char const * const absl::ascii_internal::kPropertyBits" (?kPropertyBits@ascii_
internal@absl@@3QBEB) referenced in function "public: class absl::strings_inter
nal::SplitIterator<class absl::strings_internal::Splitter<class absl::ByChar,st
ruct absl::SkipWhitespace,class std::basic_string_view<char,struct std::char_tr
aits<char> > > > & __cdecl absl::strings_internal::SplitIterator<class absl::st
rings_internal::Splitter<class absl::ByChar,struct absl::SkipWhitespace,class s
td::basic_string_view<char,struct std::char_traits<char> > > >::operator++(void
)" (??E?$SplitIterator@V?$Splitter@VByChar@absl@@USkipWhitespace@2@V?$basic_str
ing_view@DU?$char_traits@D@std@@@std@@@strings_internal@absl@@@strings_internal
@absl@@QEAAAEAV012@XZ) [C:\dev\build\s2geometry\build\python\_pywraps2.vcxproj]
C:\dev\build\s2geometry\build\python\Release\_pywraps2.pyd : fatal error LNK112
0: 3 unresolved externals [C:\dev\build\s2geometry\build\python\_pywraps2.vcxpr
oj]

The abseil-cpp was configured like so:

cmake -DCMAKE_CXX_STANDARD=17 -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_INSTALL_PREFIX=C:\dev\build\s2geometry\abseil-cpp\absl-install ..

And then S2 referring to the absl build (I tried both with shared libs on and off):

cmake -DCMAKE_INSTALL_PREFIX=%CONDA_PREFIX%\Library -DCMAKE_PREFIX_PATH=C:\dev\build\s2geometry\abseil-cpp\absl-install -DWITH_PYTHON=ON -DBUILD_SHARED_LIBS=OFF ..

Any ideas?

allixender avatar Nov 18 '21 15:11 allixender

It's been awhile since I built s2 but based on those linker errors, it's clearly looking for ABSL symbols -- so probably either ABSL source is missing from the project or an ABSL input library is missing.

AndrewAtAvenza avatar Nov 18 '21 16:11 AndrewAtAvenza

What's the command that's running when these errors are generated? Try cmake with -DCMAKE_VERBOSE_MAKEFILE=on, but I don't really know if that works on Windows.

jmr avatar Nov 19 '21 11:11 jmr

Reopen if you're still seeing problems.

jmr avatar Jan 27 '24 10:01 jmr