Build a C++ example using XCode

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Dario Cazzola
Posts: 44
Joined: Mon Jun 03, 2013 8:08 am

Build a C++ example using XCode

Post by Dario Cazzola » Tue Feb 18, 2020 9:56 am

Hi there,

I am trying to build, compile, and run the first OpenSIm example. I am following this instructions: https://simtk-confluence.stanford.edu/p ... d=29165309

However when I try to build it using cmake (version 3.17.0), and compile using Xcode (version 11.3.1) I get the following error:
Screenshot 2020-02-18 at 16.51.20.png
Screenshot 2020-02-18 at 16.51.20.png (156.68 KiB) Viewed 1534 times
If I try to specify the compiler I get this error:
Screenshot 2020-02-18 at 16.52.09.png
Screenshot 2020-02-18 at 16.52.09.png (204.58 KiB) Viewed 1534 times
If I try t compile using Unix MakeFiles, I get this warning:
Screenshot 2020-02-18 at 16.43.20.png
Screenshot 2020-02-18 at 16.43.20.png (200.62 KiB) Viewed 1534 times
Not sure what I doing wrong, but I am certainly forgetting to do something!

Many thanks for your help.

Cheers

Dario

Tags:

User avatar
Christopher Dembia
Posts: 506
Joined: Fri Oct 12, 2012 4:09 pm

Re: Build a C++ example using XCode

Post by Christopher Dembia » Tue Feb 18, 2020 10:17 am

Dario, maybe you could proceed with Unix Makefiles, because that generated only a warning, which you can hopefully ignore.

User avatar
Dario Cazzola
Posts: 44
Joined: Mon Jun 03, 2013 8:08 am

Re: Build a C++ example using XCode

Post by Dario Cazzola » Wed Feb 19, 2020 4:08 pm

Hi Chris,

I managed to resolve the compiler error when using Xcode by typing this:

Code: Select all

sudo xcode-select --reset
Apparently it is something you need to do after using homebrew.

However I now face another error in Xcode:

Code: Select all

clang: error: no such file or directory: '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Accelerate.framework' 
This is because ...SDKs/MacOSX10.14.sdk/... should be ...SDKs/MacOSX10.15.sdk/...
Not sure how to change this though.

Hope it helps.
Cheers
Dario

User avatar
Ayman Habib
Posts: 2252
Joined: Fri Apr 01, 2005 12:24 pm

Re: Build a C++ example using XCode

Post by Ayman Habib » Thu Feb 20, 2020 1:56 pm

Hi Dario,

Check the CMake variable CMake_OSX_SYSROOT

and let us know,
-Ayman

User avatar
Dario Cazzola
Posts: 44
Joined: Mon Jun 03, 2013 8:08 am

Re: Build a C++ example using XCode

Post by Dario Cazzola » Tue Feb 25, 2020 3:13 pm

Hi Ayman,

Thanks for this. I did check that variable and it refers to the right path.

However I have noticed that the file XCODE_DEPEND_HELPER.make still includes the old path (i.e. MACOS_10.14.sdk).

Code: Select all

# DO NOT EDIT
# This makefile makes sure all linkable targets are
# up-to-date with anything they link to
default:
	echo "Do not invoke directly"

# Rules to remove targets that are older than anything to which they
# link.  This forces Xcode to relink the targets from scratch.  It
# does not seem to check these dependencies itself.
PostBuild.exampleMain.Debug:
/Users/dc547/Documents/OpenSim/4.0/Code/CPP/ExampleMain/build/Debug/exampleMain:\
	/Applications/OpenSim\ 4.0/sdk/lib/libosimTools.dylib\
	/Applications/OpenSim\ 4.0/sdk/lib/libosimAnalyses.dylib\
	/Applications/OpenSim\ 4.0/sdk/lib/libosimActuators.dylib\
	/Applications/OpenSim\ 4.0/sdk/lib/libosimSimulation.dylib\
	/Applications/OpenSim\ 4.0/sdk/lib/libosimCommon.dylib\
	/Applications/OpenSim\ 4.0/sdk/Simbody/lib/libSimTKsimbody.3.6.dylib\
	/Applications/OpenSim\ 4.0/sdk/Simbody/lib/libSimTKmath.3.6.dylib\
	/Applications/OpenSim\ 4.0/sdk/Simbody/lib/libSimTKcommon.3.6.dylib\
	/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Accelerate.framework\
	/Applications/OpenSim\ 4.0/sdk/lib/libosimLepton.dylib
	/bin/rm -f /Users/dc547/Documents/OpenSim/4.0/Code/CPP/ExampleMain/build/Debug/exampleMain
Thanks for your help.

Dario

User avatar
Ayman Habib
Posts: 2252
Joined: Fri Apr 01, 2005 12:24 pm

Re: Build a C++ example using XCode

Post by Ayman Habib » Tue Feb 25, 2020 4:39 pm

Hi Dario,

You may need to delete the cache and rerun CMake to get a fresh XCODE_DEPEND_HELPER.cmake though I found online help that suggested this file is not used anymore (since XCode 5). Not sure since we typically do not use XCode to build on OSX.

Please let me know how it goes,
-Ayman

User avatar
Hendrik Reimann
Posts: 5
Joined: Tue Apr 07, 2015 1:54 pm

Re: Build a C++ example using XCode

Post by Hendrik Reimann » Fri Jul 31, 2020 10:53 am

I had the same issue and spent a very frustrating weekend trying to solve it, so putting this here for others.

My problem was that I had an older standard install of OpenSim in the usual place (Applications/OpenSim...), which I had installed a while ago, and I had updated the OS in the meantime. When generating the XCode project, CMake used this pre-installed version of OpenSim, rather than the newer version I had built from source code more recently, and the linker complained with the above error. Pointing CMake to the right locations fixed it:
Screen Shot 2020-07-31 at 7.44.09 PM copy.jpg
Screen Shot 2020-07-31 at 7.44.09 PM copy.jpg (206.27 KiB) Viewed 1415 times

POST REPLY