﻿<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ja">
	<id>https://wiki.blender.jp/index.php?action=history&amp;feed=atom&amp;title=Dev%3A2.4%2FDoc%2FHow_to%2FAdd_PyScripts_Command_Line_Options</id>
	<title>Dev:2.4/Doc/How to/Add PyScripts Command Line Options - 版の履歴</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.blender.jp/index.php?action=history&amp;feed=atom&amp;title=Dev%3A2.4%2FDoc%2FHow_to%2FAdd_PyScripts_Command_Line_Options"/>
	<link rel="alternate" type="text/html" href="https://wiki.blender.jp/index.php?title=Dev:2.4/Doc/How_to/Add_PyScripts_Command_Line_Options&amp;action=history"/>
	<updated>2026-08-03T00:31:38Z</updated>
	<subtitle>このウィキのこのページに関する変更履歴</subtitle>
	<generator>MediaWiki 1.31.0</generator>
	<entry>
		<id>https://wiki.blender.jp/index.php?title=Dev:2.4/Doc/How_to/Add_PyScripts_Command_Line_Options&amp;diff=51752&amp;oldid=prev</id>
		<title>Yamyam: 1版 をインポートしました</title>
		<link rel="alternate" type="text/html" href="https://wiki.blender.jp/index.php?title=Dev:2.4/Doc/How_to/Add_PyScripts_Command_Line_Options&amp;diff=51752&amp;oldid=prev"/>
		<updated>2018-06-28T17:49:55Z</updated>

		<summary type="html">&lt;p&gt;1版 をインポートしました&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;ja&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← 古い版&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;2018年6月28日 (木) 17:49時点における版&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;ja&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(相違点なし)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Yamyam</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.blender.jp/index.php?title=Dev:2.4/Doc/How_to/Add_PyScripts_Command_Line_Options&amp;diff=51751&amp;oldid=prev</id>
		<title>wiki&gt;Brecht: moved Dev:Doc/How to/Add PyScripts Command Line Options to Dev:2.4/Doc/How to/Add PyScripts Command Line Options</title>
		<link rel="alternate" type="text/html" href="https://wiki.blender.jp/index.php?title=Dev:2.4/Doc/How_to/Add_PyScripts_Command_Line_Options&amp;diff=51751&amp;oldid=prev"/>
		<updated>2011-06-15T13:07:38Z</updated>

		<summary type="html">&lt;p&gt;moved &lt;a href=&quot;/Dev:Doc/How_to/Add_PyScripts_Command_Line_Options&quot; class=&quot;mw-redirect&quot; title=&quot;Dev:Doc/How to/Add PyScripts Command Line Options&quot;&gt;Dev:Doc/How to/Add PyScripts Command Line Options&lt;/a&gt; to &lt;a href=&quot;/Dev:2.4/Doc/How_to/Add_PyScripts_Command_Line_Options&quot; title=&quot;Dev:2.4/Doc/How to/Add PyScripts Command Line Options&quot;&gt;Dev:2.4/Doc/How to/Add PyScripts Command Line Options&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新規ページ&lt;/b&gt;&lt;/p&gt;&lt;div&gt;=Adding command line option for python scripts=&lt;br /&gt;
by Kent Mein&lt;br /&gt;
==Introduction==&lt;br /&gt;
This is an incomplete shot at adding a command line option to blender to run a&lt;br /&gt;
python script. This is a hands on sort of thing for going about attacking a specific&lt;br /&gt;
task, mostly focusing on tools talked about in the intro to the source. I'll also&lt;br /&gt;
add a couple more tools to your bag of tricks at the end of the document.&lt;br /&gt;
&lt;br /&gt;
This is based off of the blender-2.28 release to check it out you will want to do&lt;br /&gt;
the following in a directory that does not have a blender subdir: cvs checkout -r&lt;br /&gt;
blender-2-28-release blender (This is assuming you have already logged in to&lt;br /&gt;
the cvs server) While its not the latest and greatest, having a version you can&lt;br /&gt;
checkout and use tools like cvs diff with will be helpful, and this way all of the&lt;br /&gt;
code will match up. Durring the writing of this document the python API was being&lt;br /&gt;
replaced. (You'll see a hint to some of the problems with this later on)&lt;br /&gt;
&lt;br /&gt;
Before you get started with this tutorial you should really try to build blender from&lt;br /&gt;
the 2-28-release and get that working first. It will make your life a lot easier.&lt;br /&gt;
&lt;br /&gt;
Now on with the show...&lt;br /&gt;
&lt;br /&gt;
==Planning==&lt;br /&gt;
Its always a good idea to talk to other people whenever you have questions. Just&lt;br /&gt;
talking to someone else about it will probably give you a better understanding of&lt;br /&gt;
the subject and help you flesh out your ideas. Don't be afraid to talk about things&lt;br /&gt;
with others, you may even answer your own questions while trying to explain your&lt;br /&gt;
ideas to someone else.&lt;br /&gt;
&lt;br /&gt;
The first step is seeing what command line options are already there. So we fire up: &amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
blender -h&lt;br /&gt;
&amp;lt;/source&lt;br /&gt;
-p and -y are already taken so I think I'd like to go with:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
blender -r myscript.py&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So where do we start? We basically have the following tasks:&lt;br /&gt;
&lt;br /&gt;
* find where the command line stuff takes place.&lt;br /&gt;
* add the help to the command line help function.&lt;br /&gt;
* find out how to execute a python script.&lt;br /&gt;
* find out where to execute our python script.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Searching The Code For Command Line Options==&lt;br /&gt;
Ok lets hunt down the command line stuff since thats easy to find: cd&lt;br /&gt;
blender; cscope -R (cscope is a tool I mentioned in the last doc, cscope is&lt;br /&gt;
your friend) I'm going to use cscope to search for something in the -h output.&lt;br /&gt;
So lets search for &amp;quot;Game Engine specific options:&amp;quot; I got line 174 of creator.c&lt;br /&gt;
So lets see if we can find creator.c type: find . -name creator.c -print&lt;br /&gt;
It returns: ./source/creator/creator.c If we didn't know the exact name and or&lt;br /&gt;
capitalization, we could use -iname (case insensitive) and wild cards. so we&lt;br /&gt;
could do something like find . -iname &amp;quot;*tor.c&amp;quot; -print All of the&lt;br /&gt;
following examples would match: FUNtor.c unTor.c creator.c BLAHBlahblahtor.c&lt;br /&gt;
&lt;br /&gt;
Looking through the options in creator.c, I think I'll put the info under Misc&lt;br /&gt;
options: Shoot there is a -R under windows... however looking up further we&lt;br /&gt;
notice there is a -S and a -s so we can use -r and -R were still all right.&lt;br /&gt;
&lt;br /&gt;
I'm adding the following:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
printf (&amp;quot; -r \t\tCall a python script from the command line\n&amp;quot;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The next thing we do is look at the name of this help function and its&lt;br /&gt;
print_help If we look at the code and find where print_help is called, were&lt;br /&gt;
probably pretty close to where we want to add the function to parse our python&lt;br /&gt;
script. So now we have a clue as to where to look to add our functions to&lt;br /&gt;
blender.&lt;br /&gt;
&lt;br /&gt;
Firing up cscope again, this time I'm going to search for where print_help gets&lt;br /&gt;
called: We see its again creator.c line 261 and line 306. If you look at the two&lt;br /&gt;
lines shown by cscope we find the part where we handle Unix and windows style&lt;br /&gt;
help requests. While this may not be quite right, its at least where we will want&lt;br /&gt;
to parse the command line. (We may need to store the location of the python&lt;br /&gt;
script here for later, depending on what has already happened in the code, if&lt;br /&gt;
blender hasn't fully started up yet it might not make sense to call a python&lt;br /&gt;
script if you can't really do anything yet with it, python may not be started yet)&lt;br /&gt;
&lt;br /&gt;
==Writing Functions To Do Our Stuff==&lt;br /&gt;
Now we need to know what to actually do, this is going to take some hunting:&lt;br /&gt;
We could fire up cscope and do some searches for python, Look at the basic&lt;br /&gt;
directory structure, could ask on #blendercoders on IRC, pray or a&lt;br /&gt;
bunch of other things. Again you can find more info on the directory structure&lt;br /&gt;
in the previous document and or the online resources.&lt;br /&gt;
&lt;br /&gt;
There are all kinds of tricks we can use and the more we get to know the code&lt;br /&gt;
the more tricks we'll have to use. The truth is though this part takes some&lt;br /&gt;
work. The first thing to do is to collect all of the data you think you know: That&lt;br /&gt;
could be key words, gui elements, keystrokes/shortcuts, or even tool tips&lt;br /&gt;
comments.&lt;br /&gt;
&lt;br /&gt;
I know current python scripts are in a text window, and they get called with the&lt;br /&gt;
alt-p command. We also know we could use works like python, script,&lt;br /&gt;
text, execute, evaluate, etc...&lt;br /&gt;
&lt;br /&gt;
Because I've played with the source a bit I'm going to let you in on a little&lt;br /&gt;
secret that may or may not be helpful in this case. A great place to start&lt;br /&gt;
looking is in the following files:&lt;br /&gt;
&lt;br /&gt;
* blender/source/blender/src/space.c&lt;br /&gt;
* blender/source/blender/src/toets.c (keys.c in dutch)&lt;br /&gt;
* blender/source/blender/src/toolbox.c&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
looking at those files I easily figure out PKEY is used in the code to denote&lt;br /&gt;
pressing the p key. There is also a file keyval.c that has this info. doing :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
grep PKEY ./source/blender/src/*&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
I get:&lt;br /&gt;
&lt;br /&gt;
* drawtext.c&lt;br /&gt;
* drawview.c&lt;br /&gt;
* editimasel.c&lt;br /&gt;
* editscreen.c&lt;br /&gt;
and a bunch of other stuff.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Looking at drawtext.c I think we have a winner... Looking at the PKEY we have:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
case PKEY:&lt;br /&gt;
                        if (G.qual &amp;amp; LR_ALTKEY) {&lt;br /&gt;
                                if (!BPY_txt_do_python(st)) {&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
I think we want everything in that if statement looking at it.&lt;br /&gt;
&lt;br /&gt;
We probably want to make our own function like print_help in creator.c that&lt;br /&gt;
does this stuff, or the equivalent. If this is the wrong place for it we can move&lt;br /&gt;
it later.&lt;br /&gt;
&lt;br /&gt;
So there is quite a bit of stuff in this bit. Looking at it though we have this call&lt;br /&gt;
to BPY_txt_do_python and a few more things of interest then we have&lt;br /&gt;
this if lineno &amp;gt;=0 which looks like its jumping to the error in the text&lt;br /&gt;
window since we don't have that we can ignore that bit.&lt;br /&gt;
&lt;br /&gt;
So lets start with something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int call_python_script(char *infile) {&lt;br /&gt;
   int lineno;&lt;br /&gt;
   st; /* Need to figure out what we do here were not using a window */&lt;br /&gt;
   char *py_filename;&lt;br /&gt;
&lt;br /&gt;
   if (!BPY_txt_do_python(st)) {&lt;br /&gt;
      lineno = BPY_Err_getLinenumber();&lt;br /&gt;
      py_filename = (char*) BPY_Err_getFilename();&lt;br /&gt;
      if (!strcmp(py_filename, st-&amp;gt;text-&amp;gt;id.name+2)) &lt;br /&gt;
&lt;br /&gt;
        We may or may not need to add a print statement for the error&lt;br /&gt;
        message here, we need to do more research&lt;br /&gt;
        who knows we may even be able to get rid of some of the stuff&lt;br /&gt;
        above like the filename and lineno bit...&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
It still needs some work but were getting somewhere.&lt;br /&gt;
&lt;br /&gt;
Take 2&lt;br /&gt;
&lt;br /&gt;
Before we continue, your probably thinking wow I could never do that,&lt;br /&gt;
this guys not really a beginner he's cheating. So lets try this all again&lt;br /&gt;
from another route. Ok lets start with the directory's Our first choice is&lt;br /&gt;
blender/intern or blender/source The intern dir is mostly for higher level&lt;br /&gt;
little libraries that the blender code uses. Looking at blender/intern/ we&lt;br /&gt;
have a python directory could be promising... Looking at blender/source&lt;br /&gt;
we have to make a couple of more choices: We have to look at a bunch of&lt;br /&gt;
dirs but&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ls -ld */*python*&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
gives us: blender/source/python and blender/source/bpython two more&lt;br /&gt;
promising dirs... We could use grep or cscope in there as well, and just&lt;br /&gt;
search for python. If you do after a little hunting you will also come up&lt;br /&gt;
with BPY_txt_do_python, or as we see further down you might even&lt;br /&gt;
skip over this step so lets go back to where we were.&lt;br /&gt;
&lt;br /&gt;
We need to hunt down&lt;br /&gt;
&lt;br /&gt;
BPY_txt_do_python&lt;br /&gt;
&lt;br /&gt;
using cscope we get:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* BPY_extern.h&lt;br /&gt;
* BPY_main.c&lt;br /&gt;
* BPY_interface.c&lt;br /&gt;
* drawtext.c&lt;br /&gt;
&lt;br /&gt;
Looking at BPY_main.c we could probably get by with setting up a&lt;br /&gt;
dummy SpaceText st and just calling the same function.&lt;br /&gt;
If we look through the function though what we really want is to setup our&lt;br /&gt;
python env and then make a call to BPY_runPython(text, d);&lt;br /&gt;
&lt;br /&gt;
So lets change our function to the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int call_python_script(char *infile) {&lt;br /&gt;
   PyObject* d = NULL;&lt;br /&gt;
   PyObject* ret;&lt;br /&gt;
   Text *text;&lt;br /&gt;
&lt;br /&gt;
   text = &lt;br /&gt;
   d = newGlobalDictionary();&lt;br /&gt;
   ret = BPY_runPython(text, d);&lt;br /&gt;
   if  (!ret) {&lt;br /&gt;
      releaseGlobalDictionary(d);&lt;br /&gt;
      BPY_Err_Handle(text);&lt;br /&gt;
      Py_Finalize();&lt;br /&gt;
      initBPythonInterpreter();&lt;br /&gt;
      return 0;&lt;br /&gt;
   } else {&lt;br /&gt;
      releaseGlobalDictionary(d);&lt;br /&gt;
      Py_DECREF(ret);&lt;br /&gt;
      return 1;&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now all we need to do is figure out how to load our text into a Text object.&lt;br /&gt;
Doing some more hunting with cscope (for &amp;quot;Text &amp;quot;) I came up with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
text = add_text(infile);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Compiling==&lt;br /&gt;
Time to see if our stuff compiles...&lt;br /&gt;
&lt;br /&gt;
The first Error I get is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
../../../blender/source/creator/creator.c:176: `PyObject' undeclared &lt;br /&gt;
(first use in this function)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After a little digging and talking to a python blender developer I learned&lt;br /&gt;
that I need to #include I also need to add a -I to&lt;br /&gt;
blender/source/creator/Makefile.am and blender/source/creator/Makefile&lt;br /&gt;
that includes the system python headers. Of course after editing the&lt;br /&gt;
Makefile.am if your using autotools you need to rerun bootstrap and&lt;br /&gt;
configure.&lt;br /&gt;
&lt;br /&gt;
How do we know this, and what do we include? Well we would know because&lt;br /&gt;
its unable to find Python.h and to find what to include we can look at other&lt;br /&gt;
Makefiles. Cscope doesn't look at the Makefiles so we need to use&lt;br /&gt;
another trick. We could use cscope to find other files that use Python.h and&lt;br /&gt;
look at their makefile(s). Or we could use the following from the root dir:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
grep python `find . -name Makefile -print`&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ok our next error is this one:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
../../../blender/source/creator/creator.c: In function `call_python_script':&lt;br /&gt;
../../../blender/source/creator/creator.c:178: `Text' undeclared &lt;br /&gt;
(first use in this function)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Looks like I need some more include paths and header files.. Using&lt;br /&gt;
cscope to find Text's definition I came up with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;quot;DNA_text_types.h&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now were down to a couple of warnings:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
../../../blender/source/creator/creator.c:180: warning: assignment makes &lt;br /&gt;
pointer from integer without a cast&lt;br /&gt;
&lt;br /&gt;
../../../blender/source/creator/creator.c:182: warning: assignment makes &lt;br /&gt;
pointer from integer without a cast&lt;br /&gt;
&lt;br /&gt;
../../../blender/source/creator/creator.c:183: warning: assignment makes &lt;br /&gt;
pointer from integer without a cast&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A couple of casts and those are easly taken care of.&lt;br /&gt;
&lt;br /&gt;
Now we need to add the part that calls our new function. Lets first look at the&lt;br /&gt;
blender -h output again. We need to model our function call after&lt;br /&gt;
another help function that has a parameter. Lets use : the -p option so&lt;br /&gt;
search for case 'p' we only have one arg So lets add the following after the&lt;br /&gt;
'p' case:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
case 'r':&lt;br /&gt;
   a++;&lt;br /&gt;
   call_python_script(argv[a]);&lt;br /&gt;
   break;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This probably is not the place to put it because we may not want to execute&lt;br /&gt;
python scripts just yet but its a good place for now until we have everything&lt;br /&gt;
compiling. We really need to look at this code and find the proper place to&lt;br /&gt;
do it.&lt;br /&gt;
&lt;br /&gt;
Now after another try and compiling we get the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
source/.libs/libblender_source.al(creator.lo): In function `call_python_script':&lt;br /&gt;
&lt;br /&gt;
../../../blender/source/creator/creator.c:182: undefined reference to &lt;br /&gt;
`newGlobalDictionary'&lt;br /&gt;
&lt;br /&gt;
../../../blender/source/creator/creator.c:183: undefined reference to &lt;br /&gt;
`BPY_runPython'&lt;br /&gt;
&lt;br /&gt;
../../../blender/source/creator/creator.c:192: undefined reference to &lt;br /&gt;
`releaseGlobalDictionary'&lt;br /&gt;
&lt;br /&gt;
../../../blender/source/creator/creator.c:186: undefined reference to &lt;br /&gt;
`releaseGlobalDictionary'&lt;br /&gt;
&lt;br /&gt;
../../../blender/source/creator/creator.c:189: undefined reference to &lt;br /&gt;
`initBPythonInterpreter'&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Looks like we need to fix some of the linking. In general this could&lt;br /&gt;
mean were not including the library that has this stuff defined in it, and&lt;br /&gt;
or its in the wrong spot for the linker.&lt;br /&gt;
&lt;br /&gt;
Its taken me way to long to get this document up on the blender site,&lt;br /&gt;
so I'm going to cut it off here and hopefully there will be a followup down&lt;br /&gt;
the road...&lt;br /&gt;
&lt;br /&gt;
Too Be continued.....&lt;br /&gt;
&lt;br /&gt;
==New Tools==&lt;br /&gt;
Ok I promised I'd introduce a couple of new tools. The first is ldd.&lt;br /&gt;
ldd is used to determine what library's a program is linked against.&lt;br /&gt;
For example Here is some output of running ldd on blender on my system.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
ldd blender &lt;br /&gt;
        libblender_source.so.0 =&amp;gt; /usr/local/blender/lib/libblender_source.so.0 &lt;br /&gt;
        (0x40016000)&lt;br /&gt;
&lt;br /&gt;
        libm.so.6 =&amp;gt; /lib/libm.so.6 (0x40401000)&lt;br /&gt;
        libpthread.so.0 =&amp;gt; /lib/libpthread.so.0 (0x40425000)&lt;br /&gt;
        libgcc_s.so.1 =&amp;gt; /usr/lib/libgcc_s.so.1 (0x4043a000)&lt;br /&gt;
        libc.so.6 =&amp;gt; /lib/libc.so.6 (0x40442000)&lt;br /&gt;
        libblender_intern.so.0 =&amp;gt; /usr/local/blender/lib/libblender_intern.so.0 &lt;br /&gt;
        (0x40567000)&lt;br /&gt;
&lt;br /&gt;
        libGLU.so.1 =&amp;gt; /usr/X11R6/lib/libGLU.so.1 (0x40601000)&lt;br /&gt;
        libGL.so.1 =&amp;gt; /usr/lib/libGL.so.1 (0x4067e000)&lt;br /&gt;
        libopenal.so.0 =&amp;gt; /usr/local/lib/libopenal.so.0 (0x406e5000)&lt;br /&gt;
(there is more thats deleted)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Why is this useful?==&lt;br /&gt;
For starters you can make sure its linking against the correct version&lt;br /&gt;
of libGL. If you have multiple versions on your system you may be&lt;br /&gt;
wondering which version its using. The next tool is nm. Nm is used to&lt;br /&gt;
show the symbols defined in a library or other object file. For example&lt;br /&gt;
here is some of the output on my machine of:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
nm /usr/lib/libc.a &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
init-first.o:&lt;br /&gt;
0000019f t Letext&lt;br /&gt;
         U __close&lt;br /&gt;
         U __environ&lt;br /&gt;
         U __fpu_control&lt;br /&gt;
00000004 C __libc_argc&lt;br /&gt;
00000004 C __libc_argv&lt;br /&gt;
         U __libc_fatal&lt;br /&gt;
         U __libc_init&lt;br /&gt;
00000178 T __libc_init_first&lt;br /&gt;
         U __libc_init_secure&lt;br /&gt;
00000000 D __libc_multiple_libcs&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==What is all of this garbage, and why do I care?==&lt;br /&gt;
each line is a value, type, and symbol. The type and symbol are&lt;br /&gt;
mostly what were interested in. Notice in the above U __libc_init_&lt;br /&gt;
secure means that __libc_init_secure is undefined. and 00000178&lt;br /&gt;
T __libc_init_first means that this library has __libc_init_first defined in&lt;br /&gt;
it, if were using this variable or function this is the library we need to&lt;br /&gt;
link against. Read the man page on nm for information on the various types.&lt;br /&gt;
&lt;br /&gt;
So whenever your getting problems where you have undefined symbol&lt;br /&gt;
BLAH.... you can start going through your library's looking for where&lt;br /&gt;
BLAH is defined. So for example lets say we were having problems finding&lt;br /&gt;
the floor function. well a quick nm /usr/lib/libm.a |grep floor shows us&lt;br /&gt;
thats the library we need to add to our linking line.&lt;br /&gt;
&lt;br /&gt;
So lets say your really lost and have no clue where floor might be found.&lt;br /&gt;
You could always do the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 cd /usr/lib&lt;br /&gt;
 script /tmp/mein.txt&lt;br /&gt;
 foreach i (`find . -type f -print`)&lt;br /&gt;
    echo &amp;quot;Looking at $i&amp;quot;&lt;br /&gt;
    nm $i |grep floor&lt;br /&gt;
    end&lt;br /&gt;
 exit&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then look through /tmp/mein.txt for floor, once you found it scroll up&lt;br /&gt;
to the Looking at line and you've found your library.&lt;br /&gt;
&lt;br /&gt;
[[Category:Script]]&lt;/div&gt;</summary>
		<author><name>wiki&gt;Brecht</name></author>
		
	</entry>
</feed>