MengeCrowdSim / Menge

The source code for the Menge crowd simulation framework
Apache License 2.0
138 stars 64 forks source link

Compile with GNU on Mac #60

Open zhangl64 opened 7 years ago

zhangl64 commented 7 years ago

Hi, I am trying to compile the project on Mac, I tried to use Apple llvm+clang, and brew installed llvm with clang, both of them have "cannot found OpenMP" error, then I moved on to gcc and g++, using the command like: cmake -DCMAKE_C_COMPILER=gcc-7 -DCMAKE_CXX_COMPILER=g++-7 -DOpenMP_C_FLAGS=-fopenmp -D CMAKE_MACOSX_RPATH=1 .. cmake succeed. However, when I tried the make command, I met "the duplicate symbol" error:

... duplicate symbol float Menge::Math::abs(Menge::Math::Vector2d const&) in: CMakeFiles/mengeCore.dir/Users/leizhang/Projects/Laipac/src/Menge/MengeCore/Agents/AgentGenerators/AgentGenerator.cpp.o CMakeFiles/mengeCore.dir/Users/leizhang/Projects/Laipac/src/Menge/MengeCore/resources/WayPortal.cpp.o duplicate symbol float Menge::Math::absSq(Menge::Math::Vector2d const&) in: CMakeFiles/mengeCore.dir/Users/leizhang/Projects/Laipac/src/Menge/MengeCore/Agents/AgentGenerators/AgentGenerator.cpp.o CMakeFiles/mengeCore.dir/Users/leizhang/Projects/Laipac/src/Menge/MengeCore/resources/WayPortal.cpp.o ld: 12660 duplicate symbols for architecture x86_64 collect2: error: ld returned 1 exit status make[2]: [/Users/leizhang/Projects/Laipac/Exe/libmengeCore.dylib] Error 1 make[1]: [Menge/MengeCore/CMakeFiles/mengeCore.dir/all] Error 2 make: *** [all] Error 2

Is this the same problem as what described in #28 ? Any suggestions about the solution? Thanks.

MengeCrowdSim commented 7 years ago

I don't have access with a mac (or expertise with it). Between your first and second tries, did you do a full clean of the project? @chraibi may have some insight. Or possibly @russgayle. They had done sterling work in getting mac builds to work in the first place.

zhangl64 commented 7 years ago

Between the first and the second tries, I used "rm" command to remove the build folder, is that OK? At the same time, I hope @chraibi and @russgayle can see my question. Thanks.

MengeCrowdSim commented 7 years ago

It's inexplicable that you'd get that linker error. For example, neither AgentGenerator.cpp or WayPortal.cpp contain the symbol abs -- so it doesn't make sense that it should report that both have that symbol. Something very weird is going on.

chraibi commented 7 years ago

I could not manage to compile Menge with g++. Now when I try, I do also get these "duplicate"-errors. @MengeCrowdSim although abs is not defined in AgentGenerator.cpp and WayPortal.cpp, these two include Math.h, where abs is defined. This seems to confuse g++ and somehow clash with std::abs.

@zhangl64 clang has OpenMP-supprt. You just have to install it, not via Homebrew. See here and this question

zhangl64 commented 7 years ago

@chraibi Thanks for the info, I will give it a try with OpenMP-enabled clang. Have you successfully built Menge with clang on Mac? or it also has some issues?

chraibi commented 7 years ago

After minor changes I can compile Menge with clang (openMP enabled).

zhangl64 commented 7 years ago

Thanks, @chraibi . I will wait for your PR, and try it again. Currently, I am moving on to Windows and Linux, it's easier for me to play around...