GraphLayout
GraphLayout copied to clipboard
Q: compile error
Hi,
I'm stuck at the compile step. I run the command make
and get
gcc -std=c99 -O3 -shared -o _layout.so layout.c
/usr/bin/ld: /tmp/ccbKpqJX.o: relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/tmp/ccbKpqJX.o: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
make: *** [_layout.so] Error 1
Any advice on how to proceed?
Thanks a lot!
Add the -fPIC
switch and try again.
Thanks for this surprisingly quick response! Yes, I tried make --fPIC
but got make: unrecognized option '--fPIC'
.
I also did gcc -std=c99 -O3 -shared -o _layout.so layout.c -fPIC
which seems to work (I don't know what to do with the other lines of Makefile
). However, if I go to ipython and import layout
, I still get:
Traceback (most recent call last)
<ipython-input-1-ef1e5c67b397> in <module>()
----> 1 import layout
~/GraphLayout/layout.py in <module>()
1 from ctypes import CDLL, CFUNCTYPE, POINTER, Structure, c_float, c_int, byref
2
----> 3 dll = CDLL('_layout.so')
4
5 MAX_EDGES = 128
~/anaconda/lib/python2.7/ctypes/__init__.pyc in __init__(self, name, mode, handle, use_errno, use_last_error)
363
364 if handle is None:
--> 365 self._handle = _dlopen(self._name, mode)
366 else:
367 self._handle = handle
OSError: _layout.so: cannot open shared object file: No such file or directory
Which seems to suggests that the compilation didn't work?
Perhaps I'm looking in the wrong direction,
Thanks!
Yeah, it's a single hyphen.
For the next error, try removing .so
on this line:
https://github.com/fogleman/GraphLayout/blob/master/layout.py#L3
It's a Linux thing...
For the next error, try removing .so on this line: https://github.com/fogleman/GraphLayout/blob/master/layout.py#L3 It's a Linux thing...
I'm on ubuntu indeed. But no this didn't fix it :/
----> 1 import layout
~/GraphLayout/layout.py in <module>()
1 from ctypes import CDLL, CFUNCTYPE, POINTER, Structure, c_float, c_int, byref
2
----> 3 dll = CDLL('_layout')
4
5 MAX_EDGES = 128
~/anaconda/lib/python2.7/ctypes/__init__.pyc in __init__(self, name, mode, handle, use_errno, use_last_error)
363
364 if handle is None:
--> 365 self._handle = _dlopen(self._name, mode)
366 else:
367 self._handle = handle
OSError: _layout: cannot open shared object file: No such file or directory
Might need to rename the _layout.so to _layout too? I have weird issues with the file extensions on Linux.
Still not..