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

Build error on v1.1.2: redefinition of ‘struct std::hash<std::filesystem::__cxx11::path>’ #1047

Open
eduvfalc opened this issue Feb 7, 2024 · 5 comments
Labels

Comments

@eduvfalc
Copy link

eduvfalc commented Feb 7, 2024

Hi,

When trying to build and install CNL v1.1.2 I ran through the following error:

[ 95%] Building CXX object test/unit/CMakeFiles/test-unit-presentations-cppcon2017.dir/presentations/cppcon2017.cpp.o
/home/falco/repos/cnl-1.1.2/test/unit/presentations/cppcon2017.cpp:24:13: error: redefinition of ‘struct std::hash<std::filesystem::__cxx11::path>’
   24 | struct std::hash<filesystem::path> {
      |             ^~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/filesystem:45,
                 from /home/falco/repos/cnl-1.1.2/test/unit/presentations/cppcon2017.cpp:16:
/usr/include/c++/11/bits/fs_path.h:1361:10: note: previous definition of ‘struct std::hash<std::filesystem::__cxx11::path>’
 1361 |   struct hash<filesystem::path>
      |          ^~~~~~~~~~~~~~~~~~~~~~

It happens in both cppcon2017.cpp and cppcon2018.cpp. Any hint on what might be going wrong here or what I can be missing?

Note: I am running it on WSL Ubuntu 22.04

@eduvfalc eduvfalc added the bug label Feb 7, 2024
@johnmcfarlane
Copy link
Owner

Hi Eduardo,

Thanks for letting me know. If you could provide any of the info listed here, it would be helpful. In particular, compiler version and flags are likely to explain this.

That specialization was previously not defined until C++17. Likely, a toolchain defined this in its standard library implementation since a certain version. It would be useful to confirm this. It would appear benign though if it's the only error you're seeing.

Cheers,
John

@eduvfalc
Copy link
Author

eduvfalc commented Feb 7, 2024

Hi John,

Thanks for the prompt reply. For your convenience, please find below the template-friendly problem I am facing and further info.

Describe the bug

When trying to build and install CNL v1.1.2 I ran through the following error:

[ 95%] Building CXX object test/unit/CMakeFiles/test-unit-presentations-cppcon2017.dir/presentations/cppcon2017.cpp.o
/home/falco/repos/cnl-1.1.2/test/unit/presentations/cppcon2017.cpp:24:13: error: redefinition of ‘struct std::hash<std::filesystem::__cxx11::path>’
   24 | struct std::hash<filesystem::path> {
      |             ^~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/filesystem:45,
                 from /home/falco/repos/cnl-1.1.2/test/unit/presentations/cppcon2017.cpp:16:
/usr/include/c++/11/bits/fs_path.h:1361:10: note: previous definition of ‘struct std::hash<std::filesystem::__cxx11::path>’
 1361 |   struct hash<filesystem::path>
      |          ^~~~~~~~~~~~~~~~~~~~~~

It happens in both cppcon2017.cpp and cppcon2018.cpp.

To Reproduce

Run the following commands:

mkdir build && cd build
cmake ..
cmake --build . --target install

Expected behavior

Files successfully installed in the system.

Desktop

OS: Ubuntu 22.04.3 LTS Jammy
CMake: 3.22.1
Compilers: gcc/g++ 11.4.0
Compiler flags used: default values apart from those set by the CNL build structure
Conan: 2.0.17
CNL: Latest release, v1.1.2

Please let me know if you need more information.

@eduvfalc
Copy link
Author

eduvfalc commented Feb 8, 2024

Hi John,

I downgraded my gcc/g++ compilers to version 10.5 instead of 11.4. Now the build is successful. The issue is not present in my system anymore, so I guess we can close this one.

@johnmcfarlane
Copy link
Owner

Please don't close. CNL is intended to work with both versions of the compiler.

@eduvfalc
Copy link
Author

eduvfalc commented Feb 8, 2024

Ok, let me know what else you will need from me and I can feed you with more details of the issue. I am still able to reproduce it should I upgrade the version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants