How can I create a binary for another BSD system?

Sometimes you are not allowed (i.e: lack of privileges), you can not (i.e: lack of disk space) or (for any other reason) you don't want to install or compile a program on a FreeBSD system.

I was wondering if it is possible to perform the compiling/installing (or whatever) operation on another unrestricted FreeBSD computer and transfer just one (or a few) binary (executable) file to the "restricted" machine.

Say I want to use ImageMagick "convert" tool to be able to convert text files to their equivalent image files on the restricted FreeBSD computer:

Code:
convert "@hello.txt" hello.png

Maybe I could download and compile the sources generating a transferable binary?
Or maybe installing is the best way? What file or files should I transfer, then?

If possible, some details about the steps I must keep would be thanked.

Notes:
- We can assume the unrestricted FreeBSD computer could be modified in any manner, i.e: we can format it and install the same FreeBSD version of the restricted computer.
 
If I understand your question, you just want Imagemagick's convert tool on your machine. You could (untested by me) see what it requires with
Code:
 ldd /usr/local/bin/convert
and try to get all those on the second machine, but I would think (not knowing your situation) that you would be better off using pkg, which doesn't require compiling, it just installs the package on your system.
Not sure if this answer is a waste of your time, if it is, I apologize. Short answer, might be possible, but might require more work than it's worth. Though I suppose you could also copy over the needed libraries that you got from the ldd command over to the new machine.
 
You can build your port with MAKE_ARGS+= STATIC=1 and it will run on most any FreeBSD as it is self contained..
You must add this to the ports makefile, all dependencies makefile and to the dependencies of those as well.
So it works best for small programs with few dependencies.
 
drhowarddrfine, I just tried it, made a test.txt and used convert on it. It does change it to a png file which was just the text on a white background. The OP may have some use case for that particular example, personally, I've always used it as you describe, change the format of an image from, for example, png to jpg, or even pdf. (Ah, changing text to pdf might be a use case, though there are other tools.)
 
It's simple. Statical link and done. We also use this method to distribute for a broad class of Linux, targeting glibc version of Redhat 6 and it will run on any newer versions of glibc 😘
 
Back
Top