Curious question about FreeBSD

Hyperblaze

Lifer
May 31, 2001
10,027
1
81
If you are doing C/C++ coding or shell scripting, are there anything you need to be aware of compared to when you would be coding in Linux?

I know they aren't identical so that's why I'm wondering.

 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
Ummmmm, no. They use the same compiler. :p

EDIT: Shell scripting might be different. I'm not sure, but I think FreeBSD uses decent shells by default and Linux uses bash.
 

Red and black

Member
Apr 14, 2005
152
0
0
Some library interfaces will be slightly different -- for instance, the socket structs. Basically, just fix your compile errors and you should be good to go.
 

Red and black

Member
Apr 14, 2005
152
0
0
Note also that different GCC versions will treat your code (especially C++ code) differently. Be prepared for new warnings with newer versions of GCC.
 

uOpt

Golden Member
Oct 19, 2004
1,628
0
0
The differences between different gcc variants on Linux are bigger than the differences between the C/C++ variants on Linux and FreeBSD. As long as you stay POSIX compliant there should be no problem.

FreeBSD still uses an ash variant for /bin/sh, that means you have to stay in the POSIX spec for bourne shell syntax. Which you should do anyway, if you have a shellscript getting complicated enough that you have to resort to non-POSIX tricks you should upgrade the whole thing to python or perl before it gets more complicated.
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
Originally posted by: MartinCracauer
The differences between different gcc variants on Linux are bigger than the differences between the C/C++ variants on Linux and FreeBSD. As long as you stay POSIX compliant there should be no problem.

FreeBSD still uses an ash variant for /bin/sh, that means you have to stay in the POSIX spec for bourne shell syntax. Which you should do anyway, if you have a shellscript getting complicated enough that you have to resort to non-POSIX tricks you should upgrade the whole thing to python or perl before it gets more complicated.

Preferably perl since it's practically standard these days.
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
EDIT: Shell scripting might be different. I'm not sure, but I think FreeBSD uses decent shells by default and Linux uses bash.

FreeBSD either uses normal /bin/sh or csh by default, both of which are ass compared to bash. Even Apple wised up and made bash the default shell after a few releases.
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
Originally posted by: Nothinman
EDIT: Shell scripting might be different. I'm not sure, but I think FreeBSD uses decent shells by default and Linux uses bash.

FreeBSD either uses normal /bin/sh or csh by default, both of which are ass compared to bash. Even Apple wised up and made bash the default shell after a few releases.

Apple used tcsh, which was fine for everything but scripting. BSDs traditionally had csh as the default shell for root, which is fine since you don't need to use root. OpenBSD's gone ahead and changed it, and did a lot of work on pdksh.
 

Red and black

Member
Apr 14, 2005
152
0
0
The default interactive shell is a completely different matter from the shell people use to write shell scripts.

The default interactive shell in NetBSD is sh for root, and csh for non-root. Both lack many handy interactive features; people usually install tcsh, bash or zsh as packages.
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
Originally posted by: Red and black
The default interactive shell is a completely different matter from the shell people use to write shell scripts.

The default interactive shell in NetBSD is sh for root, and csh for non-root. Both lack many handy interactive features; people usually install tcsh, bash or zsh as packages.

That must suck for NetBSD and FreeBSD users. :p
 

Red and black

Member
Apr 14, 2005
152
0
0
In NetBSD at least, there's a certain level of competence expected from users. The developers don't bend over backwards to make it noob-friendly. This is a bad thing or a good thing, depending on whether you are a noob.
 

Red and black

Member
Apr 14, 2005
152
0
0
Red and black: "people usually install tcsh, bash or zsh as packages."
n0cmonkey: "That must suck for NetBSD and FreeBSD users."
Red and black: "In NetBSD at least, there's a certain level of competence expected from users."
Nothinman: "I don't get it, aren't pkgsrc, ports, etc supposed to make that easy too?"

Yes, they make it easy, but apparently not easy enough for n0monkey.
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
Originally posted by: Red and black
Red and black: "people usually install tcsh, bash or zsh as packages."
n0cmonkey: "That must suck for NetBSD and FreeBSD users."
Red and black: "In NetBSD at least, there's a certain level of competence expected from users."
Nothinman: "I don't get it, aren't pkgsrc, ports, etc supposed to make that easy too?"

Yes, they make it easy, but apparently not easy enough for n0monkey.

I'd rather have a great shell right off the bat instead of having to go through ports (and setting up pkgsrc is a PITA) to install one. OpenBSD's modified pdksh works great, no need for lesser shells. :beer:
 

Red and black

Member
Apr 14, 2005
152
0
0
cd /usr
CVSROOT=anoncvs@some-anon-cvs-mirror.netbsd.org:/cvsroot cvs co -P pkgsrc
cd pkgsrc/shells/foo
make install clean clean-depends

Doing the CVS checkout takes a while if your disk or your network connection is slow, but other than that, setting up pkgsrc is really straightforward. And you were going to set up pkgsrc anyway to get GNU screen, right?

:)
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
Originally posted by: Red and black
cd /usr
CVSROOT=anoncvs@some-anon-cvs-mirror.netbsd.org:/cvsroot cvs co -P pkgsrc
cd pkgsrc/shells/foo
make install clean clean-depends

Doing the CVS checkout takes a while if your disk or your network connection is slow, but other than that, setting up pkgsrc is really straightforward. And you were going to set up pkgsrc anyway to get GNU screen, right?

:)

Screen is one of the first things I install. ;)

Of course, I just install the binary in OpenBSD (using a great interactive shell, that comes installed by default). :D
 

birdpup

Banned
May 7, 2005
746
0
0
Originally posted by: Hyperblaze
If you are doing C/C++ coding or shell scripting, are there anything you need to be aware of compared to when you would be coding in Linux?

Originally posted by: n0cmonkey
Ummmmm, no. They use the same compiler. :p

I think it may have been missed that Linux applications tend to expect the GNU C/C++ compiler, gcc (and g++). FreeBSD currently uses icc v8.1.032, which is "Intels C/C++ compiler, set up to produce native FreeBSD binaries". When developing, you can use whichever compiler you wish but you may wish to use the icc compiler if developing applications specifically for FreeBSD. I am not sure on this point though since I have not developed applications specifically for FreeBSD.

Typically, an application compiled for linux will produce errors in FreeBSD if trying to install using "make install" since FreeBSD expects icc compiler produced binaries. However, FreeBSD does possess perfectly working Linux Binary Compatibility.

 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
Originally posted by: birdpup
Originally posted by: Hyperblaze
If you are doing C/C++ coding or shell scripting, are there anything you need to be aware of compared to when you would be coding in Linux?

Originally posted by: n0cmonkey
Ummmmm, no. They use the same compiler. :p

I think it may have been missed that Linux applications tend to expect the GNU C/C++ compiler, gcc (and g++). FreeBSD currently uses icc v8.1.032, which is "Intels C/C++ compiler, set up to produce native FreeBSD binaries". When developing, you can use whichever compiler you wish but you may wish to use the icc compiler if developing applications specifically for FreeBSD. I am not sure on this point though since I have not developed applications specifically for FreeBSD.

Typically, an application compiled for linux will produce errors in FreeBSD if trying to install using "make install" since FreeBSD expects icc compiler produced binaries. However, FreeBSD does possess perfectly working Linux Binary Compatibility.

FreeBSD uses GCC, just like every other one of the BSDs. And Linux. icc is a port. You can use it if you want, but why bother? You could also probably use tendra.

make may be a problem because FreeBSD probably uses BSD make, which differs from GNU make. Installing the gmake port fixes this though, and I'm not sure how many programs really rely on GNU make anyhow...