HOWTO: Compiling, step by step.

If you are new to YDL and have some more or less basic questions.

HOWTO: Compiling, step by step.

Postby CronoCloud » 18 Feb 2009, 03:57

Sometimes an application you might want to use isn't available in repositories or you might want to run a newer version than what's in the repositories. So what do you do? That's when Linux guru's say, "Use the Source Luke" and tell you to compile it yourself.

Don't worry, compiling is fun and easy. Really, it is.....some of the time, though I admit that some other times it's a pain in the neck.

So what do you need to compile from source on YDL?

1. You need to have installed the Software development packages during installation or by using pirut, but it's very easy to add them with yum:

Code: Select all
yum groupinstall 'Development Tools'


2. You need to setup your build environment properly so it doesn't mess stuff up, that's actually quite easy

2.1: First, edit /etc/ld.so.conf to look like this:
Code: Select all
/usr/local/lib
/usr/local/include
/usr/lib/
/usr/include

include ld.so.conf.d/*.conf


2.2 Add this line to /etc/profile

Code: Select all
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/lib/pkgconfig


2.3 That sets up the build environment and only needs to be done once.

3. Now that the build environment is set up, you can now download all the tarballs you want. What's a tarball? The archive format source code usually comes in. Then you need to know what to do with them once you have them.

3.1 Most of us have a specific spot to put our source tarballs in. I happen to like /usr/src, though probably /usr/local/src would be more "correct"

3.2 Guess what, you get to start using the terminal.... a lot. Compiles are run in the terminal and this is where I usually become root, though only the install step requires being root. So open up your term and move your tarball from where it currently is, usually your /home/user directory to where you want it

Code: Select all
mv tarball  desired_location


3.3 Then change to the directory with your lovely tarball, which for me is /usr/src

Code: Select all
cd /usr/src


3.4 There are basically two kinds of source tarballs, those that are gzip compressed and those that are bzip compressed. You can tell the difference by looking at the suffixes. gzipped tarballs will have gz or tgz suffixes while bzipped ones will have bz or something similar. Bzip is a more efficient compression algorithm so they're a bit smaller.

3.5 Then you get to untar them, turning those nice tarball archives into directories of source code. Since bzip and gzip are different compression methods, you untar them slightly differently.

gzip ones you do:
Code: Select all
tar -xvzf name_of_tarball


bzip ones you do:
Code: Select all
tar -xvjf name_of_tarball


3.6 Then your term spits out a ton of text while it creates your new source directory.

4. Now you have a nice shiny source directory, change into it:

Code: Select all
cd name_of_source_directory


4.1 You can take a look at what's in there with:

Code: Select all
ls


Go ahead, it's fun, I always do it.

4.2 Now you can read the README's and INSTALL info. But people often don't, even I don't some of the time, but I should because sometimes there's specific compile and install instructions that should be followed. I like using less, because less is better than more. Heh.

Code: Select all
less name_of_text_file


You exit out of less by hitting q

4.3 Those readme's and whatnot might tell you what you need to compile your source, additional libraries, optional stuff, etc. But if you're ready, you can go ahead and do the first part of the compile step, configure. That sets up the source for the actual compile, it figures out what libs you have, what compiler you're using what options to use, all sorts of stuff that I don't understand the half of what it means, but it's fun to watch it happening. You do it by:

Code: Select all
./configure


Though you can check out various configure options that you might want to use by:

Code: Select all
./configure --help


You use those options by using arguments with ./configure
Code: Select all
./configure --with-evil --without-sample-function


Why do we use the ./? Because that insures we run the configure script in the directory we're in, not some other directory in our PATH

4.4 Hopefully configure finishes without error messages. If it errors out you get to figure out what went wrong. Usually it's a missing library dependency, requiring either an install of a devel package or a compile of the missing library if it's not in the repos, or not having a new enough library installed. Usually you can slap any error messsages into Google to figure out what you need to do.

4.5 If the configure finished error free, it creates Makefiles and other files too. Makefiles tell make how to "make" the source code into the binary you want. Compiler flags, what libs and headers to include, etc. To run the make, all you do is:
Code: Select all
make


You terminal will begin spitting out tons of output that will look something like:
Code: Select all
gcc -02 blah blah blah blah source.c


That is good. What is bad is if you see something like
Code: Select all
make[2]: *** [all] Error 2

and then see the make quit.

Then you would get to figure out why the compile failed, which usually means slapping error messages into Google. But hopefully the make finishes without errors, which leads to:

4.6 The install step. All make does is make your binary, it doesn't install it. That requires an extra step. This step requires being root.

Code: Select all
make install


Yep, it's that simple. Your terminal will spit out more lines of stuff, showing where it's putting everything. Usually, the binaries will end up in /usr/local/bin

4.7 There's one more step, which is also done as root. Applications often install libraries, as do libraries when you install them. But your applications need to be able to find them, so now we get to tell the linker, ld, where they are, which is:

Code: Select all
ldconfig


Always ldconfig after installs, it'll save you frustration of forgetting to and then not having an application run properly when you try to run it.

5. Now your done and can run your application, or compile some more. Enjoy

Ron Rogers Jr. (CronoCloud)
CECHE01 PS3 (MGS4 80GB Bundle) without OtherOS and with an upgraded 320GB HD
Running Fedora 23 on a Compaq Presario CQ5320F upgraded with a Phenom X4 and GT640
Vizio E221A1 22" 1080P TV with HDMI, using 1080P over HDMI
PSN ID: CronoCloudAuron
User avatar
CronoCloud
Moderator
Moderator
 
Posts: 523
Joined: 21 Oct 2006, 05:48
Location: Central Illinois, USA

Re: HOWTO: Compiling, step by step.

Postby juanito » 18 Feb 2009, 04:25

Very Good - a couple of points:

1. Does listing /usr/include or /usr/local/include in /etc/ld.so.conf actually do anything?
2. You need to be root to run "make install" or "make install-strip" (uses less space)
3. If you're going to compile yourself, you could use compiler flags (CFLAGS, CXXFLAGS) to customise the application especially for the ps3 (-mcpu=cell, -maltivec, etc)
ps3 60gb, cechc04, fw-3.15, ydl-6.2/cblfs multi-lib dual boot
dell 2009w monitor, logitech mediaboard (usb)
juanito
ydl guru
ydl guru
 
Posts: 300
Joined: 30 Jul 2008, 05:30
Location: Dubai, U.A.E.

Re: HOWTO: Compiling, step by step.

Postby CronoCloud » 18 Feb 2009, 04:58

juanito wrote:Very Good - a couple of points:

1. Does listing /usr/include or /usr/local/include in /etc/ld.so.conf actually do anything?


I found it did, back on the PS2, some stuff refused to compile without the two "include" directories in there. Never did figure out why, and I thought, better safe than sorry.

2. You need to be root to run "make install" or "make install-strip" (uses less space)


Yes. I usually become root at the start of the process.

3. If you're going to compile yourself, you could use compiler flags (CFLAGS, CXXFLAGS) to customise the application especially for the ps3 (-mcpu=cell, -maltivec, etc)


There's little source out there with cell optimized code so -mcpu=cell won't help too much. And I've found that most applications that use altivec have a configure script good enough to detect that you have it. I'm also a "reasonable defaults" sort of guy and rarely send additional options to configure scripts (or set CFLAGS or CXXFLAGS) unless I have to.

Ron Rogers Jr. (CronoCloud)
CECHE01 PS3 (MGS4 80GB Bundle) without OtherOS and with an upgraded 320GB HD
Running Fedora 23 on a Compaq Presario CQ5320F upgraded with a Phenom X4 and GT640
Vizio E221A1 22" 1080P TV with HDMI, using 1080P over HDMI
PSN ID: CronoCloudAuron
User avatar
CronoCloud
Moderator
Moderator
 
Posts: 523
Joined: 21 Oct 2006, 05:48
Location: Central Illinois, USA

Re: HOWTO: Compiling, step by step.

Postby sa12257759 » 07 Apr 2009, 21:36

where in /etc/profile should the line be added, I don't know if it matters though it might and I don't wish to mess anything up.
sa12257759
ydl newbie
ydl newbie
 
Posts: 7
Joined: 04 Apr 2009, 17:51

Re: HOWTO: Compiling, step by step.

Postby CronoCloud » 08 Apr 2009, 03:48

sa12257759 wrote:where in /etc/profile should the line be added, I don't know if it matters though it might and I don't wish to mess anything up.


I put it right below this line:
Code: Select all
export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC


Ron Rogers Jr.
CECHE01 PS3 (MGS4 80GB Bundle) without OtherOS and with an upgraded 320GB HD
Running Fedora 23 on a Compaq Presario CQ5320F upgraded with a Phenom X4 and GT640
Vizio E221A1 22" 1080P TV with HDMI, using 1080P over HDMI
PSN ID: CronoCloudAuron
User avatar
CronoCloud
Moderator
Moderator
 
Posts: 523
Joined: 21 Oct 2006, 05:48
Location: Central Illinois, USA

Re: HOWTO: Compiling, step by step.

Postby mojomaster » 22 May 2009, 16:16

OMG !!!! I feel oh so stupid all of a sudden, But I only just jumped in.
Would you class this as "novice" or "intermidiate"

Should I be learning this right off the bat. Wish I had friends who could show me, its nice actually seeing it done there and then. but who said life was easy. Im gonna learn it one way or the other.............

Other...........lol
mojomaster
ydl newbie
ydl newbie
 
Posts: 14
Joined: 21 Mar 2009, 20:19

Re: HOWTO: Compiling, step by step.

Postby CronoCloud » 27 May 2009, 04:53

mojomaster wrote:OMG !!!! I feel oh so stupid all of a sudden, But I only just jumped in.
Would you class this as "novice" or "intermidiate"


Don't feel stupid, I was a Linux beginner too, back in 2002 and at first it was overwhelming to me too.

Compiling from source, I'd consider to be intermediate level stuff on YDL, since a person who uses YDL on a basic desktop level probably doesn't "need" to do it.

Should I be learning this right off the bat. Wish I had friends who could show me, its nice actually seeing it done there and then.


Well I learned how to compile within a week of installing Linux on the PS2 but you don't have to. It's nice to know, just in case you might want to.

Ron Rogers Jr (CronoCloud)
CECHE01 PS3 (MGS4 80GB Bundle) without OtherOS and with an upgraded 320GB HD
Running Fedora 23 on a Compaq Presario CQ5320F upgraded with a Phenom X4 and GT640
Vizio E221A1 22" 1080P TV with HDMI, using 1080P over HDMI
PSN ID: CronoCloudAuron
User avatar
CronoCloud
Moderator
Moderator
 
Posts: 523
Joined: 21 Oct 2006, 05:48
Location: Central Illinois, USA

Re: HOWTO: Compiling, step by step.

Postby ; /\/\ 3 » 21 Oct 2009, 08:34

Thanks for the How-To... makes it seem not sooo complicated. :?
User avatar
; /\/\ 3
ydl newbie
ydl newbie
 
Posts: 5
Joined: 09 Nov 2008, 05:40
Location: greenville, SC USA

Re: HOWTO: Compiling, step by step.

Postby mgschnel » 02 Nov 2009, 01:25

Hello Crono Cloud


I followed all your instructions on compiling, but after I ran the
./configure I got this error message: configure: error: The pkg-config script could not be found or is too old. Make sure it is in your PATH or set the PKG_CONFIG environment variable to the full path to pkg-config. any advice.......... Thanks in advance


Mark
mgschnel
ydl newbie
ydl newbie
 
Posts: 4
Joined: 25 Oct 2009, 01:47

Re: HOWTO: Compiling, step by step.

Postby walnut » 11 Nov 2009, 19:39

I just installed YDL on my PS3. I've been running Ubuntu on my laptop for a couple months, so I'm still pretty inexperienced. I registered here just to say thanks for the well-written how-to for compiling software on YDL. I am on the first step now. I'd like to run htop and couldn't find a package for it. It's a small thing that I could live without, but I prefer it to top and also it'll probably make a good little first-compile project for me. Still, I was surprised it wasn't in the repositories.

Thanks again for the help.
walnut
ydl newbie
ydl newbie
 
Posts: 1
Joined: 11 Nov 2009, 19:32

Re: HOWTO: Compiling, step by step.

Postby juanito » 12 Nov 2009, 06:20

mgschnel wrote:I followed all your instructions on compiling, but after I ran the
./configure I got this error message: configure: error: The pkg-config script could not be found or is too old. Make sure it is in your PATH or set the PKG_CONFIG environment variable to the full path to pkg-config


The first thing to try would be
Code: Select all
$ which pkg-config

If this doesn't come up with something like "/usr/bin/pkg-config", then you probably don't have the "pkg-config" package (and perhaps other development packages) installed.

It also possible to set the PKG_CONFIG_PATH variable like this:
Code: Select all
export PKG_CONFIG_PATH=/usr/lib/pkgconfig:/usr/local/lib/pkgconfig
but I don't think this is the cause of your problem.
ps3 60gb, cechc04, fw-3.15, ydl-6.2/cblfs multi-lib dual boot
dell 2009w monitor, logitech mediaboard (usb)
juanito
ydl guru
ydl guru
 
Posts: 300
Joined: 30 Jul 2008, 05:30
Location: Dubai, U.A.E.

Re: HOWTO: Compiling, step by step.

Postby juanito » 18 Nov 2009, 12:50

It does or does not help?

What did "which pkg-config" give?
ps3 60gb, cechc04, fw-3.15, ydl-6.2/cblfs multi-lib dual boot
dell 2009w monitor, logitech mediaboard (usb)
juanito
ydl guru
ydl guru
 
Posts: 300
Joined: 30 Jul 2008, 05:30
Location: Dubai, U.A.E.

Re: HOWTO: Compiling, step by step.

Postby mgschnel » 24 Nov 2009, 03:46

Hello Ron

I ran the command , which config_package it came back with("/usr/bin/pkg-config")so I guess I am ok.
after I extracted a tar file and open the dir (home/tarball/file) where it is, I run the ./configure. this is where I keep getting the error messages:
configure: error: The pkg-config script could not be found or is too old. Make sure it
is in your PATH or set the PKG_CONFIG environment variable to the full
path to pkg-config.

Alternatively, you may set the environment variables GEGL_CFLAGS
and GEGL_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.


where should I have my path set?


thank in advance, Mark
mgschnel
ydl newbie
ydl newbie
 
Posts: 4
Joined: 25 Oct 2009, 01:47

Re: HOWTO: Compiling, step by step.

Postby sok_linux » 04 Dec 2009, 22:49

I keep getting stuck on the first step. I'm in as root but /etc/ld.so.conf gives me Permission Denied. I tried changing selinux through system-config-securitylevel but not luck.

YDL 6.2 on a PS3

cheers

Update: Fixed it using chmod a+rw ld.so.conf in terminal, then changed it back using chmod u+rwx ld.so.conf
There is only one thing you can do, so do it.
User avatar
sok_linux
ydl newbie
ydl newbie
 
Posts: 18
Joined: 15 Sep 2009, 17:45

Re: HOWTO: Compiling, step by step.

Postby juanito » 06 Dec 2009, 11:25

mgschnel wrote:I ran the command , which config_package it came back with("/usr/bin/pkg-config")so I guess I am ok.
after I extracted a tar file and open the dir (home/tarball/file) where it is, I run the ./configure. this is where I keep getting the error messages:
configure: error: The pkg-config script could not be found or is too old. Make sure it
is in your PATH or set the PKG_CONFIG environment variable to the full
path to pkg-config.


Hmm - I wonder if pkg-config is actually too old - after running ./configure, could you look in config.log and search on "The pkg-config script" to see if it reports that the pkg-config version is too old.
ps3 60gb, cechc04, fw-3.15, ydl-6.2/cblfs multi-lib dual boot
dell 2009w monitor, logitech mediaboard (usb)
juanito
ydl guru
ydl guru
 
Posts: 300
Joined: 30 Jul 2008, 05:30
Location: Dubai, U.A.E.

Next

Return to Beginner

Who is online

Users browsing this forum: No registered users and 7 guests