How to install and run gcc safely without polluting my flawlessly running system

decuser

Member

Thanks: 2
Messages: 33

#1
I am wanting to run the examples in the Stevens book, Advanced Programming in the Unix Environment. I'd rather not pollute my running system with extraneous files that are not required for the system to function. My question and followups for the masters out there:

What's a safe way to install and run gcc safely on my fbsd 11.2 system in such a way that it doesn't litter my filesystem with its cruft? Is this something where I should just download the gcc/gdb/etc source and install as a regular user using --prefix, or is this suited to a jail (never used one before), or what?

Thanks!

Will
 

Chris_H

Daemon

Thanks: 182
Messages: 1,076

#2
I think the simplest way for you to accomplish pretty much anything like this, and avoid unnecessary/undesirable housekeeping is jail(8). That is; setup a jail on your box, and everything is self-contained. You can then easily tailor your environment to your exact needs/desires. :)

HTH

--Chris
 

ralphbsz

Daemon

Thanks: 688
Messages: 1,159

#3
Why do you need gcc for the Stevens book? Clang (the more common compiler, which I think is installed by default) should be able to work fine, right?

And while I understand wanting to have a pretty and clean file system, the pkg system is pretty good at cleaning up. I wouldn't worry about just using pkg to install gcc as root. If after a while you decide you no longer need it, pkg can uninstall it and get rid of the files again. The only thing is: if you have edited configuration files (like /usr/local/etc/xxx.conf) by hand, you should also delete them by hand before letting pkg uninstall.
 
OP
OP
decuser

decuser

Member

Thanks: 2
Messages: 33

#4
I haven't tried with Clang yet. make didn't, so I tried gmake, which complained about missing gcc. In retrospect, I'm thinking the makefile had explicit refs to gcc... I'll go back and see if I can just do it by hand.
 

ralphbsz

Daemon

Thanks: 688
Messages: 1,159

#5
Your theory with the (g-) makefile explicitly calling for gcc or g++ is most likely. Search for those strings in there, and try replacing them with cc and c++. Clang has been designed to use the same command line switches as gcc, so you'll most likely just get lucky.
 
OP
OP
decuser

decuser

Member

Thanks: 2
Messages: 33

#6
Nice. Just replaced gcc with cc and removed some extraneous conditionals and everything compiles just fine with clang. I thought the switches would all be different, thanks ralphbsz for setting me straight on that.
 

connchri

Member

Thanks: 4
Messages: 27

#7
You could make a snapshot of your before you start, and anything you want to keep afterwards copy somewhere safe before you restore?

Otherwise, I second Jails.
 
Top