johnBuffer / NoCol

Trajectories finder

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MacOS compile

J-Siu opened this issue · comments

I am not familiar with make and cmake, so I just find some g++ command line to "brute force" it:

g++ -v --std=c++17 -I../include -I /usr/local/Cellar/sfml/2.5.1_1/include -I /usr/local/Cellar/csfml/2.5/include -L /usr/local/Cellar/sfml/2.5.1_1/lib -L /usr/local/Cellar/csfml/2.5/lib -I /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/OpenGL.framework main.cpp display_manager.cpp -o nocol

It almost work. However the linking failed.

Apple clang version 12.0.0 (clang-1200.0.32.29)
Target: x86_64-apple-darwin20.3.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1"
ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1"
 "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" -cc1 -triple x86_64-apple-macosx11.0.0 -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -Werror=implicit-function-declaration -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name main.cpp -mrelocation-model pic -pic-level 2 -mthread-model posix -mframe-pointer=all -fno-strict-return -masm-verbose -munwind-tables -target-sdk-version=11.1 -target-cpu penryn -dwarf-column-info -debugger-tuning=lldb -target-linker-version 609.8 -v -resource-dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -I ../include -I /usr/local/Cellar/sfml/2.5.1_1/include -I /usr/local/Cellar/csfml/2.5/include -I /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/OpenGL.framework -I/usr/local/include -stdlib=libc++ -internal-isystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1 -internal-isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/local/include -internal-isystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.0/include -internal-externc-isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include -internal-externc-isystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include -Wno-reorder-init-list -Wno-implicit-int-float-conversion -Wno-c99-designator -Wno-final-dtor-non-final-class -Wno-extra-semi-stmt -Wno-misleading-indentation -Wno-quoted-include-in-framework-header -Wno-implicit-fallthrough -Wno-enum-enum-conversion -Wno-enum-float-conversion --std=c++17 -fdeprecated-macro -fdebug-compilation-dir /Users/js/tmp/NoCol/src -ferror-limit 19 -fmessage-length 308 -stack-protector 1 -fstack-check -mdarwin-stkchk-strong-link -fblocks -fencode-extended-block-signature -fregister-global-dtors-with-atexit -fgnuc-version=4.2.1 -fobjc-runtime=macosx-11.0.0 -fcxx-exceptions -fexceptions -fmax-type-align=16 -fdiagnostics-show-option -fcolor-diagnostics -o /var/folders/y1/jr7gnyzs39g878wm3xtf3rr00000gn/T/main-903599.o -x c++ main.cpp
clang -cc1 version 12.0.0 (clang-1200.0.32.29) default target x86_64-apple-darwin20.3.0
ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/local/include"
ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/Library/Frameworks"
#include "..." search starts here:
#include <...> search starts here:
 ../include
 /usr/local/Cellar/sfml/2.5.1_1/include
 /usr/local/Cellar/csfml/2.5/include
 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/OpenGL.framework
 /usr/local/include
 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1
 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.0/include
 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include
 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks (framework directory)
End of search list.
 "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" -cc1 -triple x86_64-apple-macosx11.0.0 -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -Werror=implicit-function-declaration -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name display_manager.cpp -mrelocation-model pic -pic-level 2 -mthread-model posix -mframe-pointer=all -fno-strict-return -masm-verbose -munwind-tables -target-sdk-version=11.1 -target-cpu penryn -dwarf-column-info -debugger-tuning=lldb -target-linker-version 609.8 -v -resource-dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -I ../include -I /usr/local/Cellar/sfml/2.5.1_1/include -I /usr/local/Cellar/csfml/2.5/include -I /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/OpenGL.framework -I/usr/local/include -stdlib=libc++ -internal-isystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1 -internal-isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/local/include -internal-isystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.0/include -internal-externc-isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include -internal-externc-isystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include -Wno-reorder-init-list -Wno-implicit-int-float-conversion -Wno-c99-designator -Wno-final-dtor-non-final-class -Wno-extra-semi-stmt -Wno-misleading-indentation -Wno-quoted-include-in-framework-header -Wno-implicit-fallthrough -Wno-enum-enum-conversion -Wno-enum-float-conversion --std=c++17 -fdeprecated-macro -fdebug-compilation-dir /Users/js/tmp/NoCol/src -ferror-limit 19 -fmessage-length 308 -stack-protector 1 -fstack-check -mdarwin-stkchk-strong-link -fblocks -fencode-extended-block-signature -fregister-global-dtors-with-atexit -fgnuc-version=4.2.1 -fobjc-runtime=macosx-11.0.0 -fcxx-exceptions -fexceptions -fmax-type-align=16 -fdiagnostics-show-option -fcolor-diagnostics -o /var/folders/y1/jr7gnyzs39g878wm3xtf3rr00000gn/T/display_manager-0fa2c7.o -x c++ display_manager.cpp
clang -cc1 version 12.0.0 (clang-1200.0.32.29) default target x86_64-apple-darwin20.3.0
ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/local/include"
ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/Library/Frameworks"
#include "..." search starts here:
#include <...> search starts here:
 ../include
 /usr/local/Cellar/sfml/2.5.1_1/include
 /usr/local/Cellar/csfml/2.5/include
 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/OpenGL.framework
 /usr/local/include
 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1
 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.0/include
 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include
 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks (framework directory)
End of search list.
 "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld" -demangle -lto_library /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/libLTO.dylib -no_deduplicate -dynamic -arch x86_64 -platform_version macos 11.0.0 11.1 -syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -o nocol -L/usr/local/Cellar/sfml/2.5.1_1/lib -L/usr/local/Cellar/csfml/2.5/lib -L/usr/local/lib /var/folders/y1/jr7gnyzs39g878wm3xtf3rr00000gn/T/main-903599.o /var/folders/y1/jr7gnyzs39g878wm3xtf3rr00000gn/T/display_manager-0fa2c7.o -lc++ -lSystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.0/lib/darwin/libclang_rt.osx.a
Undefined symbols for architecture x86_64:
  "sf::CircleShape::setPointCount(unsigned long)", referenced from:
      _main in main-903599.o
  "sf::CircleShape::CircleShape(float, unsigned long)", referenced from:
      _main in main-903599.o
  "sf::VertexArray::VertexArray(sf::PrimitiveType, unsigned long)", referenced from:
      Ball::getVA() const in main-903599.o
      DisplayManager::DisplayManager(sf::RenderTarget&, sf::RenderWindow&) in display_manager-0fa2c7.o
  "sf::VertexArray::operator[](unsigned long)", referenced from:
      Ball::getVA() const in main-903599.o
  "sf::RenderStates::RenderStates()", referenced from:
      DisplayManager::getRenderStates() const in display_manager-0fa2c7.o
  "sf::RenderTarget::draw(sf::Drawable const&, sf::RenderStates const&)", referenced from:
      _main in main-903599.o
  "sf::RenderTarget::clear(sf::Color const&)", referenced from:
      _main in main-903599.o
      main::$_1::operator()(sf::Event const&) const in main-903599.o
  "sf::RenderWindow::RenderWindow(sf::VideoMode, sf::String const&, unsigned int, sf::ContextSettings const&)", referenced from:
      _main in main-903599.o
  "sf::RenderWindow::~RenderWindow()", referenced from:
      _main in main-903599.o
  "sf::RenderTexture::create(unsigned int, unsigned int, sf::ContextSettings const&)", referenced from:
      _main in main-903599.o
  "sf::RenderTexture::display()", referenced from:
      _main in main-903599.o
  "sf::RenderTexture::RenderTexture()", referenced from:
      _main in main-903599.o
  "sf::RenderTexture::~RenderTexture()", referenced from:
      _main in main-903599.o
  "sf::Transformable::setPosition(sf::Vector2<float> const&)", referenced from:
      _main in main-903599.o
  "sf::Transformable::setOrigin(float, float)", referenced from:
      _main in main-903599.o
  "sf::Color::Black", referenced from:
      _main in main-903599.o
  "sf::Color::Color(unsigned char, unsigned char, unsigned char, unsigned char)", referenced from:
      _main in main-903599.o
      Ball::getVA() const in main-903599.o
      main::$_1::operator()(sf::Event const&) const in main-903599.o
  "sf::Mouse::getPosition(sf::Window const&)", referenced from:
      _main in main-903599.o
      DisplayManager::processEvents() in display_manager-0fa2c7.o
  "sf::Shape::setFillColor(sf::Color const&)", referenced from:
      _main in main-903599.o
  "sf::Shape::~Shape()", referenced from:
      sf::CircleShape::~CircleShape() in main-903599.o
  "sf::String::String(char const*, std::__1::locale const&)", referenced from:
      _main in main-903599.o
  "sf::Window::setVerticalSyncEnabled(bool)", referenced from:
      _main in main-903599.o
      main::$_4::operator()(sf::Event const&) const in main-903599.o
  "sf::Window::close()", referenced from:
      main::$_3::operator()(sf::Event const&) const in main-903599.o
      DisplayManager::DisplayManager(sf::RenderTarget&, sf::RenderWindow&)::$_0::operator()(sf::Event const&) const in display_manager-0fa2c7.o
  "sf::Window::display()", referenced from:
      _main in main-903599.o
  "sf::Window::pollEvent(sf::Event&)", referenced from:
      sfev::EventManager::processEvents() const in display_manager-0fa2c7.o
  "sf::Texture::Texture()", referenced from:
      DisplayManager::DisplayManager(sf::RenderTarget&, sf::RenderWindow&) in display_manager-0fa2c7.o
  "sf::Texture::~Texture()", referenced from:
      DisplayManager::~DisplayManager() in main-903599.o
      DisplayManager::DisplayManager(sf::RenderTarget&, sf::RenderWindow&) in display_manager-0fa2c7.o
  "sf::BlendAdd", referenced from:
      _main in main-903599.o
  "sf::Transform::scale(float, float)", referenced from:
      DisplayManager::getRenderStates() const in display_manager-0fa2c7.o
  "sf::Transform::translate(float, float)", referenced from:
      DisplayManager::getRenderStates() const in display_manager-0fa2c7.o
  "sf::VideoMode::VideoMode(unsigned int, unsigned int, unsigned int)", referenced from:
      _main in main-903599.o
  "sf::Window::isOpen() const", referenced from:
      _main in main-903599.o
  "vtable for sf::VertexArray", referenced from:
      sf::VertexArray::~VertexArray() in main-903599.o
      sf::VertexArray::~VertexArray() in display_manager-0fa2c7.o
  NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Any clue how it can be fixed?

Fixed. I am able to compile on my Mac with following commands:

g++ -v --std=c++2a -I../include -I /usr/local/Cellar/sfml/2.5.1_1/include -L /usr/local/Cellar/sfml/2.5.1_1/lib -I /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/OpenGL.framework -c main.cpp display_manager.cpp
g++ -v --std=c++2a -I../include -I /usr/local/Cellar/sfml/2.5.1_1/include -L /usr/local/Cellar/sfml/2.5.1_1/lib -I /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/OpenGL.framework -o sfml-app -lsfml-graphics -lsfml-window -lsfml-system main.cpp display_manager.cpp

PS: the balls are actually colliding/bumping each other🤣

commented

@J-Siu Do the balls actually collide? Is it because the ok_count < 199 that makes it looks like the balls never collide?

This is just to avoid balls to turn red when the collision is negligible because of floating points inaccuracy

@J-Siu Do the balls actually collide? Is it because the ok_count < 199 that makes it looks like the balls never collide?

The balls did collide at the beginning, but after running for awhile (a few minutes?), they will reach a balance and no longer collide.

commented

@johnBuffer It will for sure collide at the beginning. For an extreme example: two balls are initialized at symmetrical positions relative to the center point. But I am curious if it will reach a balance after some collides. Will response later. Great work!