Closed chraibi closed 7 years ago
Several items:
1) What version g++ are you running? I'm suspecting there's direct correlation between your compiling problems and that. 2) MacOSX is not explicitly supported (mainly because none of the core developers have or develop on mac. :/) So, we'll have to work with you to help work through these fixes, document them and make sure others can enjoy the fruits of your labor.
(By the way, Mohcine, welcome to Menge fun. :) You'll be glad to hear we're going to be releasing our GCF plug-in soon.)
I see. the g++
is actually a clang
compiler (Apple LLVM version 8.0.0).
I will try to get this running and document my steps here.
(Glad to see you doing GCM - with ellipses I trust 👍 )
I know there are some older relics in the Menge code that newer compilers aren't particularly happy about. And I really haven't tested this against clang. For example, the tri/unordered_map
is an older relic that is no longer viable vis a vis C++0x11(or 14).
(And it wouldn't be GCM if it wasn't ellipses. :) I had written it a couple of years ago so it worked with Menge, but when we changed up the architecture, we didn't get a chance to bring it over. Right now, I've got good agent-agent interactions, I just have to figure out why my obstacle interactions are terrible.)
Ok I did some progress. I'll try here to document my steps to get Menge
compiled under OSX.
g++
: mkdir build && cd build
cmake -D CMAKE_CXX_COMPILER=g++-5 -D CMAKE_C_COMPILER=gcc-5 -D CMAKE_MACOSX_RPATH=1..
That solves the above mentioned MACOSX_RPATH
-issue
-- Could NOT find SDL_ttf (missing: SDL_TTF_LIBRARIES SDL_TTF_INCLUDE_DIRS)
Easily solved by installing sdl_ttf
brew install sdl_ttf
Now no complains from cmake
. Next step make
g++-5.0
/Users/chraibi/Workspace/Menge/src/Menge/MengeCore/Agents/PrefVelocity.cpp:93:34:
error: 'SPAN_EPS' was not declared in this scope
assert( det( right, left ) >= SPAN_EPS );
clang
fatal error: 'tr1/unordered_map' file not found
#include <tr1/unordered_map>
😃
Do you use C++11
or not yet? If yes, you can use std::unordered_map
instead of tr1::unordered_map
This is easily solved (with g++).
The problem is that the code assumes that "assert" is only compiled in debug mode. As such, the SPAN_EPS
value is only defined when _DEBUG is defined.
I just committed a patch that should resolve this.
Generally, this reflects a bug in the code. The documentation of the assert method is that it gets compiled unless the symbol NDEBUG
is defined prior to reading the cassert
header file. So, places that currently say:
#if _DEBUG
...
#endif
Should read:
#ifndef NDEBUG
...
#endif
Ok, let's for now stick with g++
since the above problem is solved.
Next problem
src/Menge/MengeCore/SceneGraph/graphCommon.h:50:19:
fatal error: GL/gl.h: No such file or directory
Apprently I don't have OpenGL
. so
brew install freeglut
To answer the earlier question, this code is all pre-c++11. It's going to make the jump (in one painful move) from 03 to 14 (skipping 11). I don't know when, but eventually. And the sooner the better.
Yeah now that even 17 is coming..
Anyway,
The GL/gl.h
can be solved
#ifdef __APPLE__
#include <OpenGL/gl.h>
#else
#include "GL/gl.h"
#endif
Next error:
src/Menge/MengeCore/Math/RandGenerator.cpp:105:20: error:
'CLOCK_REALTIME' was not declared in this scope
clock_gettime( CLOCK_REALTIME, &t );
^
src/Menge/MengeCore/Math/RandGenerator.cpp:105:39: error:
'clock_gettime' was not declared in this scope
clock_gettime( CLOCK_REALTIME, &t );
I'm going to make a PR.
It appears apple does not implement the POSIX real time extension. So, in order get high-precision time we need to do something akin to this.
In this case, it's probably irrelevant. A low resolution timer would be sufficient just to grab an int
for the random number generator seed. That said, it'll crop up elsewhere as well. So, we need an apple-dependent block here.
I found this workaroud which seems to be ok. What do you think? It compiles fine right now.
(I'm at 67% now 😄 )
I don't have a strong feeling for the solution out of context. I'll wait to form an opinion after I see the whole pull request.
What other errors are you getting?
Any idea where the errors in this branch come from?
In MengeCore's cmakefile
I found that linking the libraries to the MengeCore is necessary to compile this lib
target_link_libraries ( mengeCore dl tinyxml ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} ${SDL_LIBRARY} ${PNG_LIBRARY} ${SDLIMAGE_LIBRARY} ${SDLTTF_LIBRARY})
However, now I m stuck with some linking errors. Maye you have a hint. (it is late now... gonna have a sleep)
For reference sake -- in case I can't get the same linker errors -- what are the linking errors you're getting?
duplicate symbol Menge::Math::Vector3d<float>::z() const in:
CMakeFiles/mengeCore.dir/Users/chraibi/Workspace/Menge/src/Menge/MengeCore/Agents/AgentGenerators/AgentGenerator.cpp.o
CMakeFiles/mengeCore.dir/Users/chraibi/Workspace/Menge/src/Menge/MengeCore/Agents/AgentGenerators/AgentGeneratorDatabase.cpp.o
duplicate symbol Menge::Math::Vector3d<float>::y() const in:
CMakeFiles/mengeCore.dir/Users/chraibi/Workspace/Menge/src/Menge/MengeCore/Agents/AgentGenerators/AgentGenerator.cpp.o
CMakeFiles/mengeCore.dir/Users/chraibi/Workspace/Menge/src/Menge/MengeCore/Agents/AgentGenerators/AgentGeneratorDatabase.cpp.o
duplicate symbol Menge::Math::Vector2d<float>::y() const in:
CMakeFiles/mengeCore.dir/Users/chraibi/Workspace/Menge/src/Menge/MengeCore/Agents/AgentGenerators/AgentGenerator.cpp.o
CMakeFiles/mengeCore.dir/Users/chraibi/Workspace/Menge/src/Menge/MengeCore/Agents/AgentGenerators/AgentGeneratorDatabase.cpp.o
duplicate symbol Menge::Math::Vector3d<float>::x() const in:
CMakeFiles/mengeCore.dir/Users/chraibi/Workspace/Menge/src/Menge/MengeCore/Agents/AgentGenerators/AgentGenerator.cpp.o
CMakeFiles/mengeCore.dir/Users/chraibi/Workspace/Menge/src/Menge/MengeCore/Agents/AgentGenerators/AgentGeneratorDatabase.cpp.o
duplicate symbol Menge::Math::Vector2d<float>::x() const in:
CMakeFiles/mengeCore.dir/Users/chraibi/Workspace/Menge/src/Menge/MengeCore/Agents/AgentGenerators/AgentGenerator.cpp.o
CMakeFiles/mengeCore.dir/Users/chraibi/Workspace/Menge/src/Menge/MengeCore/Agents/AgentGenerators/AgentGeneratorDatabase.cpp.o
duplicate symbol Menge::Math::Vector3d<float>::zero() in:
CMakeFiles/mengeCore.dir/Users/chraibi/Workspace/Menge/src/Menge/MengeCore/Agents/AgentGenerators/AgentGenerator.cpp.o
CMakeFiles/mengeCore.dir/Users/chraibi/Workspace/Menge/src/Menge/MengeCore/Agents/AgentGenerators/AgentGeneratorDatabase.cpp.o
duplicate symbol Menge::Math::Vector2d<float>::zero() in:
CMakeFiles/mengeCore.dir/Users/chraibi/Workspace/Menge/src/Menge/MengeCore/Agents/AgentGenerators/AgentGenerator.cpp.o
CMakeFiles/mengeCore.dir/Users/chraibi/Workspace/Menge/src/Menge/MengeCore/Agents/AgentGenerators/AgentGeneratorDatabase.cpp.o
duplicate symbol Menge::Math::Vector3d<float>::Length() const in:
CMakeFiles/mengeCore.dir/Users/chraibi/Workspace/Menge/src/Menge/MengeCore/Agents/AgentGenerators/AgentGenerator.cpp.o
CMakeFiles/mengeCore.dir/Users/chraibi/Workspace/Menge/src/Menge/MengeCore/Agents/AgentGenerators/AgentGeneratorDatabase.cpp.o
duplicate symbol Menge::Math::Vector2d<float>::Length() const in:
CMakeFiles/mengeCore.dir/Users/chraibi/Workspace/Menge/src/Menge/MengeCore/Agents/AgentGenerators/AgentGenerator.cpp.o
CMakeFiles/mengeCore.dir/Users/chraibi/Workspace/Menge/src/Menge/MengeCore/Agents/AgentGenerators/AgentGeneratorDatabase.cpp.o
duplicate symbol Menge::Math::Vector3d<float>::operator-() const in:
CMakeFiles/mengeCore.dir/Users/chraibi/Workspace/Menge/src/Menge/MengeCore/Agents/AgentGenerators/AgentGenerator.cpp.o
CMakeFiles/mengeCore.dir/Users/chraibi/Workspace/Menge/src/Menge/MengeCore/Agents/AgentGenerators/AgentGeneratorDatabase.cpp.o
duplicate symbol Menge::Math::Vector2d<float>::operator-() const in:
CMakeFiles/mengeCore.dir/Users/chraibi/Workspace/Menge/src/Menge/MengeCore/Agents/AgentGenerators/AgentGenerator.cpp.o
CMakeFiles/mengeCore.dir/Users/chraibi/Workspace/Menge/src/Menge/MengeCore/Agents/AgentGenerators/AgentGeneratorDatabase.cpp.o
I think we need to back out the linking solution. What were the compilation problems you were having that were alleviated by adding the extra libraries?
Well, for the time being I gave up g++
. Trying OSX's native compiler clang
I just get everything compiled and linked. Good news!
The only relevant change was in a file written by Ulrich 😈 . See this commit
Now let's come back to g++
, since clang
is very slow (no OpenMP
support yet!!! :trollface: )
We have two important CMakeLists.txt
:
in MengeMain
: here menge
is linked to the lib MengeCore
.
an important line is this
target_link_libraries ( menge mengeCore tinyxml ${OPENGL_LIBRARIES}
${SDL_LIBRARY}
${PNG_LIBRARY}
${SDLIMAGE_LIBRARY}
${SDLTTF_LIBRARY} )
in MengeCore
: and here the lib used in 1. is compiled and linked.
here the line that I have problems with
target_link_libraries ( mengeCore dl )
However, MengeCore
depends on some other libs. This why on my system make VERBOSE=1
yields: linking errors like :
[ 76%] Linking CXX shared library /Users/chraibi/Workspace/Menge/Exe/libmengeCore.dylib
Undefined symbols for architecture x86_64:
"_IMG_Init", referenced from:
Menge::ImageData::start() in image.cpp.o
"_IMG_Load", referenced from:
Menge::readImageData(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) in image.cpp.o
"_IMG_Quit", referenced from:
Menge::ImageData::release() in image.cpp.o
"_SDL_Delay", referenced from:
Menge::Vis::GLViewer::initSDL(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) in GLViewer.cpp.o
"_SDL_EnableKeyRepeat", referenced from:
Menge::Vis::GLViewer::initSDL(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) in GLViewer.cpp.o
"_SDL_FreeSurface", referenced from:
Menge::SceneGraph::TextWriter::printLine(_TTF_Font*, char const*, float, float, int) in TextWriter.cpp.o
Menge::ImageData::~ImageData() in image.cpp.o
This is only solved by linking all required missing libs to MengeCore
target_link_libraries ( mengeCore tinyxml ${OPENGL_LIBRARIES}
${SDL_LIBRARY}
${PNG_LIBRARY}
${SDLIMAGE_LIBRARY}
${SDLTTF_LIBRARY} )
and
then link only this to menge
target_link_libraries ( menge MengeCore)
And here we have the duplicate symbol problems.
[ 4%] Linking CXX shared library /Users/chraibi/Workspace/Menge/Exe/libmengeCore.dylib
duplicate symbol Menge::Math::Vector3d<float>::z() const in:
CMakeFiles/mengeCore.dir/Users/chraibi/Workspace/Menge/src/Menge/MengeCore/Agents/AgentGenerators/AgentGenerator.cpp.o
CMakeFiles/mengeCore.dir/Users/chraibi/Workspace/Menge/src/Menge/MengeCore/Agents/AgentGenerators/AgentGeneratorDatabase.cpp.o
duplicate symbol Menge::Math::Vector3d<float>::y() const in:
CMakeFiles/mengeCore.dir/Users/chraibi/Workspace/Menge/src/Menge/MengeCore/Agents/AgentGenerators/AgentGenerator.cpp.o
CMakeFiles/mengeCore.dir/Users/chraibi/Workspace/Menge/src/Menge/MengeCore/Agents/AgentGenerators/AgentGeneratorDatabase.cpp.o
duplicate symbol Menge::Math::Vector2d<float>::y() const in:
CMakeFiles/mengeCore.dir/Users/chraibi/Workspace/Menge/src/Menge/MengeCore/Agents/AgentGenerators/AgentGenerator.cpp.o
CMakeFiles/mengeCore.dir/Users/chraibi/Workspace/Menge/src/Menge/MengeCore/Agents/AgentGenerators/AgentGeneratorDatabase.cpp.o
duplicate symbol Menge::Math::Vector3d<float>::x() const in:
CMakeFiles/mengeCore.dir/Users/chraibi/Workspace/Menge/src/Menge/MengeCore/Agents/AgentGenerators/AgentGenerator.cpp.o
CMakeFiles/mengeCore.dir/Users/chraibi/Workspace/Menge/src/Menge/MengeCore/Agents/AgentGenerators/AgentGeneratorDatabase.cpp.o
duplicate symbol Menge::Math::Vector2d<float>::x() const in:
CMakeFiles/mengeCore.dir/Users/chraibi/Workspace/Menge/src/Menge/MengeCore/Agents/AgentGenerators/AgentGenerator.cpp.o
In the spirit of trying to find differences. I'm running cmake v 3.5.1 and g++ version 5.4.0 under ubuntu 16 and building just fine. What versions of cmake and g++ are you running?
I can't see why linking mengeCore is necessary. It is being built into a shared library which means that the linking against its dependencies should be deferred to run time.
What's particularly bizarre about this is that the duplicate symbols are only found in two files. Those math constructs are referenced all over the place. Very, very strange.
cmake
: 3.6.2
g++
: 5.3.0
I did not understand your comment. Linking menge
to mengeCore
is necessary.
And Linking mengeCore
to e.g. SDL is necessary I think, don't you?
Concerning, Ubuntu see this issue #32
Hey! I was playing around with this project and saw this issue. I've been able to compile and run on MacOSX. I'm on MacOSX El Capital (10.11.6); using Apple's clang (v 7.3.0).
@MengeCrowdSim Would you like me to setup a PR with my changes? It quite likely needs some cleaning up, there were some quirks in there :).
@chraibi Were you able to get yours going?
@russgayle That would be marvelous. I'd love the PR. I anticipate some of what you had to do is something I've been intending to do for a while, so it'll be a good impetus.
Sorry I forgot to send a PR. For me it compiles fine with El-Capitan. Recently I upgraded to Sierra. It compiles fine too.
Addressed by PR #36.
Following the instructions here
I' m trying to compile
Menge
incmake
says something aboutMACOSX_RPATH
.Ignoring this warning (apparently not a good idea) leads to
make
error:Any help is appreciated. ;-)