LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
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 11-04-2007, 09:24 PM   #1
itsmilesdavis
LQ Newbie
 
Registered: Aug 2005
Location: Western NY
Posts: 5

Rep: Reputation: 0
Expat XML Parser not working


First off, I'm running Ubuntu 7.04

I installed Expat 2.0.1 from
http://sourceforge.net/projects/expat/

'./configure'
and
'sudo make install'

It seemed to install alright. I saw no errors or anything

However, when I try to compile the sample problem from (there is a link to a zip file with the .c files [line.c, etc.])
http://www.xml.com/pub/a/1999/09/exp...ex.html?page=2

All breaks loose:

line.c:21:22: error: xmlparse.h: No such file or directory
line.c:37: error: expected ‘)’ before ‘p’
line.c: In function ‘start_hndl’:
line.c:47: error: ‘XML_Parser’ undeclared (first use in this function)
line.c:47: error: (Each undeclared identifier is reported only once
line.c:47: error: for each function it appears in.)
line.c:47: error: expected ‘)’ before ‘data’
line.c: In function ‘proc_hndl’:
line.c:65: error: ‘XML_Parser’ undeclared (first use in this function)
line.c:65: error: expected ‘)’ before ‘data’
line.c: In function ‘main’:
line.c:70: error: ‘XML_Parser’ undeclared (first use in this function)
line.c:70: error: expected ‘;’ before ‘p’
line.c:71: error: ‘p’ undeclared (first use in this function)
line.c:73: warning: incompatible implicit declaration of built-in function ‘exit’
line.c:87: warning: incompatible implicit declaration of built-in function ‘strlen’
line.c:90: warning: incompatible implicit declaration of built-in function ‘exit’
line.c:97: warning: incompatible implicit declaration of built-in function ‘exit’
line.c:69: warning: return type of ‘main’ is not ‘int’

It would appear that my expat install was unsuccessful? Or, maybe I need to add something to my path? Can anyone off any advice?
 
Old 11-06-2007, 06:01 AM   #2
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 63
Why don't you install from the repositories? Compiling from source is sometimes necessary, but if there is a pre-built package, you should probably use it.

The expat package is found in the universe repository, so you need to enable that and then reload the package list.
  • Open synaptic package manager, go to the Settings menu, select Repositories.
  • Check "community maintained (universe)
  • Close the dialog. You will get a message saying "Repositories changed", click close/OK
  • Click the reload button on the toolbar
  • Search for expat
  • Click the box to the left of the expat package and select "mark for installation". You will probably be told that other packages will also be marked. That's fine, but don't worry if there is no notification.
  • Click apply on the toolbarm, confir, apply in dialog
  • Wait for installation, and close synaptic.
 
Old 11-06-2007, 09:56 PM   #3
itsmilesdavis
LQ Newbie
 
Registered: Aug 2005
Location: Western NY
Posts: 5

Original Poster
Rep: Reputation: 0
Reinstalled expat...still no good.

expat was already installed according to the Repository. I marked for reinstallation and applied it. The reinstall went fine.

However, the code still does not work. Same errors I mentioned from above.

Could something be missing in my path?

echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
 
Old 11-07-2007, 01:36 AM   #4
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 63
Oh I see now. I had mis-understood youd initial post to mean you were trying to build the expat library itself. My apologies - I didn't read as thoroughly as I should have.

The expat package only contains the xmlwf program and attendant files. If you want to build software which uses the expat library, you should install the package libexpat-dev. You will also need the regular development tools. Most of these are provided by the package build-essential. I think you probably have this installed already if you have gcc available.
 
Old 11-07-2007, 02:23 AM   #5
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 63
I looked at the examples in the .zip file from that page. It looks like since they were written the usage of the expat library has changed and the examples will not build.

The libexpat-dev is actually a virtual package which installs libexpat1-dev. If you list the files in this package, you will find these:
Code:
dpkg --listfiles libexpat1-dev |grep example
/usr/share/doc/libexpat1-dev/examples
/usr/share/doc/libexpat1-dev/examples/elements.c
/usr/share/doc/libexpat1-dev/examples/outline.c
/usr/share/doc/libexpat1-dev/examples/elements.dsp.gz
/usr/share/doc/libexpat1-dev/examples/outline.dsp.gz
There is no Makefile, but these samples are trivial to build:
Code:
mkdir $HOME/expat_examples
cd $HOME/expat_examples
cp /usr/share/doc/libexpat1-dev/examples/*.c .
gcc elements.c -lexpat -o elements
gcc outline.c -lexpat -o outline
Hope that helps.
 
Old 11-14-2007, 11:53 AM   #6
itsmilesdavis
LQ Newbie
 
Registered: Aug 2005
Location: Western NY
Posts: 5

Original Poster
Rep: Reputation: 0
more issues

I followed your directions (thank you for taking time with this issue, by the way), but it I'm still having issues.

I have the following packages installed (through Synaptic Package Manager):
expat
libexpat1
libexpat1-dev

(also, build-essential)

I copied the examples you described in the last post, 'elements.c' and 'outline.c'. However, I still have issues.

jr@Deimos:~/Desktop/expat_examples$ cp /usr/share/doc/libexpat1-dev/examples/*.c .
jr@Deimos:~/Desktop/expat_examples$ ls
elements.c outline.c
jr@Deimos:~/Desktop/expat_examples$ gcc elements.c
/tmp/cc0Bi17J.o: In function `main':
elements.c:(.text+0x95): undefined reference to `XML_ParserCreate'
elements.c:(.text+0xbd): undefined reference to `XML_SetUserData'
elements.c:(.text+0xdb): undefined reference to `XML_SetElementHandler'
elements.c:(.text+0x14a): undefined reference to `XML_Parse'
elements.c:(.text+0x15c): undefined reference to `XML_GetCurrentLineNumber'
elements.c:(.text+0x16c): undefined reference to `XML_GetErrorCode'
elements.c:(.text+0x174): undefined reference to `XML_ErrorString'
elements.c:(.text+0x1b9): undefined reference to `XML_ParserFree'
collect2: ld returned 1 exit status
jr@Deimos:~/Desktop/expat_examples$ gcc outline.c
/tmp/ccCL5zbl.o: In function `main':
outline.c:(.text+0xcc): undefined reference to `XML_ParserCreate'
outline.c:(.text+0x121): undefined reference to `XML_SetElementHandler'
outline.c:(.text+0x1bc): undefined reference to `XML_Parse'
outline.c:(.text+0x1cb): undefined reference to `XML_GetErrorCode'
outline.c:(.text+0x1d3): undefined reference to `XML_ErrorString'
outline.c:(.text+0x1e0): undefined reference to `XML_GetCurrentLineNumber'
collect2: ld returned 1 exit status
 
Old 11-18-2007, 12:17 PM   #7
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 63
You forgot the -lexpat option when using gcc.

Also, you do not need to perform a manual link stage invoking ld - gcc will do this for you.

Code:
gcc elements.c -lexpat -o elements
 
  


Reply


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
checking for XML::Parser... configure: error: XML::Parser perl module is required for kornerr Linux - General 11 11-16-2008 07:24 AM
trouble parsing xml encoded in ISO-8859-1 with expat skails22 Programming 2 09-07-2007 05:27 PM
XML Parser... Prada Linux - Software 2 04-17-2007 11:26 AM
XML Parser bulkman Linux - Software 6 04-29-2005 07:01 AM
fontconfig expat xml parse PROBLEMS!! OrganicOrange84 Linux - Software 0 08-18-2004 12:35 PM


All times are GMT -5. The time now is 12:42 AM.

Main Menu
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