slembcke/Chipmunk2D

Unable to run hello world program after building from cmake

Closed this issue · 2 comments

Hi. I built the library from the CMake script that is present in the main directory. I then went on to copy the hello world script from the C tutorial on this page. I got the following error...

Ld /Users/kartikeygupta/Workspace/C++/Chipmunk/ChipmunkTest/ChipmunkTest/build/Debug/ChipmunkTest normal x86_64 (in target: ChipmunkTest)
    cd /Users/kartikeygupta/Workspace/C++/Chipmunk/ChipmunkTest/ChipmunkTest
    export MACOSX_DEPLOYMENT_TARGET=10.14
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -L/Users/kartikeygupta/Workspace/C++/Chipmunk/ChipmunkTest/ChipmunkTest/build/Debug -L/Users/kartikeygupta/Workspace/C++/Chipmunk/ChipmunkTest/lib -F/Users/kartikeygupta/Workspace/C++/Chipmunk/ChipmunkTest/ChipmunkTest/build/Debug -filelist /Users/kartikeygupta/Workspace/C++/Chipmunk/ChipmunkTest/ChipmunkTest/build/ChipmunkTest.build/Debug/ChipmunkTest.build/Objects-normal/x86_64/ChipmunkTest.LinkFileList -mmacosx-version-min=10.14 -Xlinker -object_path_lto -Xlinker /Users/kartikeygupta/Workspace/C++/Chipmunk/ChipmunkTest/ChipmunkTest/build/ChipmunkTest.build/Debug/ChipmunkTest.build/Objects-normal/x86_64/ChipmunkTest_lto.o -Xlinker -export_dynamic -Xlinker -no_deduplicate -lchipmunk -Xlinker -dependency_info -Xlinker /Users/kartikeygupta/Workspace/C++/Chipmunk/ChipmunkTest/ChipmunkTest/build/ChipmunkTest.build/Debug/ChipmunkTest.build/Objects-normal/x86_64/ChipmunkTest_dependency_info.dat -o /Users/kartikeygupta/Workspace/C++/Chipmunk/ChipmunkTest/ChipmunkTest/build/Debug/ChipmunkTest

Undefined symbols for architecture x86_64:
  "_cpBodySetPos", referenced from:
      _main in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

What am I doing wrong here?

Sorry, I've been sick for the last few days.

Hmm. So -lchipmunk is in there and there isn't an error about the library not being found. If you run nm on chipmunk.dylib is cpBodySetPos listed? Also, if you run lipo -i on it, does it providing x86_64 symbols?

Err, nevermind. I had my Mac handy, so I just tried it.

cpBodySetPos() is the old abbreviated name. At some point years ago I went through the API and got rid of most of the abbreviations. I think even the compatibility macros were removed a few years ago. Apparently I never updated that example. Derp. :(

Use cpBodySetPosition() instead.