compiling mp3splt on Solaris


Before posting the mp3 of the first IOSUG meeting I had to compile up mp3splt in order to split up the mp3 into something a bit more usable. There are one or two little caveats for doing this on Solaris, so for the purposes of documentation these are written up below.

The compilation in this example does not include support for ogg-vorbis, but if people want I'll post an example of this as well. I grabbed libmad from blastwave.org. The short version is here first, and then an explanation of possible errors you may see when trying to compile this or similar software.

Short Version

If you don't have /usr/sfw/bin and /usr/ccs/bin in your path you will need to add them in.
# /opt/csw/bin/pkg-get -i libmad
# LDFLAGS="$LDFLAGS -L/opt/csw/lib -R/opt/csw/lib"; export LDFLAGS
# CFLAGS="-lresolv -lnsl -lsocket"; export CFLAGS
# CPPFLAGS="-I/opt/csw/include -I/usr/include"
# cd ${mp3splt_src}
# ./configure --disable-ogg
# make; make install

Possible Errors

And thats it. Now with a few errors. The first possible error one will encounter is missing header files. In this case libmad is going to be your most likely issue, and you will get errors similar to
[fintanr@charlico mp3splt-2.1c] $ make
make  all-recursive
Making all in doc
if gcc -DHAVE_CONFIG_H       -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DNO_OGG -MT \\ 
   mp3splt.o -MD -MP -MF ".deps/mp3splt.Tpo" \\
  -c -o mp3splt.o `test -f 'mp3splt.c' || echo './'`mp3splt.c; \\
then mv -f ".deps/mp3splt.Tpo" ".deps/mp3splt.Po"; \\
else rm -f ".deps/mp3splt.Tpo"; exit 1; \\
fi
In file included from mp3splt.c:43:
mp3.h:40:17: mad.h: No such file or directory
In file included from mp3splt.c:43:
mp3.h:99: error: field `stream' has incomplete type
mp3.h:100: error: field `frame' has incomplete type
This is resolved with the CPPFLAGS setting above. Next up, and much more common is when you see an error similar to
gcc  -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DNO_OGG  -L/usr/local/lib -R/usr/local/lib \\ 
-L/opt/csw/lib -o mp3splt  mp3splt.o splt.o mp3.o  wrap.o cddb.o ogg.o  -lmad  -lm
Undefined                       first referenced
 symbol                             in file
recv                                cddb.o
send                                cddb.o
herror                              cddb.o
gethostbyname                       cddb.o
socket                              cddb.o
connect                             cddb.o
ld: fatal: Symbol referencing errors. No output written to mp3splt
collect2: ld returned 1 exit status
These errors are all due to missing symbols from the networking libs, so the CFLAGS entry above passes in the correct libs.
Technorati Tag(s) :
Comments:

Strictly speaking you should use:
LIBS="-lresolv -lnsl -lsocket"; export LIBS
(this is a configur(e)ism, (g)make takes LDLIBS)
as you only need the libraries for linking.

The problem is that CFLAGS can be used in places that the -l flag would not be accepted.
CFLAGS is c compiler flags
CXXFLAGS are the c++ compiler flags

CPPFLAGS are preprocessor flags

LDFLAGS is the linker flags
(LD)LIBS are the linker libraries

And remember, the libraries have to follow the .o's that make use of them :)

Posted by Pete on October 14, 2005 at 04:49 AM IST #

Post a Comment:
  • HTML Syntax: NOT allowed
About

fintanr

Search

Archives
« April 2014
MonTueWedThuFriSatSun
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
    
       
Today