njsmith / pysrilm

An extremely simple Python wrapper for the SRI Language Modeling toolkit
BSD 2-Clause "Simplified" License
70 stars 20 forks source link

Installation problem #4

Open mdtux89 opened 9 years ago

mdtux89 commented 9 years ago

Hi! I tried installing this on python but when I run the setup script I get this:

/usr/bin/ld: /home/marco/srilm/lib/i686-m64/liboolm.a(Vocab.o): relocation R_X86_64_32 against `_ZSt4cerr' can not be used when making a shared object; recompile with -fPIC /home/marco/srilm/lib/i686-m64/liboolm.a: error adding symbols: Bad value collect2: error: ld returned 1 exit status error: command 'c++' failed with exit status 1

Do you know how to fix this?

njsmith commented 9 years ago

I don't, sorry! It looks like some problem with how you compiled srilm maybe? Pysrilm is a shared library that needs to link against the srilm libraries. The error message there says that your liboolm has been compiled in such a way that it can't be used from shared libraries. If you can find a way to recompile srilm with the -fPIC option then it'll probably work? On 15 Nov 2014 22:57, "Marco Damonte" notifications@github.com wrote:

Hi! I tried installing this on python but when I run the setup script I get this:

/usr/bin/ld: /home/marco/srilm/lib/i686-m64/liboolm.a(Vocab.o): relocation R_X86_64_32 against `_ZSt4cerr' can not be used when making a shared object; recompile with -fPIC /home/marco/srilm/lib/i686-m64/liboolm.a: error adding symbols: Bad value collect2: error: ld returned 1 exit status error: command 'c++' failed with exit status 1

Do you know how to fix this?

— Reply to this email directly or view it on GitHub https://github.com/njsmith/pysrilm/issues/4.

mdtux89 commented 9 years ago

I'll try.. Thanks for the quick reply =) On 16 Nov 2014 01:02, "Nathaniel J. Smith" notifications@github.com wrote:

I don't, sorry! It looks like some problem with how you compiled srilm maybe? Pysrilm is a shared library that needs to link against the srilm libraries. The error message there says that your liboolm has been compiled in such a way that it can't be used from shared libraries. If you can find a way to recompile srilm with the -fPIC option then it'll probably work? On 15 Nov 2014 22:57, "Marco Damonte" notifications@github.com wrote:

Hi! I tried installing this on python but when I run the setup script I get this:

/usr/bin/ld: /home/marco/srilm/lib/i686-m64/liboolm.a(Vocab.o): relocation R_X86_64_32 against `_ZSt4cerr' can not be used when making a shared object; recompile with -fPIC /home/marco/srilm/lib/i686-m64/liboolm.a: error adding symbols: Bad value collect2: error: ld returned 1 exit status error: command 'c++' failed with exit status 1

Do you know how to fix this?

— Reply to this email directly or view it on GitHub https://github.com/njsmith/pysrilm/issues/4.

— Reply to this email directly or view it on GitHub https://github.com/njsmith/pysrilm/issues/4#issuecomment-63199782.

alumae commented 9 years ago

This can be solved by recompiling SRILM using the -fPIC flag. To do this, modify SRILM's common/Makefile.machine.i686-m64 (or appropriate for you system) file and add -fPIC to the following lines like that:

ADDITIONAL_CFLAGS = -fopenmp -fPIC
ADDITIONAL_CXXFLAGS = -fopenmp -fPIC

Then make clean and make World SRILM.

I also had to modify pysrilm's setup.py a little. I you get errors about undefined symbol: gzvprintf, use the following section in pysrilm's setup.py and try again:

setup(
    cmdclass = {'build_ext': build_ext},
    ext_modules = [
      Extension("srilm",
                ["srilm.pyx"],
                language="c++",
                include_dirs=[SRILM_INCLUDE_DIR],
                libraries=["oolm", "dstruct", "misc", "z", "gomp"],
                library_dirs=[SRILM_LIB_DIR],
                extra_compile_args=['-fopenmp', '-fPIC'],
                )
      ],
)

Actually, I think it's more correct than the trunk's version anyway.

mdtux89 commented 9 years ago

Thanks!! On 18 Nov 2014 10:50, "Tanel Alumäe" notifications@github.com wrote:

This can be solved by recompiling SRILM using the -fPIC flag. To do this, modify SRILM's common/Makefile.machine.i686-m64 (or appropriate for you system) file and add -fPIC to the following lines like that:

ADDITIONAL_CFLAGS = -fopenmp -fPIC ADDITIONAL_CXXFLAGS = -fopenmp -fPIC

Then make clean and make World SRILM.

I also had to modify pysrilm's setup.py a little. I you get errors about undefined symbol: gzvprintf, use the following section in pysrilm's setup.py and try again:

setup( cmdclass = {'build_ext': build_ext}, ext_modules = [ Extension("srilm", ["srilm.pyx"], language="c++", include_dirs=[SRILM_INCLUDE_DIR], libraries=["oolm", "dstruct", "misc", "z", "gomp"], library_dirs=[SRILM_LIB_DIR], extra_compile_args=['-fopenmp', '-fPIC'], ) ], )

Actually, I think it's more correct than the trunk's version anyway.

— Reply to this email directly or view it on GitHub https://github.com/njsmith/pysrilm/issues/4#issuecomment-63452522.

PeterBourgonje commented 9 years ago

Thanks a lot! Had the same issue, your solution worked for me!

afshinrahimi commented 8 years ago

Solved my problem as well. Thanks.