LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Install expat-1.2 on Ubuntu 10.04 (https://www.linuxquestions.org/questions/linux-software-2/install-expat-1-2-on-ubuntu-10-04-a-932360/)

shayno90 03-02-2012 11:14 AM

Install expat-1.2 on Ubuntu 10.04
 
I am trying to install expat-1.2 on ubuntu but the make and install of this package is not typical of other installs:

http://www.xml.com/pub/a/1999/09/expat/index.html
Building expat

One of the problems with using expat is that isn't packaged as a library. Instead there are four separate object files that you have to link into your application. The Makefile that builds the sample applications in this article can be used as a template.

The makefile is here:
http://www.xml.com/1999/09/expat/src/Makefile

I need to find out what is the correct way to compile it with gcc and its flags in order to make and install it:

So far I tried this:
user@user:~$ cd expat-1.2/
user@user:~/expat-1.2$ make
gcc -Wall -O2 -Ixmltok -Ixmlparse -DXML_NS -DXML_DTD -c -o xmlwf/xmlwf.o xmlwf/xmlwf.c
gcc -Wall -O2 -Ixmltok -Ixmlparse -DXML_NS -DXML_DTD -c -o xmlwf/xmlfile.o xmlwf/xmlfile.c
gcc -Wall -O2 -Ixmltok -Ixmlparse -DXML_NS -DXML_DTD -c -o xmlwf/codepage.o xmlwf/codepage.c
gcc -Wall -O2 -Ixmltok -Ixmlparse -DXML_NS -DXML_DTD -c -o xmlwf/unixfilemap.o xmlwf/unixfilemap.c
xmlwf/unixfilemap.c: In function ‘filemap’:
xmlwf/unixfilemap.c:36: warning: implicit declaration of function ‘close’
gcc -Wall -O2 -Ixmltok -Ixmlparse -DXML_NS -DXML_DTD -o gennmtab/gennmtab gennmtab/gennmtab.c
rm -f xmltok/nametab.h
gennmtab/gennmtab >xmltok/nametab.h
gcc -Wall -O2 -Ixmltok -Ixmlparse -DXML_NS -DXML_DTD -c -o xmltok/xmltok.o xmltok/xmltok.c
gcc -Wall -O2 -Ixmltok -Ixmlparse -DXML_NS -DXML_DTD -c -o xmltok/xmlrole.o xmltok/xmlrole.c
gcc -Wall -O2 -Ixmltok -Ixmlparse -DXML_NS -DXML_DTD -c -o xmlparse/xmlparse.o xmlparse/xmlparse.c
ar rc xmlparse/libexpat.a xmltok/xmltok.o xmltok/xmlrole.o xmlparse/xmlparse.o
gcc -Wall -O2 -Ixmltok -Ixmlparse -DXML_NS -DXML_DTD -o xmlwf/xmlwf xmlwf/xmlwf.o xmlwf/xmlfile.o xmlwf/codepage.o xmlwf/unixfilemap.o xmlparse/libexpat.a

But I don't think I have installed it in the correct directories.

Attempted with this install but not sure is it correct:
http://glacier.lbl.gov/build_versions.html#Expat

user@user:~/expat-1.2$ make clean
rm -f xmlwf/xmlwf.o xmlwf/xmlfile.o xmlwf/codepage.o xmlwf/unixfilemap.o xmltok/xmltok.o xmltok/xmlrole.o xmlparse/xmlparse.o xmlparse/libexpat.a xmlwf/xmlwf
user@user:~/expat-1.2$ mkdir Linux-x86_64
user@user:~/expat-1.2$ make
gcc -Wall -O2 -Ixmltok -Ixmlparse -DXML_NS -DXML_DTD -c -o xmlwf/xmlwf.o xmlwf/xmlwf.c
gcc -Wall -O2 -Ixmltok -Ixmlparse -DXML_NS -DXML_DTD -c -o xmlwf/xmlfile.o xmlwf/xmlfile.c
gcc -Wall -O2 -Ixmltok -Ixmlparse -DXML_NS -DXML_DTD -c -o xmlwf/codepage.o xmlwf/codepage.c
gcc -Wall -O2 -Ixmltok -Ixmlparse -DXML_NS -DXML_DTD -c -o xmlwf/unixfilemap.o xmlwf/unixfilemap.c
xmlwf/unixfilemap.c: In function ‘filemap’:
xmlwf/unixfilemap.c:36: warning: implicit declaration of function ‘close’
gcc -Wall -O2 -Ixmltok -Ixmlparse -DXML_NS -DXML_DTD -c -o xmltok/xmltok.o xmltok/xmltok.c
gcc -Wall -O2 -Ixmltok -Ixmlparse -DXML_NS -DXML_DTD -c -o xmltok/xmlrole.o xmltok/xmlrole.c
gcc -Wall -O2 -Ixmltok -Ixmlparse -DXML_NS -DXML_DTD -c -o xmlparse/xmlparse.o xmlparse/xmlparse.c
ar rc xmlparse/libexpat.a xmltok/xmltok.o xmltok/xmlrole.o xmlparse/xmlparse.o
gcc -Wall -O2 -Ixmltok -Ixmlparse -DXML_NS -DXML_DTD -o xmlwf/xmlwf xmlwf/xmlwf.o xmlwf/xmlfile.o xmlwf/codepage.o xmlwf/unixfilemap.o xmlparse/libexpat.a
user@user:~/expat-1.2$ mv bin/* lib/* Linux-x86_64
mv: cannot `bin/*' to `stat': No such file or directory
mv: cannot `lib/*' to `stat': No such file or directory

I assume the correct directory should be /usr/bin and /usr/lib but which is the best make and install command for this?

jhwilliams 03-02-2012 01:19 PM

Hi shayno,

The default to install in /usr/local is probably best. This way, you don't mess up the system's copy of libexpat, if that exists.

You need to run make install, after you run make.

If you decide you really do want to put the libs in /usr/lib/, you should configure and deploy like this:

Code:

./configure --prefix=/usr
make
sudo make install


shayno90 03-02-2012 04:05 PM

I corrected the warning issue of:

xmlwf/unixfilemap.c: In function ‘filemap’:
xmlwf/unixfilemap.c:36: warning: implicit declaration of function ‘close’

by adding:
#include <unistd.h>

to:
xmlwf/unixfilemap.c

I don't think you can compile using ./configure as there is no configure file as shown below:

user@user:~/expat-1.2$ ./configure --prefix=/usr
bash: ./configure: No such file or directory

How can I add the prefix with /usr to the make command?

There is only a makefile in the expat-1.2 directory which is below:

CC=gcc
# If you know what your system's byte order is, define XML_BYTE_ORDER:
# use -DXML_BYTE_ORDER=12 for little-endian byte order;
# use -DXML_BYTE_ORDER=21 for big-endian (network) byte order.
# -DXML_NS adds support for checking of lexical aspects of XML namespaces spec
# -DXML_MIN_SIZE makes a smaller but slower parser
# -DXML_DTD adds full support for parsing DTDs
CFLAGS=-Wall -O2 -Ixmltok -Ixmlparse -DXML_NS -DXML_DTD
AR=ar
# Use one of the next two lines; unixfilemap is better if it works.
FILEMAP_OBJ=xmlwf/unixfilemap.o
#FILEMAP_OBJ=xmlwf/readfilemap.o
LIBOBJS=xmltok/xmltok.o \
xmltok/xmlrole.o \
xmlparse/xmlparse.o

OBJS=xmlwf/xmlwf.o \
xmlwf/xmlfile.o \
xmlwf/codepage.o \
$(FILEMAP_OBJ)
LIB=xmlparse/libexpat.a
EXE=
XMLWF=xmlwf/xmlwf$(EXE)

all: $(XMLWF)

$(XMLWF): $(OBJS) $(LIB)
$(CC) $(CFLAGS) -o $@ $(OBJS) $(LIB)

$(LIB): $(LIBOBJS)
$(AR) rc $(LIB) $(LIBOBJS)

clean:
rm -f $(OBJS) $(LIBOBJS) $(LIB) $(XMLWF)

xmltok/nametab.h: gennmtab/gennmtab$(EXE)
rm -f $@
gennmtab/gennmtab$(EXE) >$@

gennmtab/gennmtab$(EXE): gennmtab/gennmtab.c
$(CC) $(CFLAGS) -o $@ gennmtab/gennmtab.c

xmltok/xmltok.o: xmltok/nametab.h

.c.o:
$(CC) $(CFLAGS) -c -o $@ $<

jhwilliams 03-02-2012 05:59 PM

Use the libexpat source linked from their website. I think you're using some weird version.

http://sourceforge.net/projects/expat/

Oh wait, sorry. Unless you really need version 1.2. Do you?

In that case,

Code:

wget ftp://ftp.jclark.com/pub/xml/expat.zip
unzip expat.zip
cd expat
make -j10
sudo install xmlparse/libexpat.a /usr/local/lib/libexpat.a


shayno90 03-05-2012 06:13 AM

Quote:

Originally Posted by jhwilliams (Post 4617195)
Use the libexpat source linked from their website. I think you're using some weird version.

http://sourceforge.net/projects/expat/

Oh wait, sorry. Unless you really need version 1.2. Do you?

No the version I got is from here:

http://glacier.lbl.gov/build_versions.html#Expat

Build: make clean
mkdir Linux-x86_64
make
mv bin/* lib/* Linux-x86_64

However I wanted to attempt to build it before trying the package you referenced in your last post.

I assume I can link the four separate object files into Expat by editing the final line of the build above to:

PWD: /home/user/expat-1.2/ (directory as reference)

mv /usr/bin/* /usr/lib/* Linux-x86_64


This command moves all .bin and .lib files into the new Linxu folder but I am sure the is a simpler way to link the 4 object files of:
xmlwf.o xmlfile.o codepage.o unixfilemap.o

by exporting the environment variable using LD or adding a prefix the C++ compiling?

i.e. http://www.obj-sys.com/docs/xbCCppUGv1p0/XBinder4.html

shayno90 03-05-2012 08:32 AM

Some more information:

"RATS requires expat to be installed in order to build and run. Expat is often installed in /usr/local/lib and /usr/local/include. On some systems, you will need to specify --with-expat-lib and --with-expat-include options to configure so that it can find your installation of the library and header."

There is no configure file in the source package of expat-1.2 so how can the prefixes of --with-expat be added, to the make file or in the install/compile commands?

knudfl 03-05-2012 08:47 AM

Assume rats-2.3 https://www.fortify.com/downloads2/p...ats-2.3.tar.gz

https://www.fortify.com/ssa-elements...ence/rats.html

'rats-2.3' will compile with the system expat :
sudo apt-get install libexpat1-dev
http://packages.ubuntu.com/natty/libexpat1-dev

No reason at all to use an eleven year old expat.

.

shayno90 03-05-2012 02:32 PM

Quote:

Originally Posted by knudfl (Post 4618929)
Assume rats-2.3 https://www.fortify.com/downloads2/p...ats-2.3.tar.gz

https://www.fortify.com/ssa-elements...ence/rats.html

'rats-2.3' will compile with the system expat :
sudo apt-get install libexpat1-dev
http://packages.ubuntu.com/natty/libexpat1-dev

No reason at all to use an eleven year old expat.

.

Seems like I already have it installed:
user@user:~$ sudo apt-get install libexpat1-dev
[sudo] password for shayno90:
Reading package lists... Done
Building dependency tree
Reading state information... Done
libexpat1-dev is already the newest version.
libexpat1-dev set to manually installed.
0 upgraded, 0 newly installed, 0 to remove and 4 not upgraded.

I will try to install RATS now and see if I get any compile errors.

However, I am still interested in finding out what is the correct way to link the 4 files to the application as discussed above,
( --with-expat-lib and --with-expat-include)

knudfl 03-05-2012 03:16 PM

expat-1.2/xmlparse/libexpat.a is made up from 3 object files :
xmlparse.o xmlrole.o xmltok.o
( 'ar -x libexpat.a' will unpack the library.)

Makefile, lines 13 .. 15 :
Code:

LIBOBJS=xmltok/xmltok.o \
  xmltok/xmlrole.o \
  xmlparse/xmlparse.o


shayno90 03-05-2012 05:55 PM

I got the information from:
http://www.xml.com/pub/a/1999/09/expat/index.html

"Building expat

One of the problems with using expat is that isn't packaged as a library. Instead there are four separate object files that you have to link into your application. The Makefile that builds the sample applications in this article can be used as a template."

gcc -Wall -O2 -Ixmltok -Ixmlparse -DXML_NS -DXML_DTD -o xmlwf/xmlwf xmlwf/xmlwf.o xmlwf/xmlfile.o xmlwf/codepage.o xmlwf/unixfilemap.o xmlparse/libexpat.a

Four object files listed from the compile of expat-1.2

In any case I built RATS since lib-expat was already installed but some warnings again with headers:

lex.yyphp.c:10314: warning: ‘yyunput’ defined but not used
lex.yyphp.c:10774: warning: ‘yy_push_state’ defined but not used
lex.yyphp.c:10799: warning: ‘yy_pop_state’ defined but not used
lex.yyphp.c:10807: warning: ‘yy_top_state’ defined but not used

hash.c: In function ‘HashKeys’:
hash.c:96: warning: initialization discards qualifiers from pointer target type

main.c: In function ‘load_database’:
main.c:104: warning: ignoring return value of ‘fread’, declared with attribute warn_unused_result

vuln_db.c: In function ‘ParseVulnDb’:
vuln_db.c:417: warning: format ‘%d’ expects type ‘int’, but argument 4 has type ‘XML_Size’

knudfl 03-05-2012 06:27 PM

Warnings are messages, not really errors.

The lowest "count of warnings" is with gcc-4.5.2, which probably
is about the same age as rats : Only the 4 yy* warnings are present.


All times are GMT -5. The time now is 10:46 PM.