Installing SNAPHU on Macbook

Somewhere, I read Snaphu installation instruction as:-

-Download the software and locate it wherever desired

  • Terminal
  • Go to the location, create a file named “.cshrc” typing “vi .cshrc”
  • once inside the file, press “i” and insert will be activated in the bottom of the screen.
    -then copy this line "set path = (/here insert snaphu folder path/bin $path) Making sure that you put your own path.
  • to exit and save just press “esc” and then “:wq”
    -now type “source .cshrc”

However it did not work for me. Can anyone help how to install snaphu on Macbook?

If you downloaded the Snaphu source code from the original Stanford website, you will need to compile it. I am not aware of any place that you can download a pre-built binary for the Mac OSX.

To compile Snaphu, you need to use the terminal to go (cd) to the directory where you downloaded Snaphu and then cd to the “src” directory. Type “make” to build it. I think all Mac OSX machines have “make” and a C compiler, so they should be able to build the program. This should place the executable program in the snaphu/bin directory.

The instructions you listed are still necessary to add the snaphu/bin directory to your path.

1 Like

Thank you for the suggestion. The make command gets this error!

cc -static -O3
snaphu.c
snaphu_tile.o snaphu_solver.o snaphu_io.o snaphu_util.o snaphu_cost.o snaphu_cs2.o
-o …/bin/snaphu
-lm
ld: library not found for -lcrt0.o
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** […/bin/snaphu] Error 1

You can’t use the “-static” flag on the Mac. Did you add that to the Makefile? The Makefile that comes with the download from Stanford has only this:
CC = cc
CFLAGS = -O3 # -D NO_CS2

You should remove the “-static” from the CFLAGS.

Oh the one I tried was linux version one (http://step.esa.int/main/third-party-plugins-2/snaphu/). I then went with the one form Stanford and first tried to build as you suggested and got the following result! Shall I set the path first or build first?
cc -O3 -c -o snaphu_tile.o snaphu_tile.c
cc -O3 -c -o snaphu_solver.o snaphu_solver.c
cc -O3 -c -o snaphu_io.o snaphu_io.c
snaphu_io.c:753:6: warning: comparison of constant 32767 with boolean expression
is always false [-Wtautological-constant-out-of-range-compare]
>POSSHORTRANGE){
^~~~~~~~~~~~~~
1 warning generated.
cc -O3 -c -o snaphu_util.o snaphu_util.c
snaphu_util.c:578:10: warning: ‘finite’ is deprecated: first deprecated in macOS
10.9 [-Wdeprecated-declarations]
return(finite(d));
^
/usr/include/math.h:757:12: note: ‘finite’ has been explicitly marked deprecated
here
extern int finite(double) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __M…
^
1 warning generated.
cc -O3 -c -o snaphu_cost.o snaphu_cost.c
cc -O3 -c -o snaphu_cs2.o snaphu_cs2.c
cc -O3
snaphu.c
snaphu_tile.o snaphu_solver.o snaphu_io.o snaphu_util.o snaphu_cost.o snaphu_cs2.o
-o …/bin/snaphu
-lm

You can ignore the compilation warnings. It looks like your build completed. You can now set the path to your snaphu/bin directory and try running it.

Thanks. I followed this link https://www.architectryan.com/2012/10/02/add-to-the-path-on-mac-os-x-mountain-lion/#.Ueg2zWTXSA8 to set the path to bin, and am sure it is added (Please see it below.)
roshan@Roshans-MacBook-Pro:~$ echo $PATH
/Library/Frameworks/Python.framework/Versions/3.6/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin :/Users/roshan/snaphu-v1.4.2/bin

Now, as I type ‘snaphu -h’ or ‘snaphu’ , both shows
“-bash: snaphu: command not found”

Could you please tell me where lies the error. Sorry for my novice questions.

you can use whereis snaphu to get the path that is required by linux to run snaphu from any location. This is the one you add to your path. But you have to make sure that this is permanent.

Yes, it looks like you added to your PATH successfully. Are you sure you added the right path to your PATH? Check with “ls /Users/roshan/snaphu-v1.4.2/bin”. Can you see the compiled “snaphu” with that “ls”?

Thank you EJFielding! I successfully installed and added the path as well and it works!

2 Likes

Hello! I have just read materials above. It look like you successfully make your MAC work with snaphu.
Is it possible to get that file from you? I understand that what is written above is like instructions but I don’t know how to use it(