PDA

View Full Version : Cross Compile Linux to FreeBSD



technomage
07-05-2006, 01:04 PM
Hi people

this is a trickyl question. I have a nice little cgi application that wrosk fine under both windows and linux (I have both of thse opertating systems) but it appears not to work under FreeBSD :cry:

I do know it is possibleto use Free Pascal to cross compile (using the -T option) but Iwas wondering if anyone has got this to work under linux :?: If so what do I need to do.

Any ideas?

Dean
PS - As a side note I'm trying to install FreeBSD under qemu so I have a virtual pc with free bsd on it, but i'd rather just compile under linux if possible.

technomage
07-05-2006, 07:10 PM
Ok , the good news is I now have a FreeBSD image which has Free Pascal on it :D. And the compiled cgi app worked fine on my web server.

To asnwer my own question, I downloaded the freebsd units and placed those in my free pascal units directory under i386-freebad. then you can compile using fpc <project> -Tfreebsd.

It can't actually produce the exe as the link stage fails but it does compile all the units, so you know if you unit will compile user freebsd as well as win32, I assume you can do the same for linux aswell.

Of course this doesn't mean you application will run under freebsd without testing but it goes along way to knowing if your code is portable :D

marmin
09-05-2006, 04:57 PM
Try a dedicated IRC channel and ask the developers. They mostly know a lot.

marcov
21-07-2006, 08:10 AM
Ok , the good news is I now have a FreeBSD image which has Free Pascal on it :D. And the compiled cgi app worked fine on my web server.

To asnwer my own question, I downloaded the freebsd units and placed those in my free pascal units directory under i386-freebad. then you can compile using fpc <project> -Tfreebsd.


See also www.stack.nl/~marcov/buildfaq.pdf for lots of background info.

Make sure you have installed linux->freebsd crossbinutiils (an mostly correct script for that in install/ directory of the "fpcbuild" svn module) make sure they are renamed i386-freebsd-as and i386-freebsd-ld and i386-freebsd-ar and compile with -XPi386-freebsd- -TFreeBSD to generate bins.

[quote]
It can't actually produce the exe as the ]

To windows or to linux/freebsd without using shared libs is easiest. To linux/freebsd while using shared libs is harder.

To OS X requires more to set up, but is easier because there are fewer variants of the core libraries (about 3 in supported OS X versions 10.2-10.4)