Welcome to my unobtrusive blog!
By default I blog in english but there is also german content.

libsgml and gcc 4.3.x problem with linking

January 1st, 2009 Posted in english

Today I wanted to compile libsgml 1.1.4 on Ubuntu Intrepid AMD64 and I came across the following error message when I tried to link it:

/usr/bin/ld: DomComment.o: relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC
DomComment.o: could not read symbols: Bad value

So I just did what the error message wanted me to do: I opened ./src/Makefile and modified line 10 so that it looked like:

CFLAGS=${DEBUG} ${INCLUDE} -Wall -O3 -fPIC

I did “make clean” and “make” again which worked this time.

That’s it!

For the guys who are compiling libsgml for “io”, you also have to edit the main Makefile in the root of where you untarred libsgml:

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
31
32
# Generated automatically from Makefile.in by configure.
all:
	cd src && make
	cd examples && make
 
install:
	install -o root -g root --directory /usr/local/include/sgml
	install -m 644 -o root -g root include/Variant.h /usr/local/include/sgml/Variant.h	
	install -m 644 -o root -g root include/DomComment.h /usr/local/include/sgml/DomComment.h
	install -m 644 -o root -g root include/DomDocument.h /usr/local/include/sgml/DomDocument.h
	install -m 644 -o root -g root include/DomElement.h /usr/local/include/sgml/DomElement.h
	install -m 644 -o root -g root include/DomNode.h /usr/local/include/sgml/DomNode.h
	install -m 644 -o root -g root include/DomNodeList.h /usr/local/include/sgml/DomNodeList.h
	install -m 644 -o root -g root include/DomText.h /usr/local/include/sgml/DomText.h
	install -m 644 -o root -g root include/SgmlParser.h /usr/local/include/sgml/SgmlParser.h
	install -m 644 -o root -g root include/SgmlExtensionHtml.h /usr/local/include/sgml/SgmlExtensionHtml.h
	install -m 644 -o root -g root include/SgmlExtensionXml.h /usr/local/include/sgml/SgmlExtensionXml.h
	install -m 644 -o root -g root include/libsgml.h /usr/local/include/sgml/libsgml.h
	install -m 644 -o root -g root libsgml.a /usr/local/lib/libsgml.a
	install -m 644 -o root -g root libsgml.so /usr/local/lib/libsgml.so
 
uninstall:
	rm -rf /usr/local/include/sgml /usr/local/lib/libsgml.a /usr/local/lib/libsgml.so
 
clean:
	cd src && make clean
	cd examples && make clean
 
distclean:
	cd src && make distclean
	cd examples && make distclean
	rm -f config.* Makefile

BUT be careful with that because the paths are hardcoded. It’s kinda odd but if you have installed “io” in /usr instead of /usr/local which is the case for me you have to edit these hardcoded paths as well :). Yep, ligsgml is a big old PITA.

So my Makefile looks like that:

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
31
32
# Generated automatically from Makefile.in by configure.
all:
	cd src && make
	cd examples && make
 
install:
	install -o root -g root --directory /usr/include/sgml
	install -m 644 -o root -g root include/Variant.h /usr/include/sgml/Variant.h	
	install -m 644 -o root -g root include/DomComment.h /usr/include/sgml/DomComment.h
	install -m 644 -o root -g root include/DomDocument.h /usr/include/sgml/DomDocument.h
	install -m 644 -o root -g root include/DomElement.h /usr/include/sgml/DomElement.h
	install -m 644 -o root -g root include/DomNode.h /usr/include/sgml/DomNode.h
	install -m 644 -o root -g root include/DomNodeList.h /usr/include/sgml/DomNodeList.h
	install -m 644 -o root -g root include/DomText.h /usr/include/sgml/DomText.h
	install -m 644 -o root -g root include/SgmlParser.h /usr/include/sgml/SgmlParser.h
	install -m 644 -o root -g root include/SgmlExtensionHtml.h /usr/include/sgml/SgmlExtensionHtml.h
	install -m 644 -o root -g root include/SgmlExtensionXml.h /usr/include/sgml/SgmlExtensionXml.h
	install -m 644 -o root -g root include/libsgml.h /usr/include/sgml/libsgml.h
	install -m 644 -o root -g root libsgml.a /usr/lib/libsgml.a
	install -m 644 -o root -g root libsgml.so /usr/lib/libsgml.so
 
uninstall:
	rm -rf /usr/include/sgml /usr/lib/libsgml.a /usr/lib/libsgml.so
 
clean:
	cd src && make clean
	cd examples && make clean
 
distclean:
	cd src && make distclean
	cd examples && make distclean
	rm -f config.* Makefile

And before you compile “io” do…

cp -R /usr/include/sgml /usr/include/libsgml-1.1.4

…depending on the install location.

If you have any questions, you may ask them here.

follow comments via rss

Post a Comment