Udacity's Open Street Map Project in C++ Nanodegree
macos 10.15.5 Beta (19F53f) using COREGRAPHICS_MAC to compile IO2D
- Create a folder that you are going to use for the project. Then, in Terminal (or iTerm), change directory to that folder and clone the project files:
git clone https://github.com/udacity/CppND-Route-Planning-Project.git --recurse-submodules
cd
tothirdparty
folder, then clone the IO2D files:git clone --recurse-submodules https://github.com/cpp-io2d/P0267_RefImpl
- Follow IO2D instructions: https://github.com/cpp-io2d/P0267_RefImpl/blob/master/BUILDING.md - which are
- Download the extra C++ standard library headers from https://releases.llvm.org/6.0.0/clang+llvm-6.0.0-x86_64-apple-darwin.tar.xz and add the flags below so that these libraries can be found by IO2D:
- REASON: "Xcode currently comes with an old version of libc++ which lacks many of C++17 features required by IO2D. The easiest solution is to download a fresh build of libc++ from here. Export appropriate CXX and LD flags to make clang use this version of the standard library (replace NEWPATH with a path of extracted archive contents [in both of the following statements - i.e. 3 places])":
For example, if the path to that expanded folder of library headers is
export CXXFLAGS="-nostdinc++ -isystemNEWPATH/include/c++/v1" export LDFLAGS="-LNEWPATH/lib -Wl,-rpath,NEWPATH/lib"
/Users/myles/Work/Cpp/clang+llvm-6.0.0-x86_64-apple-darwin
then those statements become:export CXXFLAGS="-nostdinc++ -isystem/Users/myles/Work/Cpp/clang+llvm-6.0.0-x86_64-apple-darwin/include/c++/v1" export LDFLAGS="-L/Users/myles/Work/Cpp/clang+llvm-6.0.0-x86_64-apple-darwin/lib -Wl,-rpath,/Users/myles/Work/Cpp/clang+llvm-6.0.0-x86_64-apple-darwin/lib"
- Install libpng:
brew install libpng
- Install cmake:
brew install cmake
- Edit the
CMakeLists.txt
file (".../P0267_RefImpl/CMakeLists.txt"), commenting out the section relating to samples# COMMENT OUT: Relating to Samples #if( NOT DEFINED IO2D_WITHOUT_SAMPLES ) # add_subdirectory(P0267_RefImpl/Samples) #endif()
- From: udacity/CppND-Route-Planning-Project#1 "A small trick is to edit the CMakeLists.txt under P0267_RefImpl and comment out the part with samples. Then, using CoreGraphics/Mac on macOS run "ALL_Build" and "install" in XCode."
cd
toP0267_RefImpl
(inthirdparty
) - in Terminal:mkdir Debug && cd Debug cmake -G "Xcode" --config Debug "-DCMAKE_BUILD_TYPE=Debug" -DIO2D_DEFAULT=COREGRAPHICS_MAC ../. open io2d.xcodeproj
- In XCode:
- IO2D is now ready to be used.
cd
to the root of the project filesmkdir build && cd build cmake .. make
- Complete
- To get the project up and running in XCode, I created a new build folder in the root directory of the project (which I called
buildX
)mkdir buildX && cd buildX cmake -G Xcode ..
- Then, in XCode, I opened the
.xcodeproj
that was generated (OSM_A_star_search.xcodeproj
):open OSM_A_star_search.xcodeproj
- Note: You will have to change the paths to your map XML file(s) to make this build (in both
main.cpp
andutest_rp_a_star_search.cpp
(the test file):
If you build this project locally, you may find that the test fails. Try your code in the workspace. For some reason, in some cases, running the test locally fails but passes in the workspace (I posted a Knowledge
question about this but didn't get an explanation for why this happens. I will dig deeper, if I find a reason then I will update this to explain why).
For example, my code works in the workspace, but locally: