Hello,
I have installed OpenSim on my Mac by using the source code and following the steps outlined in the documentation. However, I have run into an issue with my C++ program: it is unable to find the locations of the include header files. All other users here are on Windows and have been able to run the program with no problems. How do I set the environment variables in Mac? Which file should I use for this? Can someone please guide me? I am the lone Mac user here, so your help is greatly appreciated!
Thank you.
Set Environmental Variables on Mac OpenSim for Header Files
- Akhil Bheemreddy
- Posts: 14
- Joined: Wed Jul 26, 2017 9:41 am
- Christopher Dembia
- Posts: 506
- Joined: Fri Oct 12, 2012 4:09 pm
Re: Set Environmental Variables on Mac OpenSim for Header Files
Don't worry, you're not the only Mac user. OpenSim has good support for Mac.
If you are getting a compile-time error that OpenSim's headers can't be found, this is not fixed by setting environment variables. You must properly tell CMake where to find and how to use OpenSim. Make sure to use the example files in the repository (e.g., https://github.com/opensim-org/opensim- ... eLists.txt).
Withouth your specific files or error messages, we can't provide any more help. What is your C++ program?
I think you can set environment variables on Mac by editing the file `~/.profile`. The environment variables are only set when using a Terminal, though.
If you are getting a compile-time error that OpenSim's headers can't be found, this is not fixed by setting environment variables. You must properly tell CMake where to find and how to use OpenSim. Make sure to use the example files in the repository (e.g., https://github.com/opensim-org/opensim- ... eLists.txt).
Withouth your specific files or error messages, we can't provide any more help. What is your C++ program?
I think you can set environment variables on Mac by editing the file `~/.profile`. The environment variables are only set when using a Terminal, though.
- Akhil Bheemreddy
- Posts: 14
- Joined: Wed Jul 26, 2017 9:41 am
Re: Set Environmental Variables on Mac OpenSim for Header Files
Thank you for the help!
I am still trying to figure out the problem, but I believe that you may be right that it is an issue with CMakeLists.txt. I believe that one of the stored directories ($ENV{OPENSIM_HOME}) is incorrect. How can I access what these directories are and possibly change them? I have tried to set the directories within the CMakeLists.txt file, but I am having some trouble knowing whether or not it is actually changed.
Thanks again!
I am still trying to figure out the problem, but I believe that you may be right that it is an issue with CMakeLists.txt. I believe that one of the stored directories ($ENV{OPENSIM_HOME}) is incorrect. How can I access what these directories are and possibly change them? I have tried to set the directories within the CMakeLists.txt file, but I am having some trouble knowing whether or not it is actually changed.
Thanks again!
- Christopher Dembia
- Posts: 506
- Joined: Fri Oct 12, 2012 4:09 pm
Re: Set Environmental Variables on Mac OpenSim for Header Files
Please see the documentation for CMake here that describes how find_package() works: https://cmake.org/cmake/help/v3.10/comm ... nd_package
The $ENV{OPENSIM_HOME} is just an option, it's basically ignored if you haven't defined that environment variable.
You can either use `ccmake` in the terminal (run `ccmake .` in your build directory), use the CMake GUI, or use `cmake . -DOPENSIM_INSTALL_DIR=...` in the terminal.
The $ENV{OPENSIM_HOME} is just an option, it's basically ignored if you haven't defined that environment variable.
You can either use `ccmake` in the terminal (run `ccmake .` in your build directory), use the CMake GUI, or use `cmake . -DOPENSIM_INSTALL_DIR=...` in the terminal.
- Akhil Bheemreddy
- Posts: 14
- Joined: Wed Jul 26, 2017 9:41 am
Re: Set Environmental Variables on Mac OpenSim for Header Files
Hello again,
I have managed to set the directories for the headers so that they can be found in cmakelists.txt, but now I am having an issue of finding the libraries. I have set the correct directory for the libraries in cmakelists.txt, but the program I am running is unable to find the libraries. Here is the error:
ld: library not found for -libosimCommon
clang: error: linker command failed with exit code 1 (use -v to see invocation)
This suggests to me that the linker cannot find the library that I have asked it to link within cmakelists.txt. I have noticed that the library not found id "-libosimCommon" while within the listed directory that library is called libosimCommon.dylib. Is the problem here that my linker is not looking for the correct file type and prefix? Here is a portion of my cmakelists.txt file
ADD_EXECUTABLE(${TARGET} ${SOURCE})
TARGET_LINK_LIBRARIES(${TARGET}
debug osimCommon_d optimized osimCommon
${PLATFORM_LIBS}
)
How can I go about getting the linker to see the libraries?
Thank you
I have managed to set the directories for the headers so that they can be found in cmakelists.txt, but now I am having an issue of finding the libraries. I have set the correct directory for the libraries in cmakelists.txt, but the program I am running is unable to find the libraries. Here is the error:
ld: library not found for -libosimCommon
clang: error: linker command failed with exit code 1 (use -v to see invocation)
This suggests to me that the linker cannot find the library that I have asked it to link within cmakelists.txt. I have noticed that the library not found id "-libosimCommon" while within the listed directory that library is called libosimCommon.dylib. Is the problem here that my linker is not looking for the correct file type and prefix? Here is a portion of my cmakelists.txt file
ADD_EXECUTABLE(${TARGET} ${SOURCE})
TARGET_LINK_LIBRARIES(${TARGET}
debug osimCommon_d optimized osimCommon
${PLATFORM_LIBS}
)
How can I go about getting the linker to see the libraries?
Thank you
- Christopher Dembia
- Posts: 506
- Joined: Fri Oct 12, 2012 4:09 pm
Re: Set Environmental Variables on Mac OpenSim for Header Files
Are you using 3.3 or "4.0"?
If using 3.3, you can use the CMake `link_directories()` command. Alternatively, you could read the instructions in the `FindOpenSim.cmake` file that comes with the source code (perhaps in your install directory).
If using "4.0," see the SampleCMakeLists.txt in the opensim-core installation (somewhere in `lib`).
If using 3.3, you can use the CMake `link_directories()` command. Alternatively, you could read the instructions in the `FindOpenSim.cmake` file that comes with the source code (perhaps in your install directory).
If using "4.0," see the SampleCMakeLists.txt in the opensim-core installation (somewhere in `lib`).