trying to compile pike as a library

View: New views
8 Messages — Rating Filter:   Alert me  

trying to compile pike as a library

by Yvan Vander Sanden :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hey.

I am trying to compile pike as a library for embedding in a c++ application.

Using the command "make libpike" i get this error at the end of the process:

Linking libpike.so
/usr/bin/ld: language.o: relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC
language.o: could not read symbols: Bad value
collect2: ld returned 1 exit status
Linking failed:
/home/yvan/Desktop/pike-sourc/bin/smartlink gcc -shared  -L/home/yvan/Desktop/pike-sourc/build/linux-2.6.27-11-generic-x86_64/bundles/lib64 -L/home/yvan/Desktop/pike-sourc/build/linux-2.6.27-11-generic-x86_64/bundles/lib/64 -L/home/yvan/Desktop/pike-sourc/build/linux-2.6.27-11-generic-x86_64/bundles/lib/. -L/usr/lib/gcc/x86_64-linux-gnu/4.3 -R/usr/lib/gcc/x86_64-linux-gnu/4.3 -L/usr/local/lib -R/usr/local/lib -rdynamic -o libpike.so language.o security.o bignum.o pike_cpulib.o interpret.o constants.o cpp.o fdlib.o cyclic.o array.o backend.o callback.o encode.o docode.o dynamic_buffer.o dynamic_load.o error.o fd_control.o fsort.o gc.o hashtable.o lex.o multiset.o signal_handler.o pike_search.o pike_types.o pike_embed.o mapping.o pike_memory.o module_support.o pikecode.o object.o opcodes.o operators.o port.o program.o rbtree.o rusage.o sscanf.o stralloc.o stuff.o threads.o version.o queue.o builtin.o iterators.o facetgroup.o svalue.o las.o builtin_functions.o peep.o tmodule.o /home/yvan/Desktop/pike-sourc/build/linux-2.6.27-11-generic-x86_64/modules/Gmp/module.a -lgmp -L/usr/lib/jvm/java-6-openjdk/jre/lib/amd64 -R/usr/lib/jvm/java-6-openjdk/jre/lib/amd64 -L/usr/lib/jvm/java-6-openjdk/jre/lib/amd64/native_threads -R/usr/lib/jvm/java-6-openjdk/jre/lib/amd64/native_threads -L/usr/lib/jvm/java-6-openjdk/jre/lib/amd64/server -R/usr/lib/jvm/java-6-openjdk/jre/lib/amd64/server modules/Mysql/dummy.o modules/_Image_TIFF/dummy.o /home/yvan/Desktop/pike-sourc/build/linux-2.6.27-11-generic-x86_64/modules/_math/module.a -lm /home/yvan/Desktop/pike-sourc/build/linux-2.6.27-11-generic-x86_64/modules/files/module.a -lnsl /home/yvan/Desktop/pike-sourc/build/linux-2.6.27-11-generic-x86_64/modules/sprintf/module.a /home/yvan/Desktop/pike-sourc/build/linux-2.6.27-11-generic-x86_64/modules/system/module.a -lnsl -ldl -lrt -lnsl -lm -lpthread -lcrypt
make[2]: *** [libpike.so] Error 1
make[1]: *** [_make_in_builddir] Error 2
make: *** [libpike] Error 2

This makes sense, adding fPIC when compiling a library. Normally, I'd add fPIC to the CFLAGS variable, but apparently that is not used in the pike build system. I'm staring at the Makefile for some time now, but have not found yet where to add fPIC. Anyone encountered this before?

Regards,

yvan

--
Copyright only exists in the imagination of those who do not have any.

Re: trying to compile pike as a library

by Bill Welliver :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

CFLAGS should work... you might have to delete your previous build  
from the builds directory for the cached values to be cleared.

Bill

On Oct 17, 2009, at 10:54 AM, Yvan Vander Sanden wrote:

> Hey.
>
> I am trying to compile pike as a library for embedding in a c++  
> application.
>
> Using the command "make libpike" i get this error at the end of the  
> process:
>
> Linking libpike.so
> /usr/bin/ld: language.o: relocation R_X86_64_32 against `a local  
> symbol' can not be used when making a shared object; recompile with  
> -fPIC
> language.o: could not read symbols: Bad value
> collect2: ld returned 1 exit status
> Linking failed:
...

>
>
> This makes sense, adding fPIC when compiling a library. Normally,  
> I'd add fPIC to the CFLAGS variable, but apparently that is not  
> used in the pike build system. I'm staring at the Makefile for some  
> time now, but have not found yet where to add fPIC. Anyone  
> encountered this before?
>
> Regards,
>
> yvan


smime.p7s (5K) Download Attachment

Re: trying to compile pike as a library

by Yvan Vander Sanden :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

mmm, yes. I did try this:

make CFLAGS="-fPIC" libpike

but then gmp.h is not found. I also tried

make CFLAGS="-fPIC" CONFIGUREARGS="--without-bignums --without-gmp" libpike

to no avail.

Then i tried a full build (which works perfectly), copying out the bundles directory from the build, doing a 'make distclean', copying the bundles directory back in and trying: 'make CFLAGS="-fPIC" libpike' once again. This time no complains about a missing gmp.h, but now i'm back to error one:

Making libpike.so in build/linux-2.6.27-11-generic-x86_64
Linking libpike.so
/usr/bin/ld: language.o: relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC
language.o: could not read symbols: Bad value
collect2: ld returned 1 exit status

Only this time i DID use fPIC. I don't see it here. I'm sure my build system is ok. I'm using the latest pike snapshot, and a plain make - make install does give me a working pike. I used make distclean between all things i tried to be sure to start from the beginning.

I sure hope someone has encountered this before, cause i'm completely clueless now :-(

Regards,

yvan


2009/10/17 H. William Welliver III <hww3@...>
CFLAGS should work... you might have to delete your previous build from the builds directory for the cached values to be cleared.

Bill


On Oct 17, 2009, at 10:54 AM, Yvan Vander Sanden wrote:

Hey.

I am trying to compile pike as a library for embedding in a c++ application.

Using the command "make libpike" i get this error at the end of the process:

Linking libpike.so
/usr/bin/ld: language.o: relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC
language.o: could not read symbols: Bad value
collect2: ld returned 1 exit status
Linking failed:
...




This makes sense, adding fPIC when compiling a library. Normally, I'd add fPIC to the CFLAGS variable, but apparently that is not used in the pike build system. I'm staring at the Makefile for some time now, but have not found yet where to add fPIC. Anyone encountered this before?

Regards,

yvan




--
Copyright only exists in the imagination of those who do not have any.

trying to compile pike as a library

by Mirar @ Pike importmöte för mailinglistan :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

The problem seems at least at first glance to be that no one has
tested building libpike on AMD64. This will produce one for you, but
you are almost guarateed to be the first person to try it on AMD64:

  # rm -rf build/
  # export CFLAGS=-fPIC
  # make libpike

Let us know how it works for you.


Re: trying to compile pike as a library

by Yvan Vander Sanden :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks for the help again. It makes sense indeed that 64bit could be untested. For reference, i am working on a ubuntu 9.04 system.

Still, this gives me the Gmp error again. Configure complains that i have no working Gmp installed:

###################################################
## Configuring module: Gmp
## Installation dir:  

checking for C compiler default output... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for executable suffix...
checking for object suffix... (cached) o
checking whether we are using the GNU C compiler... (cached) yes
checking whether /home/yvan/Desktop/pike-sourc/build/linux-2.6.27-11-generic-x86_64/smartlink gcc accepts -g... (cached) yes
checking if we are using TCC (TenDRA C Compiler)... (cached) no
checking if we are using ICC (Intel C Compiler)... (cached) no
checking how to run the C preprocessor... gcc -E
checking for libgcc file name... (cached) /usr/lib/gcc/x86_64-linux-gnu/4.3.3/libgcc.a
checking how to concatenate two symbols... (cached) ANSI
checking for gmp2/gmp.h... no
checking for gmp.h... no
Bundle gmp already installed. Disabled?
configure: error: Cannot compile --with-bignums without the GMP library
It is highly recommended that you install a working GMP
library on your system as that will add features to Pike
required by many applications.  (Such as Roxen) However,
if you know that you do not need GMP, you may re-run configure
with the option --without-bignums instead.
   
configure: error: /bin/sh '/home/yvan/Desktop/pike-sourc/src/modules/Gmp/configure' failed for Gmp
sed: can't read confdefs.h: No such file or directory
configure: error: /home/yvan/Desktop/pike-sourc/src/modules/configure failed for modules
make[1]: *** [configure] Error 1
make: *** [libpike] Error 2

Of course rerunning with --without-bignums doesn't solve it. (And i'd rather have bignums enabled.)

Regards,

yvan

2009/10/18 Peter Bortas @ Pike importmöte för mailinglistan <6341@...>
The problem seems at least at first glance to be that no one has
tested building libpike on AMD64. This will produce one for you, but
you are almost guarateed to be the first person to try it on AMD64:

 # rm -rf build/
 # export CFLAGS=-fPIC
 # make libpike

Let us know how it works for you.




--
Copyright only exists in the imagination of those who do not have any.

Re: trying to compile pike as a library

by Mirar @ Pike importmöte för mailinglistan :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Right. You have no libgmp3-dev installed so Pike compiles the bundled
one for you and installs a static version. I'm running a test build
with that scenario now, but what you could do is remove the installed
bundles and install libgmp3-dev, libnettle-dev and libffi-dev. That
scenario is already was tested on Ubuntu 9.04 AMD64 yesterday and is
known to work.

In the final scenario you probably want libgmp and libnettle compiled
into libpike and libffi (Java bridge glue) disabled. But lets get you
something that builds first and work from there.


Re: trying to compile pike as a library

by Yvan Vander Sanden :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



2009/10/18 Peter Bortas @ Pike importmöte för mailinglistan <6341@...>

In the final scenario you probably want libgmp and libnettle compiled
into libpike and libffi (Java bridge glue) disabled. But lets get you
something that builds first and work from there.

Ok. Got my library now, thanks!

I think i know how to compile without libffi, but will it make such a difference? Not that i need it, but will it cause a slowdown, or why would you want to disable it?


--
Copyright only exists in the imagination of those who do not have any.

Re: trying to compile pike as a library

by Mirar @ Pike importmöte för mailinglistan :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

--without-Java will do it, but no, it won't cause slowdowns or any
problems. If you are not going to be using the Java bridge it will
take up space on disk/flash, but not a whole lot of it.