LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices



Reply
 
Search this Thread
Old 03-02-2012, 12:14 PM   #1
shayno90
Member
 
Registered: Oct 2009
Distribution: Debian Lenny 2.6.26 Ubuntu Lucid Lynx 10.04 Windows 7
Posts: 187
Blog Entries: 2

Rep: Reputation: 21
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?
 
Old 03-02-2012, 02:19 PM   #2
jhwilliams
Senior Member
 
Registered: Apr 2007
Location: Portland, OR
Distribution: Debian, Android, LFS
Posts: 1,168

Rep: Reputation: 208Reputation: 208Reputation: 208
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
 
Old 03-02-2012, 05:05 PM   #3
shayno90
Member
 
Registered: Oct 2009
Distribution: Debian Lenny 2.6.26 Ubuntu Lucid Lynx 10.04 Windows 7
Posts: 187
Blog Entries: 2

Original Poster
Rep: Reputation: 21
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 $@ $<
 
Old 03-02-2012, 06:59 PM   #4
jhwilliams
Senior Member
 
Registered: Apr 2007
Location: Portland, OR
Distribution: Debian, Android, LFS
Posts: 1,168

Rep: Reputation: 208Reputation: 208Reputation: 208
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

Last edited by jhwilliams; 03-02-2012 at 07:04 PM.
 
1 members found this post helpful.
Old 03-05-2012, 07:13 AM   #5
shayno90
Member
 
Registered: Oct 2009
Distribution: Debian Lenny 2.6.26 Ubuntu Lucid Lynx 10.04 Windows 7
Posts: 187
Blog Entries: 2

Original Poster
Rep: Reputation: 21
Quote:
Originally Posted by jhwilliams View Post
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

Last edited by shayno90; 03-05-2012 at 07:16 AM.
 
Old 03-05-2012, 09:32 AM   #6
shayno90
Member
 
Registered: Oct 2009
Distribution: Debian Lenny 2.6.26 Ubuntu Lucid Lynx 10.04 Windows 7
Posts: 187
Blog Entries: 2

Original Poster
Rep: Reputation: 21
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?
 
Old 03-05-2012, 09:47 AM   #7
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen, DK
Distribution: pclos2014.08, Slack14.1 DebWheezy, +50+ other Linux OS, for test only.
Posts: 14,266

Rep: Reputation: 2661Reputation: 2661Reputation: 2661Reputation: 2661Reputation: 2661Reputation: 2661Reputation: 2661Reputation: 2661Reputation: 2661Reputation: 2661Reputation: 2661
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.

.
 
Old 03-05-2012, 03:32 PM   #8
shayno90
Member
 
Registered: Oct 2009
Distribution: Debian Lenny 2.6.26 Ubuntu Lucid Lynx 10.04 Windows 7
Posts: 187
Blog Entries: 2

Original Poster
Rep: Reputation: 21
Quote:
Originally Posted by knudfl View Post
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)
 
Old 03-05-2012, 04:16 PM   #9
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen, DK
Distribution: pclos2014.08, Slack14.1 DebWheezy, +50+ other Linux OS, for test only.
Posts: 14,266

Rep: Reputation: 2661Reputation: 2661Reputation: 2661Reputation: 2661Reputation: 2661Reputation: 2661Reputation: 2661Reputation: 2661Reputation: 2661Reputation: 2661Reputation: 2661
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
 
Old 03-05-2012, 06:55 PM   #10
shayno90
Member
 
Registered: Oct 2009
Distribution: Debian Lenny 2.6.26 Ubuntu Lucid Lynx 10.04 Windows 7
Posts: 187
Blog Entries: 2

Original Poster
Rep: Reputation: 21
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’
 
Old 03-05-2012, 07:27 PM   #11
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen, DK
Distribution: pclos2014.08, Slack14.1 DebWheezy, +50+ other Linux OS, for test only.
Posts: 14,266

Rep: Reputation: 2661Reputation: 2661Reputation: 2661Reputation: 2661Reputation: 2661Reputation: 2661Reputation: 2661Reputation: 2661Reputation: 2661Reputation: 2661Reputation: 2661
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.
 
  


Reply

Tags
install, make, source, ubuntu, xml


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] DBUS -> Expat.h is missing lfs_mm Linux - General 8 11-25-2011 05:05 AM
expat-2.0.1 rpm package jaffd Linux - Software 1 04-01-2010 03:02 PM
APR Installs over Expat! Yerp Linux - Software 0 06-27-2008 09:18 PM
libxml or Expat slzckboy Programming 0 12-25-2005 07:29 PM
expat!!! hhegab Linux - Software 6 07-20-2003 09:46 AM


All times are GMT -5. The time now is 06:09 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration