fogleman / Craft

A simple Minecraft clone written in C using modern OpenGL (shaders).
http://www.michaelfogleman.com/craft/
MIT License
10.44k stars 1.39k forks source link

Undefine 'create_world' #157

Closed 3dgie closed 9 years ago

3dgie commented 9 years ago

Hello,

I seem to be getting this error when I try to use builder.py

Traceback (most recent call last): File "server.py", line 200, in run self.dequeue() File "server.py", line 208, in dequeue func(_args, _kwargs) File "server.py", line 301, in on_data func(client, args) File "server.py", line 377, in on_block previous = self.get_block(x, y, z) File "server.py", line 274, in get_block return self.get_default_block(x, y, z) File "server.py", line 263, in get_default_block chunk = self.world.get_chunk(p, q) File "/home/ameoba/Craft/world.py", line 44, in get_chunk chunk = self.create_chunk(p, q) File "/home/ameoba/Craft/world.py", line 39, in create_chunk return dll_create_world(p, q) File "/home/ameoba/Craft/world.py", line 18, in dll_create_world dll.create_world(p, q, WORLD_FUNC(world_func), None) File "/usr/lib/python2.7/ctypes/init.py", line 378, in getattr func = self.getitem(name) File "/usr/lib/python2.7/ctypes/init.py", line 383, in getitem func = self._FuncPtr((name_or_ordinal, self)) AttributeError: ./world: undefined symbol: create_world

Am not sure what I am missing. Noone else seemed to have encountered the error before....

fogleman commented 9 years ago

You have to compile the world dll as shown here:

https://github.com/fogleman/Craft/blob/master/world.py#L1-L2

3dgie commented 9 years ago

The problem is there is a .data segment so I have to compile with -fPIC - which results in the initial error.

Error(both with gcc and clang)

Craft$ clang -std=c99 -O3 -shared -o world -I src -I deps/noise deps/noise/noise.c src/world.c /usr/bin/ld: /tmp/noise-459bb6.o: relocation R_X86_64_32S against `.data' can not be used when making a shared object; recompile with -fPIC /tmp/noise-459bb6.o: error adding symbols: Bad value clang: error: linker command failed with exit code 1 (use -v to see invocation)

fogleman commented 9 years ago

What error do you get when you add -fPIC?

3dgie commented 9 years ago

I get the very first error - actually I compiled with -fPIC before I opened this issue

fogleman commented 9 years ago

Not sure what's wrong then.