making a C/Python module

Scripting in Blender with Python, and working on the API

Moderators: jesterKing, stiv

Post Reply
fsvieira
Posts: 0
Joined: Tue Dec 18, 2012 2:38 pm

making a C/Python module

Post by fsvieira » Sun Jan 06, 2013 1:26 am

Hi,

I am new to blender and I am trying to figure out how to make a blender C/Python module.
For now I am just trying to make a really simple module in source/blender/python

But when I try to compile it I get this link error (bf_python_navmesh is my lib name):
[100%] Built target bf_python_navmesh
../../lib/libbf_python.a(bpy_interface.c.o):(.data.rel+0x24): undefined reference to `BPyInit_navmesh'
collect2: error: ld returned 1 exit status
make[3]: *** [bin/blender] Error 1
make[2]: *** [source/creator/CMakeFiles/blender.dir/all] Error 2
make[1]: *** [all] Error 2
make: *** [all] Error 2

I alredy put the bf_python_navmesh in the blender/source/creator/CMakeList.txt

but it stills cant find it.
What can I do, or what documentation should I read, thanks in advance.

stiv
Posts: 0
Joined: Tue Aug 05, 2003 7:58 am
Location: 45N 86W

Post by stiv » Sun Jan 06, 2013 3:36 am

Make sure the link command is actually referencing your library.

You might want to check the cmake docs. I *believe* cmake creates a cache that might have to be cleaned/deleted.

fsvieira
Posts: 0
Joined: Tue Dec 18, 2012 2:38 pm

I cleaned my cache but still have the same problem!

Post by fsvieira » Sun Jan 06, 2013 3:20 pm

====
The Error executing make in blender root src folder:


Building C object source/creator/CMakeFiles/blender.dir/buildinfo.c.o
Linking CXX executable ../../bin/blender
../../lib/libbf_python.a(bpy_interface.c.o):(.data.rel+0x24): undefined reference to `BPyInit_navmesh'
collect2: error: ld returned 1 exit status
make[3]: *** [bin/blender] Error 1
make[2]: *** [source/creator/CMakeFiles/blender.dir/all] Error 2
make[1]: *** [all] Error 2
make: *** [all] Error 2


=====
At file /blender/source/creator/CMakeLists.txt I have something like this:

#if(UNIX)
# Sort libraries
set(BLENDER_SORTED_LIBS
...
bf_intern_opennl
bf_python_navmesh
bf_python
bf_python_ext
bf_python_mathutils
bf_python_bmesh
bf_ikplugin
....


=====
At file /blender/source/blenderplayer/CMakeLists.txt I have something like this:

#if(UNIX)
# Sort libraries
set(BLENDER_SORTED_LIBS
...
extern_bullet
bf_python_navmesh
bf_intern_guardedalloc
bf_intern_memutil
bf_python_ext
bf_python_mathutils
bf_python_bmesh
bf_blenlib


====
my module cmake file at /source/blender/python/navmesh/CMakeLists.txt:

set(INC
.
../../blenkernel
../../blenlib
../../makesdna
../../../../intern/guardedalloc
)

set(INC_SYS
${PYTHON_INCLUDE_DIRS}
)

set(SRC
navmesh.cpp
navmesh.h
)

blender_add_lib(bf_python_navmesh "${SRC}" "${INC}" "${INC_SYS}")


====
And source/blender/python/CMakeLists.txt:

add_subdirectory(intern)
add_subdirectory(generic)
add_subdirectory(mathutils)
add_subdirectory(bmesh)
add_subdirectory(navmesh)

fsvieira
Posts: 0
Joined: Tue Dec 18, 2012 2:38 pm

Post by fsvieira » Sun Jan 06, 2013 3:23 pm

stiv wrote:Make sure the link command is actually referencing your library.

You might want to check the cmake docs. I *believe* cmake creates a cache that might have to be cleaned/deleted.
I cleaned the cache but it still give me the same error.

fsvieira
Posts: 0
Joined: Tue Dec 18, 2012 2:38 pm

Patch

Post by fsvieira » Mon Jan 07, 2013 12:49 am

Someone in irc suggested that I should be easy to see my problem with a patch so here it is:

http://fsvieira.com/tmp/cpython_module.diff

Post Reply