How to compile statically linked SSHFS?

527 views
Skip to first unread message

Advrk Aplmrkt

unread,
Jul 11, 2012, 9:42:49 PM7/11/12
to osxfus...@googlegroups.com
Hello,

As I attempt to build a patched SSHFS 2.4 with the remote_dmask and remote_fmask options developed here, I would also like to build it into a statically linked portable binary so that I can easily use it on all my machines.

However, when I use the "-static" gcc option, I get an error saying "configure: error: C compiler cannot create executables". I've also pasted the corresponding part of config.log here.

Since the Fuse for OS X website distributes a .pkg installer for SSHFS, surely there is a way to build a statically linked portable SSHFS?

Any instructions would be great, thank you!

Benjamin Fleischer

unread,
Jul 12, 2012, 1:00:35 AM7/12/12
to osxfus...@googlegroups.com
After you ran make to build a non-static version of SSHFS run the following command in the source directory:

gcc -D__DARWIN_64_BIT_INO_T=1 -D__FreeBSD__=10 -D_FILE_OFFSET_BITS=64 -D_REENTRANT -I/usr/local/include/osxfuse/fuse -I/opt/local/include/glib-2.0 -I/opt/local/lib/glib-2.0/include -I/opt/local/include -DDARWIN_SEMAPHORE_COMPAT -Wall -W -o sshfs sshfs-sshfs.o sshfs-cache.o -pthread -L/usr/local/lib -losxfuse /opt/local/lib/libglib-2.0.a /opt/local/lib/libgthread-2.0.a /opt/local/lib/libiconv.a /opt/local/lib/libintl.a -framework Carbon

This relinks the SSHFS binary using only static libraries. Please note, that this will only work if you installed all the necessary libraries through MacPorts to /opt/local.

Advrk Aplmrkt

unread,
Jul 12, 2012, 1:27:30 AM7/12/12
to osxfus...@googlegroups.com
Hello,

I tested the resulting binary on another machine, and yes it worked! Just one more thing: I was trying to build an Universal Binary for i386, x86_64, and ppc architectures, but after running that command there is only x86_64 left. Is there a way to run this process so that I end up with a statically linked Universal Binary of SSHFS, just like the one distributed by the package installer?

Sorry I have so many questions, I am rather new to all this. Thank you for your patience!

Benjamin Fleischer

unread,
Jul 12, 2012, 1:40:34 AM7/12/12
to osxfus...@googlegroups.com
To create a static universal binary (ppc, i386, x86_64) you need to install universal version of all needed libraries, then run the following command in the source directory:

autoreconf -i
CFLAGS="-DDARWIN_SEMAPHORE_COMPAT -arch i386 -arch x86_64 -arch ppc" ./configure --prefix=/usr/local --disable-dependency-tracking

make
gcc -D__DARWIN_64_BIT_INO_T=1 -D__FreeBSD__=10 -D_FILE_OFFSET_BITS=64 -D_REENTRANT -I/usr/local/include/osxfuse/fuse -I/opt/local/include/glib-2.0 -I/opt/local/lib/glib-2.0/include -I/opt/local/include -DDARWIN_SEMAPHORE_COMPAT -arch i386 -arch x86_64 -arch ppc -Wall -W -o sshfs sshfs-sshfs.o sshfs-cache.o -pthread -L/usr/local/lib -losxfuse /opt/local/lib/libglib-2.0.a /opt/local/lib/libgthread-2.0.a /opt/local/lib/libiconv.a /opt/local/lib/libintl.a -framework Carbon

In addition to the universal libraries you will need Xcode 3.2 for building PPC binaries. 

Advrk Aplmrkt

unread,
Jul 12, 2012, 2:16:16 AM7/12/12
to osxfus...@googlegroups.com
I just compiled it per your instructions, and tested it both on my
Intel Core i7 MacBook Pro and on an old PowerMac G4 - both worked! So
that I can "learn how to fish", if anyone can tell me resources to
learn what all those commands mean that would be great.

Thank you so much for your help and patience, I very grateful! Now I
just need to go on and figure out the permissions issues I am having
for mounted SSHFS volumes...

jwrascoe

unread,
Jul 21, 2012, 8:32:09 AM7/21/12
to osxfus...@googlegroups.com
Hi... I have been having the same problem trying to complie sshfs

Since you have it working correctly with the remote_dmask option would you be able to send me a copy?

I would really appreciate it.

Thanks.

Jim

Advrk Aplmrkt

unread,
Jul 21, 2012, 10:43:19 AM7/21/12
to osxfus...@googlegroups.com
Hello!

Yes I finally got it to work, but with some problems running it,
especially as part of MacFusion. Which version of Mac OS X are you
running? I tested it from 10.5 through 10.7 on both PPC and Intel
machines, and here is the list of runtime problems:

https://groups.google.com/d/msg/osxfuse-group/1Cuk_aB4Qgs/nYH8Cva2kJQJ

When you test it can you please let me know if you run into similar problems???

Here is the link to the statically linked sshfs binary:

http://www.solarsendit.net/d3UHDhEJabt8t8q4

Please let me know how it works for you, thanks!

James Rascoe

unread,
Jul 21, 2012, 11:21:57 AM7/21/12
to osxfus...@googlegroups.com
Thanks... It works GREAT... thes options worked just fine.

-o remote_dmask=775 -o remote_fmask=775

To make it run in MacFusion all you need to do do a "show package contents" on your MacFusion app.

Then... go to the Contents/Plugins/sshfs.mfplugin/Contents directory

rename the old sshfs-static and then put yours in that directory and call it sshfs-static

After that you will be fine!

Thanks again.. you should publish this as a lot of people are looking for it.

Jim

--
James W. Rascoe
President


eDataQuest
130 North Main Street
2nd Floor
Concord, NH 03301

Office: 603.856.7652 ext. 204 (**Please Note My New Extension**)
Fax: 603.856.7619
Mobile: 603.513.8682
Email: j...@edataquest.com


eDataQuest, CONFIDENTIALITY NOTICE: This electronic message and any included attachments are intended to be viewed only by the individual or entity to whom it is addressed. It may contain information that is privileged, confidential and may constitute inside or non-public information under international, federal, or state securities laws. Any dissemination, distribution or copying of this communication is strictly prohibited without our prior permission. If the reader of this message is not the intended recipient, or the employee or agent responsible for delivering the message to the intended recipient, or if you have received this communication in error, please notify us immediately by return e-mail or call eDataQuest. at 603-856-7652. Please then delete the original message and any copies of it from your computer system. Thank you.


Advrk Aplmrkt

unread,
Jul 21, 2012, 12:44:39 PM7/21/12
to osxfus...@googlegroups.com
Glad it worked! But how are binaries like this usually "published"?

I tried replacing the stock sshfs-static in the MacFusion application
with mine, but its got problems:

On the Mac OS X 10.5 machine, the volume mounts, but shows it has
"zero bytes" free space, and I was unable to upload any files to it!
(opening, editing, and saving existing files seemed fine)

On the Mac OS X 10.6 machine, I got this error when I try to mount the
volume: "Could not mount filesystem: Authentication failed." Looks
like this is the part of the log that shows the problem:

(SSHServerFS, [volume name], 2012-07-12 13:28:35) debug1:
Authentications that can continue:
publickey,gssapi-keyex,gssapi-with-mic,password
debug1: Next authentication method: publickey
debug1: Trying private key: /Users/[my user]/.ssh/id_rsa
debug1: Trying private key: /Users/[my user]/.ssh/id_dsa
debug1: Next authentication method: password
debug1: read_passphrase: can't open /dev/tty: Device not configured
(SSHServerFS, [volume name], 2012-07-12 13:28:36) debug1:
Authentications that can continue:
publickey,gssapi-keyex,gssapi-with-mic,password
debug1: No more authentication methods to try.
Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).

On the Mac OS X 10.7 machine, the volume was mounted successfully, and
most operations worked (such as creating, deleting, and modifying most
files). However, there are some strange permissions issues. For
example, Micro$oft Office 2011 applications like Word or Excel insists
on opening documents on the volume as read-only, and complains about
no permissions when trying to save to, or overwrite a file.

If anyone has suggestions I am all ears. Thanks!
Reply all
Reply to author
Forward
0 new messages