nrc-cnrc / EGSnrc

Toolkit for Monte Carlo simulation of ionizing radiation β€” Trousse d'outils logiciels pour la simulation Monte Carlo du rayonnement ionisant
http://nrc-cnrc.github.io/EGSnrc
GNU Affero General Public License v3.0
216 stars 146 forks source link

macOS (Monterey, 12.4) EGSnrc configuration failure #901

Closed walleludvig closed 2 years ago

walleludvig commented 2 years ago

Hi all,

I am seeking help to install and configure EGSnrc on my mac running macOS 12.4 Monterey. I have followed the installation instructions rigorously and downloaded EGS using the first listed option (by cloning the git repository), however I am experiencing an issue with the configuration.

After accepting the automatically generated compiler/linker switches:

============================================================================================ Using the following compiler/linker switches for creating/linking against dynamic shared objects (DSO, also known as shared library or DLL), where $ (abs_dso) or $ (ABS_DSO) below will be replaced with the absolute path to the EGSnrc DSO directory at compile/link time:

1) Optimization options: -O2 -mtune=native 2) Generation of position independent code:
3) Preprocessor defines: -DOSX 4) Flag for creating shared libraries: -dynamiclib 5) Output/dlopen library: -o $@ 6) DSO path encoded in the executable: -L$(abs_dso) 7) Linking against library some_lib: -lsome_lib 8) Fortran libraries needed by C++ linker: -L/usr/local/Cellar/gcc/11.3.0_2/bin/../lib/gcc/11/gcc/x86_64-apple-darwin21/11 -L/usr/local/Cellar/gcc/11.3.0_2/bin/../lib/gcc/11/gcc -L/usr/local/Cellar/gcc/11.3.0_2/bin/../lib/gcc/11/gcc/x86_64-apple-darwin21/11/../../.. -lgfortran -lemutls_w -lquadmath -lm 9) Creating library bundles on OSX: -L/usr/local/Cellar/gcc/11.3.0_2/bin/../lib/gcc/11/gcc/x86_64-apple-darwin21/11 -L/usr/local/Cellar/gcc/11.3.0_2/bin/../lib/gcc/11/gcc -L/usr/local/Cellar/gcc/11.3.0_2/bin/../lib/gcc/11/gcc/x86_64-apple-darwin21/11/../../.. -lgfortran -lemutls_w -lquadmath -lm

I hit enter to proceed and get the following error:

============================================================================================ Creating C++ config file ... OK Building the IAEA phase space library ... Failed Building the EGSnrc C++ class library ... Failed

These settings did not work out. You may edit the source code (in case you can see where the problem is when building the C++ libraries from the configure.log file) and/or try different compiler/linker options.

============================================================================================

Additionally, ctcreate and dosxyz_show was skipped during compiling with the following message: "Skipping (no C compiler)"

Any help and tips that might get me closer to solving this issue is greatly appreciated!

ftessier commented 2 years ago

Thank you @mchamberland for all the great support, and @walleludvig for not giving up! πŸ… Maybe I ought to ask work for a newer mac πŸ˜†.

walleludvig commented 2 years ago

@mchamberland I had previously failed to add the paths to my .zshrc file as you earlier mentioned to do. Turns out I had been denied permission to edit that file before however I have resolved that issue now.

echo $QTDIR now returns /opt/homebrew/Cellar/qt@5/5.15.5_1.

I believe ctcreate compilation has worked now, for reference this is the output I got from >make after having done >make clean. ctcreate_compile_output.txt

One step closer to the finish line!

I am still experiencing issue with the egs_view compilation, but this time it ran for a while returned a whole. At the end the following error message is prompted: ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation) make[1]: *** [../../bin/osx/egs_view.app/Contents/MacOS/egs_view] Error 1 make: *** [all] Error 2

My /opt/homebrew/Cellar/qt@5/5.15.5_1/mkspecs/common/g++-base.conf looks like this g++baseconfig.txt

and /opt/homebrew/Cellar/qt@5/5.15.5_1/mkspecs/common/macx.conf looks like this macxconf.txt.

walleludvig commented 2 years ago

Thank you @mchamberland for all the great support, and @walleludvig for not giving up! πŸ… Maybe I ought to ask work for a newer mac πŸ˜†.

I really wanna get this working! And I am grateful for such good support :) Almost there now

mchamberland commented 2 years ago

@walleludvig Can you post the entire output when you do make? Make sure to do a make clean first. Maybe there will be something in there to clue me in.

Since the linker complains about arm64, maybe you should remove the line QMAKE_APPLE_DEVICE_ARCHS = arm64 from macx.conf (even though I had to add it). This is mostly a stab in the dark. We'll see what if any error message this throws.

walleludvig commented 2 years ago

Hi @mchamberland,

Removing QMAKE_APPLE_DEVICE_ARCHS = arm64 made it only fail much faster. I am immediately prompted Project ERROR: QMAKE_APPLE_DEVICE_ARCHS or QMAKE_APPLE_SIMULATOR_ARCHS must contain at least one architecture without having that line.

However, this is the total output from make clean, and then make respectively when I have included QMAKE_APPLE_DEVICE_ARCHS = arm64:

egs_view_make_cleanOutput.txt

egs_view_makeOutput.txt

mchamberland commented 2 years ago

Ok good to know. Leave that line, then. Do another make clean and make, then post the Makefile_osx that gets generated in the egs_view source folder.

walleludvig commented 2 years ago

Here's a .txt version of that file @mchamberland (since GitHub don't let me upload the original filetype): egs_view_makefile_osx.txt

mchamberland commented 2 years ago

Actually, instead of make clean try make realclean.

walleludvig commented 2 years ago

Tried make realclean now but ended up with the same results.

Here's the new makefile_osx: egs_view_makefile_osx_realclean.txt

mchamberland commented 2 years ago

I’m out of ideas, but at this point, I would remove the entire EGSnrc folder, clone it fresh and redo everything, taking into account what you know now to get it working on the first try.

Let me know how that goes… πŸ˜…

mchamberland commented 2 years ago

@walleludvig Taking a closer look at your Makefile_osx, I believe the problem is the following line:

LINK = /Library/Developer/CommandLineTools/usr/bin/g++\

This should be pointing to the Brew g++. Mine looks like this:

LINK = /opt/homebrew/bin/g++-11

I remember having this issue before getting it to work, so maybe in my QT instructions above, I missed something. Or perhaps, again, just a fresh EGSnrc clone will resolve everything.

Almost there!

walleludvig commented 2 years ago

Hi @mchamberland,

Apologies for taking so long to get back at this issue, but have unfortunately not had much time for it.

I tried a complete fresh EGSnrc clone install and configuration and this time it all went pretty smoothly. I have not had any errors in configuration or compilation and even egs_view seem to have compiled alright. However, when I attempt to open egs_view by open -a egs_view it automatically opens up a finder window. I am not sure if that means it's looking for an application to open egs_view with or what else.

For reference, when I follow the first tutorial steps of the installation docs and run egs_view slab.egsinp slab.ptracks it returns zsh: command not found: egs_view, so perhaps the compilation hasn't been successful as egs_view is not aliased?

(alias egs_view does not return anything)

Any advice on how I might finally get this going?

mchamberland commented 2 years ago

For egs_view, here's what I do:

  1. Go to $HEN_HOUSE/[your config name]/bin using the Finder.
  2. Right-click on egs_view and choose Show package contents.
  3. Go down the folders to Contents --> MacOS. You should find another egs_view executable in there. Copy it to the $HEN_HOUSE/[your config]/bin folder.
  4. This should now work. Maybe you'll need to restart your terminal session. (You can also delete the egs_view package; you just need the executable that you copied for it to work.)

@walleludvig This is what I do. If you use the open -a egs_view, then the Finder window wants you to select an input file to open.

Glad you got everything working!

walleludvig commented 2 years ago

Thanks for your continuous support @mchamberland.

I have done as you suggested and copied the egs_view exec to my HEN_HOUSE/bin/osx folder. And this is what's currently happening:

My optimism lies with the fact that egs_view can now successfully be executed and I can use it for all that I would need as I usually have been opening egs_view with in egs_view <filename> type matter.

Thank you so much for all your help and support @mchamberland, and @ftessier. I am very happy to finally be able to start conducting simulations with my new M1 chip!

Here's a celebratory screen shot of the first successful egs_view run!

Screen Shot 2022-08-18 at 12 10 44 pm
edwardrjtaylor commented 5 months ago

Hi I had this same issue and have fixed it using steps similar to those above: My Mac is: OS: macOS Monterey Version 12.6.3, Chip: Apple M1 Pro

In my installation of EGSnrc I specified: gcc-13 and g++-13 (these were installed with brew commands beforehand)

In the: /pathto/EGSnrc-master/HEN_HOUSE/egs++/view/Makefile_osx file

I edited: CC = /opt/homebrew/bin/gcc-13 (It was gcc-12) CXX = /opt/homebrew/bin/g++-13 (it was g++-12) EXPORT_QMAKE_MAC_SDK_VERSION = 12.6 (was 12.3)

[in the pathto/EGSnrc-master/HEN_HOUSE/egs++/view folder] I did: make clean make

Opened the finder window with egs_view.app Clicked 'Show package contents' Navigated to 'pathto/EGSnrc-master/HEN_HOUSE/bin/osx/egs_view.app/Contents/MacOS' Copied this "egs_view" [executable] up to the 'pathto/EGSnrc-master/HEN_HOUSE/bin/osx/' folder