How to build OpenCASCADE on MAC (Mountain Lion) - macos

I am trying to build OpenCASCADE on Mac, but I am not having any luck.
I downloaded it from Github in tar.gz, but I am really new to Mac and I am stuck.
Can anybody explain what should be my next step?
(I found some terminal commands what I should use, but I am not familiar with them. So if it is the right way to build OpenCASCADE on Mac please write down the terminal commands with details. Thank you!)
EDIT:
I understood the command line commands now from the link below. I understood it before too, but I was mistaken, because my main problem was, that I didn't had gcc installed (XCode does not installs gcc automatically...). So anyways, now finally I can run the cmake command. It starts but it ends with this:
CMake Error at /Applications/CMake
2.8-9.app/Contents/share/cmake-2.8/Modules/FindX11.cmake:420 (MESSAGE): Could not find X11 Call Stack (most recent call first):
CMakeLists.txt:313 (FIND_PACKAGE)
Anybody have any idea what to do? I tryed to search this too here, and google...and I found some "solutions" but those didn't work for me.
EDIT EDIT:
The solution for the last edit is that Mountain Lion doesn't install X11. So open up an app that uses X11 or Xquartz and it will install automatically.
Unfortunetly it still doesn't work. My next error message is the following after the make command in terminal:
In file included from
/Users/davidbirkas/Documents/tpaviot-oce-6c9a06a/src/AlienImage/AlienImage_X11XWDAlienData.cxx:14:
/Users/davidbirkas/Documents/tpaviot-oce-6c9a06a/inc/Aspect_XWD.hxx:5:12:
fatal error:
'X11/XWDFile.h' file not found
# include
^ 1 error generated. make[2]: * [adm/cmake/TKService/CMakeFiles/TKService.dir/_/_/__/src/AlienImage/AlienImage_X11XWDAlienData.cxx.o]
Error 1 make1:
[adm/cmake/TKService/CMakeFiles/TKService.dir/all] Error 2 make: **
[all] Error 2
Any ideas how to fix this?

Ensure that, together with XCode, you also install the X11 support from Apple's Devtools. Your error message is indicating that it is missing.
FWIW, I have written a blog post about OCC and PythonOCC on Mac some time ago. Maybe you'll find some detailed info there.
http://cad-3d.blogspot.com/2011/10/pythonocc-open-source-interactive-cad.html
In this post, I still talk about using the binary installer, but recent updates to the OCE edition compile usually without problems out-of-the-box, also on OSX (that is NOT the case with the official OpenCASCADE release).

I spent a little time on this and I think I have it. Here is what I did step by step:
Preparation phase:
Installing Xcode (with command line tools) = Apple developer site
// If Xcode doesn't install gcc, than you can still download it from the developer site as Command Line Tools for Xcode.
Installing Cmake (with command line tools) = Google
// You can download it from the official site with a .dmg/.pkg file extension. Easy install.
X11 under Mountain Lion "changed" to Xquartz. Probably it is not installed by default, but it is easy to check it. Just go to the folder "Application" and start the X11 app. If X11/Xquartz is not installed than it will install automatically!
Installing FTGL = MacPorts = Google
// Download MacPorts from their official site, install it with the installer, than write this to the terminal:
sudo port install ftgl
Download OCE and extract it (.OCE-0.9.0.tar.gz file) = https://github.com/tpaviot/oce/wiki/Download
Installing phase:
I. Open Terminal.
II. Run this command
// This will set the proper PATH.
ln -s /opt/X11/include/X11 /usr/local/include/X11
III. Than from the Terminal go to the directory where you extracted the OCE file (the original extracted file name should be: tpaviot-oce-6c9a06a).
IV. Than write these commands:
// You make a build directory to the extracted OCE folder.
mkdir build
cd build
V. After this you give out the cmake command:
cmake -DOCE_INSTALL_PREFIX:PATH=$HOME/OCE \
-DOCE_WITH_FREEIMAGE:BOOL=ON \
-DOCE_WITH_GL2PS:BOOL=ON \
-DOCE_DRAW:BOOL=ON \
..
VI. And at the end the make commands:
make
make install/strip
If you did everything exactly like this, than it should work!

Give OCE a try. Compiling for osx is a walk in the park

Related

Issue with linker for Mac OS

I have recently started using ada for a lab in my systems programming class and I can say it is really interesting.
I tried most of it at the computers labs for testing and I decided to install the compiler and its linking tools in a MacBook.
Altough the installation is done and there seems to be no problem, when I tried to print the classic hello world program I am getting this message:
gprbuild greet.adb
using project file /Users/xyderos/opt/GNAT/2020/share/gpr/_default.gpr
Bind
[gprbind] greet.bexch
[Ada] greet.ali
Link
[link] greet.adb
ld: library not found for -lSystem
collect2: error: ld returned 1 exit status
gprbuild: link of greet.adb failed
gprbuild: failed command was: /users/name/opt/gnat/2020/bin/gcc greet.o b__greet.o - L/Users/name/ada/ -L/Users/name/ada// -L/users/name/opt/gnat/2020/lib/gcc/x86_64-apple-darwin17.7.0/8.4.1/adalib/ /users/name/opt/gnat/2020/lib/gcc/x86_64-apple-darwin17.7.0/8.4.1/adalib/libgnat.a -Wl,-rpath,#executable_path/ -Wl,-rpath,#executable_path/..//opt/gnat/2020/lib/gcc/x86_64-apple-darwin17.7.0/8.4.1/adalib -o greet
I am getting really confused about the lSystem library.
It seems that the library doesn't exist on Mac(maybe I need to install Xcode?).
Does anyone have a clue about that issue or is there a probably better way to install it via brew?
Thanks a lot in advance!
On my MacOS 10.14, the following worked for me, without having to download the massive blob that is Xcode, which I had neither the bandwidth nor the diskspace for. I don't know if this still works on MacOS 10.15 (not planning to upgrade).
Most of this info was from a blog post by Simon Wright: https://forward-in-code.blogspot.com/2019/06/macos-software-development-kit-changes.html
You only need the Xcode command line tools only (not Xcode): xcode-select --install
Now unpack the included headers: sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /
And tell GNAT where to find them: mv ce2109-specs /usr/local/opt/GNAT/2019/lib/gcc/x86_64-apple-darwin17.7.0/8.3.1/specs
The ce2109-specs file is from the blog post above. This did the job for me and GNAT can now link working binaries on MacOS 10.14.
If you're on 10.15 and it doesn't work (because there's no more Xcode command line tools or they're missing the headers package), you will unfortunately have to install Xcode as per the GNAT Readme.

Fortran codes won't compile on Mac with gfortran

I recently moved from the SGI, Sun workstation environment to a Mac. SGI and Sun came with Fortran compilers so I have maybe 100 small f77 codes I wrote over the years for post-processing and analysis of simulated data. I was hoping to get these codes running on my iMac with gfortran. Most of these are very simple codes but I can't get them to compile and execute. I tried starting with the basics and wrote the Hello World code from a gfortran help page. My code, fortran.f is:
program helloworld
print *, "hello world"
end program helloworld
When I tried compiling this according to the example I typed:
gfortran fortran.f
But I keep getting the error message:
FATAL:/opt/local/bin/../libexec/as/x86_64/as: I don't understand 'm' flag!
This is the same error message I get on my other codes. Can someone tell me what I'm doing wrong? I can't think of a simpler example but I can't seem to get it to work.
When it comes to macOS, I think that building form sources is the best approach you can have. You can achieve that quite easily by downloading and compiling GFortran as part of GCC directly from: https://gcc.gnu.org/wiki/GFortran
However, there are few things you have to take care of:
make sure you have XCode installed, you can get it here
XCode
XCode is free of charge
Make sure you have command line tools
You can get them either from developer.apple.com
Command Line Tools
or directly from XCode. It might be that XCode will tell you to install Command Line Tools upon first execution
In the past, running command like "svn", when Command Line Tools were not installed, also triggered the installation.
Compile GCC
> ./configure --prefix=$HOME/opt/usr/local
> make all
> make install
Alternatively, you can install using macOS package from GFortran
gfortran-6.3-Sierra.dmg
Fully working sample with Fortran based MPI code:
http://www.owsiak.org/running-open-mpi-on-macos/
If your gfortran was installed a long time ago and you have updated macOS since installing, it may need re-installing to get correctly aligned and linked with the latest macOS tools and libraries.
My advice would be to:
uninstall gfortran,
check that Xcode and its command line tools are up-to-date,
re-install gfortran.
Hints for each of those steps follow:
Note that gfortran is a part of GCC - the "GNU Compiler Collection".
If you installed gfortran via homebrew, you can remove it with:
brew rm gcc
You can update Xcode by by going to AppStore and clicking Updates at top-right.
The Xcode Command Line tools include make and git and command-line versions of the compilers. You can install/update the Xcode command line tools with:
xcode-select --install
You can install gfortran with homebrew using:
brew install gcc
When you are finished, you should make sure that your PATH includes /usr/local/bin near the start and that there are no errors when you run:
brew doctor
which is a brilliant utility that checks your homebrew configuration is correct.
All I had to do was change the path.
Initially, my PATH was something like
/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/opt/X11/bin
Because of this reason, the default assembler (as) was not called which is in the /usr/bin directory.
To enable the call to the right assembler (as), I had to add /usr/bin to the PATH in front of (before) /opt/local/bin, i.e. on a Mac this can be added by editing ~/.bash_profile such that one's $PATH looks like
/usr/bin:/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/opt/X11/bin
Once edited, execute at your command prompt:
source /etc/bash_profile
This worked for me.

How do I create projects on Xcode 7 using wxWidgets?

My specifications are up to date (OS X El Capitan, 10.11). Here are details on what I've tried so far.
I've followed the (Terminal) installation steps included in the wxWidgets download:
mkdir build-cocoa-debug
cd build-cocoa-debug
../configure --enable-debug
make
cd samples; make;cd ..
cd demos; make;cd ..
Then, I followed the wxWidgets wiki guide for creating Xcode projects.
Of course, there were plenty of compilation errors. After taking care of an incorrectly typed include, there were still issues. For the most part, they were undeclared identifiers and incomplete types, but my attention went to one in particular:
"No Target! You should use wx-config program for compilation flags!"
After researching, I believe I need to use wx-config to find what flags to input into the "Other Linker Flags" option in Xcode. However, I can't seem to utilize wx-config in Terminal.
I'm not sure if I'm dealing with the core issue. If I am, how do I use wx-config? And if I'm not, please steer me in the right direction.
Thank you.
*** EDIT: ***
I've used wx-config to find which flags I needed to input into "Other Linker Flags" and "Preprocessor Macros" in Xcode. This significantly reduced the amount of errors and warnings that I was facing.
Unfortunately, these new errors are esoteric to me:
Error/Warning Log
How do I remove these errors so I can run this project?
I'm finally able to compile and run wxWidgets programs using Xcode 7. I've found and followed this awesome guide (of which step 3 seems to now be irrelevant).
In case the link breaks, here is a summary of the steps that helped me:
* * * * * *
Open Terminal and install Homebrew by inputting:
ruby -e "$(curl -fsSkL raw.github.com/mxcl/homebrew/go)"
Then, input:
brew install wxmac
Open Xcode and create a Command Line Tool C++ project.
Back in Terminal, input:
wx-config --libs
Once inputted, copy everything outputted by the Terminal and place it into Other Linker Flags (found in Build Settings of your Xcode project).
At Terminal, input:
wx-config -–cxxflags
Again, copy everything outputted except this time place it into Other C++ Flags (do not erase what is currently in that section).
Then, of course don't forget to include wx/wx.h and don't forget to have at least an empty main function if you want it to run.
* * * * * *
I'm not at a place where I can create Cocoa projects/products, but that's totally fine. I simply wanted a canvas to familiarize myself with the wxWidgets library.
I hope this post will be helpful to others.
Arman,
First couple of questions:
What OS are you trying to compile?
What is your requirements for the minimal OSX version?
I presume you are trying to compile the latest Git HEAD. Please correct me if its not the case.
Now, couple of recommendations:
Try to run "../configure --help" and see at all the different options you can set.
Try to run "../configure --enable-debug --with-mac-osx-version-min=10.x --with-cocoa". This command has to be run after removing the build directory completely and pretending you are starting over.
Try to open the "minimal.xcode" project in the samples/minimnal directory, add the minimal.cpp file to it and compile. If it compiles and runs fine, then you made a mistake setting up the project of your own.
Let us know how it goes.

Issues with installing OpenCV on MAC Yosemite 10.10.2

I am trying to install OpenCV on my Macbook and I tried following this link:
http://www.learnopencv.com/install-opencv-3-on-yosemite-osx-10-10-x/
However when I try to run a sample code: I get the following error:
g++ -ggdb pkg-config --cflags --libs opencv
ld: library not found for -lcrt1.10.5.o
I looked up a few things online and I arrived at the conclusion that there was a problem with my xcode.
https://software.intel.com/en-us/articles/installing-intel-compilers-for-os-x-pre-requisite-xcode-command-line-tools
However, When I tried to install the required software I got an error saying >>source /opt/intel/bin/iccvars.sh intel64
-bash: /opt/intel/bin/iccvars.sh: No such file or directory
I would really appreciate any recommendations.
I have OpenCV in my mac with yosemite and compiles on xcode command line tools.
I followed the following step
Download the latest version of OpenCV binaries from the repository.
Please install MacPort (from here) on which the OpenCV will be installed.
Install CMAKE on your mac.
cd to your OpenCV folder and create a new directory (eg. on terminal mkdir build) and cd build, that is move to build folder. (I recommend you to use terminal)
On terminal type cmake .. (with is dots)
Next, type: make -j8
type: make install
Now OpenCV is installed in your system.
Next open Xcode with Command line tool installed.
Create a new C++ project
On your Left side plane, where the list of folder content is shown (I dont know the name) but where you will see the file main.cpp. Here right click and create a new group and name it OpenCV Frameworks. Next Right Click on this Group and select Add files and a new dialogue box will appear. Please navigate to your installation file and add all the opencv libraries to this group. you will find it either on /usr/local/lib/ or /opt/local/lib . The libaries has name like libopencvxxx.dylib.. (I Kind of forgot but something with that name)
Next go and add your header and lib path to the compiler.
Thats it.
Please try and if you still cant compile than I will add photo shoots of each step.

Unable to build mercurial on OSX - Python.h not found

For what I've read I need Python-Dev, how do I install it on OSX?
I think the problem I have, is, my Xcode was not properly installed, and I don't have the paths where I should.
This previous question:
Where is gcc on OSX? I have installed Xcode already
Was about I couldn't find gcc, now I can't find Python.h
Should I just link my /Developer directory to somewhere else in /usr/ ???
This is my output:
$ sudo easy_install mercurial
Password:
Searching for mercurial
Reading http://pypi.python.org/simple/mercurial/
Reading http://www.selenic.com/mercurial
Best match: mercurial 1.5.1
Downloading http://mercurial.selenic.com/release/mercurial-1.5.1.tar.gz
Processing mercurial-1.5.1.tar.gz
Running mercurial-1.5.1/setup.py -q bdist_egg --dist-dir /tmp/easy_install-_7RaTq/mercurial-1.5.1/egg-dist-tmp-l7JP3u
mercurial/base85.c:12:20: error: Python.h: No such file or directory
...
Thanks in advance.
I was struggling with this problem all day today.
I eventually discovered a site that claimed that all one needed to do was to reinstall Xcode, or install the latest version (4.3.2, as of this writing).
So I tried that. It did not help; not on its own. But then I went a step further: I fired up Xcode.app, and once I had done that, I opened the Xcode..Preferences menu item, and then go to the Downloads tab, and say that you want to install the "Command Line Tools"
Once I did that, and then re-ran easy_install (in my case I was trying to "easy_install dulwich" to satisfy a hg-git dependency), it was able to properly find Python.h for me.
Might depend on what version of Mac OSX you have, I have it in these spots:
/Developer/SDKs/MacOSX10.5.sdk/System/Library/Frameworks/Python.framework/Versions/2.5/include/python2.5/Python.h
/System/Library/Frameworks/Python.framework/Versions/2.5/include/python2.5/Python.h
Also I believe the version of python that comes with Xcode is a custom build that plays well with xcode but you have to jump through some hoops if you use another dev environment.
Are you sure you want to build Mercurial from source? There are binary packages available, including the nice MacHg which comes with a bundled Mercurial.

Resources