0

I tried to complile this project: https://github.com/ccshiro/corecraft I am use Ubuntu 16.04, i have installed: gcc 4.9, 5.0, 6.0; g++ 4.9, 5.0; clang; cmake3; and libsparsehash-dev .

I got this error:

[ 96%] Linking CXX executable mangosd
../game/libgame.a(Map.cpp.o): In function `sh_hashtable_settings<ObjectGuid, std::tr1::hash<ObjectGuid>, unsigned long, 4>::hash(ObjectGuid const&) const':
/usr/include/google/sparsehash/hashtable-common.h:65: undefined reference to `std::tr1::hash<ObjectGuid>::operator()(ObjectGuid) const'
collect2: error: ld returned 1 exit status
src/mangosd/CMakeFiles/mangosd.dir/build.make:244: recipe for target 'src/mangosd/mangosd' failed
make[2]: *** [src/mangosd/mangosd] Error 1
CMakeFiles/Makefile2:930: recipe for target 'src/mangosd/CMakeFiles/mangosd.dir/all' failed
make[1]: *** [src/mangosd/CMakeFiles/mangosd.dir/all] Error 2
Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2

Here Map.cpp , here /usr/include/google/sparsehash/hashtable-common.h

I ve tried to google about "collect2: error: ld returned 1 exit status" error, and found that in code might be cyrrilics or non latinics symbols, but i didnt find something wrong in this 2 files above. On issue tracker i also found same error from another person https://github.com/ccshiro/corecraft/issues/5

I am not C++ programmer so i cant understand what wrong is here, can anyone help me with this?

Amaroc
  • 179
  • 1
  • 2
  • 9
  • There's a mistake in the code, it should define `std::tr1::hash::operator()` and it does not. You are not going to get far with this, it would require someone else to start maintaining the project – M.M Jun 07 '18 at 00:26
  • Unfortunately, the developer abandoned the project, and does not respond to Issue – Amaroc Jun 07 '18 at 00:30
  • Check the forks of the project. It looks like this person has recently forked and started making fixes: https://github.com/Lephidiles/corecraft – James Poag Jun 07 '18 at 02:16
  • @JamesPoag Thank you, already seen this fork, there no big diference, i look all changes he did 50% from VS Studio (Comments), and 50% for few files with OpenSSL – Amaroc Jun 07 '18 at 03:23

1 Answers1

1

What you are seeing is a linker error. Everything compiles fine, and then when the linker starts to stitch the code together it's missing a object that defines the functionality of the std::tr1::hash<ObjectGuid>::operator() hash operator. This is a template specialization that allows this object to be used as a unique key in a map (or hash set).

The template for the hash function is specified here. At first glance, I wasn't seeing why it shouldn't link, but then I realized that the linker is looking for std::tr1::hash<ObjectGuid> instead of std::hash<ObjectGuid>. Basically, it looks like your STL library is using TR1 which is an older pre-standard version of C++11.

Your first attempt should be to figure out how to specify that your compiler uses a newer version of the STL library. You should be able to add -std=c++11 to the CMAKE C++ flags (instead of -std=c++0X). Whether this means editing the CMakeLists.txt file to include the flag or making sure that your compiler was installed with a more modern version of STL.

That should fix the problem. I can think of another solution, but I suspect that you will get more errors by linking to an older version of STL.

James Poag
  • 2,320
  • 1
  • 13
  • 20