Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I try to compile (via lualatex) the following MWE without success.

\documentclass[tikz]{standalone}
\usetikzlibrary{graphdrawing}
\usegdlibrary{ogdf}
\begin{document}
\begin{tikzpicture}
  \graph [SugiyamaLayout] { a -- {b,c,d} -- e -- a };
\end{tikzpicture}
\end{document}

I got this message:

! LuaTeX error ...tex/generic/pgf/graphdrawing/lua/pgf/gd/ogdf/library.lua:32: m
odule 'pgf_gd_ogdf_c_ogdf_script' not found:
    no field package.preload['pgf_gd_ogdf_c_ogdf_script']
    [kpse lua searcher] file not found: 'pgf_gd_ogdf_c_ogdf_script'
    [kpse C searcher] file not found: 'pgf_gd_ogdf_c_ogdf_script'
    [oberdiek.luatex.kpse_module_loader]-eroux Search failed
stack traceback:
    [C]: in function 'require'
    ...tex/generic/pgf/graphdrawing/lua/pgf/gd/ogdf/library.lua:32: in main chunk
    [C]: in function 'require'
    [string "\directlua "]:1: in function 'lookup'
    [string "\directlua "]:1: in function 'pgf_lookup_and_require'
    [string "\directlua "]:1: in main chunk.
<argument> ...drawing library '\pgf@temp ' not found}}') end}
                                                   \fi 
l.3 \usegdlibrary{ogdf}

So, how to use OGDF library with TikZ 3.0?

share|improve this question
add comment

2 Answers 2

Too long for a comment. In Section 34 Graph Drawing Algorithms: The Open Graph Drawing Framework, the PGF documentation has a rather discouraging message about this:

Remark: The integration of the ogdf library is still under construction and the examples in this section are more a proof-of-concept. So, use at your own risk.

and then, a few lines below:

Since C++ code is compiled and not interpreted (like Lua), in order to use the present library, you need a compiled version of the pgf interface code for the ogdf library (pgf/gd/ogdf/c/ogdf_script.so) installed correctly for your particular architecture. This is by no means trivial...

So, in order for those examples to work, you need a compiled version of pgf/gd/ogdf/c/ogdf_script.so installed correctly for your particular architecture. How to do that, I wouldn't know... I did a quick search on the web but couldn't find anything really helpful. It really seems to be not a trivial task.

share|improve this answer
    
I compiled the OGDF library and the ogdf_script.so (with dynamic link) on Ubuntu. Now, LuaTeX finds pgf_gd_ogdf_c_ogdf_script.so and the error message changes but I still can not compile the examples. I will continue my tests... –  Paul Gaborit Mar 13 at 14:26
add comment

I was able to compile the example after adding the following line:

\usetikzlibrary{graphs}

so that the complete MWE becomes:

\documentclass[tikz]{standalone}
\usetikzlibrary{graphs}
\usetikzlibrary{graphdrawing}
\usegdlibrary{ogdf}
\begin{document}
\begin{tikzpicture}
  \graph [SugiyamaLayout] { a -- {b,c,d} -- e -- a };
\end{tikzpicture}
\end{document}

If there still is a problem, you could check that there are no missing dependencies in the PGF-OGDF interface library:

ldd PATH_TO/pgf_gd_ogdf_c_ogdf_script.so

The following is a description of what worked for me on Ubuntu 12.04 x86-64.

I used the following software / library versions:

  • PGF 3.0.0
  • OGDF v. 2012.07
  • Lua 5.2.3

Installation

Lua and OGDF

I installed Lua and OGDF from source to a personal, i.e. non-system directory. I followed the standard procedure, except for two adjustment to OGDF:

  1. Adjusted a parameter in makeMakefile.config:

    sharedLib = true
    
  2. Removed -DOGDF_DLL from compiler options in makeMakefile.py. In the diff below, "<" is the original version and ">" the adjusted version:

    85c85
    <       compiler = ' '.join( [compiler, '-DOGDF_DLL -DOGDF_INSTALL' ] )
    ---
    >       compiler = ' '.join( [compiler, '-DOGDF_INSTALL' ] )
    

OGDF interface of PGF

I downloaded and unzipped the TDS archive of PGF from http://www.ctan.org/pkg/pgf .

I created a text file source/generic/pgf/c/config/LocalMakefileConfig.mk with the following contents:

LUAINCLUDES=<LUAPATH>
OGDFINCLUDES=<OGDFPATH>
INSTALLDIR=<TEXBIN>/lib/luatex/lua
MYCFLAGS=-fPIC

Note that <...> must be replaced with the appropriate values:

  • <LUAPATH>, path to lua headers
  • <OGDFPATH>, path to OGDF headers
  • <TEXBIN>, path to TeX binaries

Alas, I could not find a way to make a local config file that would allow a simple make all to complete (because of the order of compiler options in the Makefiles). This left me with two alternatives: edit the Makefiles or compile by hand. I took the latter route.

I ran the following sequence of commands, where <LIBPATH> denotes the location of the Lua and OGDF libraries (.so). Replace it with the appropriate path. Note that -L<LIBPATH> and -rpath=<LIBPATH> are not needed if the libraries have been installed in a standard location. The idea is basically the following:

  1. make all
  2. if (when) there is an error, fix by hand (create a shared object, .so)
  3. if there are other .so files to be made, go to 1

The command sequence:

cd source/generic/pgf/c
make all
cd graphdrawing/pgf/gd/examples/c
gcc -shared SimpleDemoC.o ../../interface/c/InterfaceFromC.o \
  -L<LIBPATH> -Wl,--no-undefined,-rpath=<LIBPATH> \
  -lm -llua -o SimpleDemoC.so
cd ../../../../..
make all
cd graphdrawing/pgf/gd/examples/c
g++ -shared SimpleDemoCPlusPlus.o ../../interface/c/InterfaceFromC++.o \
  ../../interface/c/InterfaceFromC.o -L<LIBPATH> \
  -Wl,--no-undefined,-rpath=<LIBPATH> -llua \
  -o SimpleDemoCPlusPlus.so
cd ../../../../..
make all
cd graphdrawing/pgf/gd/ogdf/c
g++ -shared ../../interface/c/InterfaceFromC.o \
  ../../interface/c/InterfaceFromC++.o InterfaceFromOGDF.o ogdf_script.o \
  -L<LIBPATH> -Wl,--no-undefined,-rpath=<LIBPATH> \
  -pthread -llua -lOGDF -o ogdf_script.so
cd ../../../../..
make all
cd graphdrawing/pgf/gd/ogdf/c
g++ -shared SimpleDemoOGDF.o ../../interface/c/InterfaceFromC++.o \
  ../../interface/c/InterfaceFromC.o InterfaceFromOGDF.o \
  -L<LIBPATH> -Wl,--no-undefined,-rpath=<LIBPATH> \
  -pthread -llua -lOGDF -o SimpleDemoOGDF.so
cd ../../../../..
make install_all

After this, TikZ/PGF should be ready to use the OGDF library.

share|improve this answer
3  
Welcome to TeX.SE! Please consider editing your answer so that it becomes a compilable, stand-alone LaTeX document; doing so will greatly help other reader figure out how and why your code solves the problem reported the OP. –  Mico May 28 at 13:08
1  
Interesting... How did you compile pgf_gd_ogdf_c_ogdf_script.so? –  Paul Gaborit May 28 at 18:03
1  
I edited my answer to show how I compiled the interface and also added a few words about building the OGDF library. –  mvkorpel May 29 at 4:06
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.