LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-07-2002, 10:05 PM   #1
lackluster
Member
 
Registered: Apr 2002
Location: D.C - USA
Distribution: slackware-current
Posts: 488

Rep: Reputation: 30
Is this a bug?


I'm trying to get XML parsing to work properly.
I tried to compile like so :

Code:
sh-2.05a$ gcc -o xml xml.c `./incxml.sh`
/tmp/ccsuZf4i.o: In function `main':
/tmp/ccsuZf4i.o(.text+0xf): undefined reference to `xmlParseFile'
collect2: ld returned 1 exit status
(a note about the above : incxml.sh looks like this :

Code:
#!/bin/sh

echo "-I/usr/include/libxml2"
)

My {trival} prog is as follows:

Code:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <libxml/xmlmemory.h>
#include <libxml/parser.h>

int main(int argc, char * argv[]) {
	xmlDocPtr xml_doc;

	if (NULL == xmlParseFile("test.xml")) {
		fprintf(stderr, "XML Parsing failed. Quitting......\n");
		exit(1);
	}

	printf("Success!\n");

	exit(0);
}
Is this a bug, or am I doing something incorrectly?
 
Old 07-07-2002, 10:24 PM   #2
crabboy
Senior Member
 
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,821

Rep: Reputation: 121Reputation: 121
You need to include the library name where the 'xmlParseFile' method is defined on the compile line so it can be linked in.
Code:
gcc -o xml -I/usr/include/libxml2 -lxml2 xml.c
I'm guessing the library name...
 
Old 07-08-2002, 12:18 PM   #3
lackluster
Member
 
Registered: Apr 2002
Location: D.C - USA
Distribution: slackware-current
Posts: 488

Original Poster
Rep: Reputation: 30
It just clicked for me . I didn't realize that /tmp/ccsuZf4i.o was my object file for my prog. I thought at first it was just some random object file. Thanks for the input, I'm still getting used to gcc & linux.
 
  


Reply



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
Is this a bug???? CruelEssence Debian 1 06-17-2005 12:11 AM
An old bug.... setlec_seta Mandriva 2 05-19-2005 10:57 PM
Free86 bug or nVidia bug?? ProtoformX Linux - Software 2 05-12-2004 02:38 AM
Is it a bug? swmok Debian 1 04-26-2004 04:26 PM
Bug in vi? ivanatora Slackware 4 10-23-2003 02:57 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:32 AM.

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
Open Source Consulting | Domain Registration