[SOLVED] Compiling from source and safe experiments

Quick to answer questions about finding your way around Linux Mint as a new user.
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions use the other forums in the support section.
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
User avatar
eiver
Level 5
Level 5
Posts: 568
Joined: Fri Jan 23, 2009 5:51 am

[SOLVED] Compiling from source and safe experiments

Post by eiver »

Hi all!

I would like to learn how to compile something from source without affecting the system. In particular I am trying to compile totem from source, but the "configure" script forces me to install more and more dependencies. The more I install the less I know about what is happening in the system. For example it complains, that gstreamer (which I have from the repos by default) is not recent enough. How can I set a development environment, which lives in a folder and compiles to a given output folder where I can test it and play with it. I do not want to install all the possibly unstable dependencies on the machine just to test a single application, which requires them. Right now I want to do this for totem, but I would like to know how to do it in general under Linux. I failed to find a tutorial for that.
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 2 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
piratesmack

Re: Compiling from source and safe experiments

Post by piratesmack »

Sounds like a chroot is what you want
https://help.ubuntu.com/community/DebootstrapChroot
User avatar
eiver
Level 5
Level 5
Posts: 568
Joined: Fri Jan 23, 2009 5:51 am

Re: Compiling from source and safe experiments

Post by eiver »

Yes, this is probably what I want, but the tutorial guides me to make a complete copy of the system in the chrooted environment. Do I need to do this to debug just one program. In windows I could just download the source code to a folder, then copy any necessary dlls to that same folder (or add them to the source code project if I have sources for them too) and then produce a nice exe file with a number of dll files it uses. Any original dlls would still be installed somewhere and used by the system, while my custom dlls would be only used for my debugging fun, so no other programs in the system would stop working if I screw something up. I wanted to do something equivalent in Linux.
piratesmack

Re: Compiling from source and safe experiments

Post by piratesmack »

Oh, I see.

Here's an example of me compiling Zenity on Slackware

Zenity has 1 dependency: libgnomecanvas

First, I created a folder to install the program in:

Code: Select all

mkdir -p ~/programs
Next I compiled libgnomecanvas with:

Code: Select all

# These configure options will make sure the program is installed into the folder I created above
./configure --prefix=~/programs --sysconfdir=~/programs/etc --localstatedir=~/programs/var

make

# run make install as an ordinary user so nothing can go where it's not supposed to.
make install
Then I compiled Zenity:

Code: Select all

# Since we installed libgnomecanvas into a non-standard prefix, we have to set PKG_CONFIG_PATH so configure will be able to find it
export PKG_CONFIG_PATH=~/programs/lib/pkgconfig

# Configure Zenity with the same options
./configure --prefix=~/programs --sysconfdir=~/programs/etc --localstatedir=~/programs/var

make

make install

Now to launch Zenity:

Code: Select all

# Since our libs are in a non-standard place, you need to set LD_LIBRARY_PATH
export LD_LIBRARY_PATH=~/programs/lib
# add ~programs/bin to our PATH
export PATH="$PATH:~programs/bin"

zenity <options>


You could also create a simple launcher script and place it in /usr/local/bin.

Example:

Code: Select all

#!/bin/sh
# launch-zenity.sh

export LD_LIBRARY_PATH="~/programs/lib"
export PATH="$PATH:~/programs/bin"

exec zenity $@
DataMan

Re: Compiling from source and safe experiments

Post by DataMan »

If you have the real estate (hd storage), another alternative to the chroot mentioned above is to do a parallel install of the production ops. In version 2 you make all changes etc. to guage the effect of new additions etc.

I am currently doing this with Mint 8 64 bit. My stable (production system) undergoes very controlled additions and updates. All trial apps etc are installed and evaluated in the "Experimental" ops. Once I am totally satisfied that any change is safe (relatively) I then introduce it to the production ops.

As a footnote, I actually use my production ops in my work-work and absolutely need stability for that purpose. That's why my "over-the-top" scenario works for me :lol: .

Hope this is of benefit.

-DataMan
User avatar
eiver
Level 5
Level 5
Posts: 568
Joined: Fri Jan 23, 2009 5:51 am

Re: Compiling from source and safe experiments

Post by eiver »

Thanks piratesmack!

Thats exactly what I needed. I successfully compiled Totem thanks to your example. And I even fixed my first bug on Linux (Bug #323649). Now I feel like a Linux developer. A very noobish Linux developer, but a developer nonetheless. 8)

I must admit that compiling the latest version of Totem (which depends on gtk+-3.0) is a real dependency hell.
Locked

Return to “Beginner Questions”