wedesoft / malloc

Raw memory allocations for Ruby
http://wedesoft.github.com/malloc/
Other
12 stars 2 forks source link

Error at Building native extensions #3

Closed arandilopez closed 7 years ago

arandilopez commented 9 years ago
/usr/bin/ld: ext/init.o: relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
ext/init.o: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
rake aborted!
Command failed with status (1): [g++  -shared -o ext/malloc.so ext/init.o e...]

Tasks: TOP => default => all => ext/malloc.so
(See full trace by running task with --trace)

rake failed, exit code 1

do I need some dependecy to install malloc?

wedesoft commented 9 years ago

Hi sorry for late response. I can't reproduce this here but for some reason "-fPIC" isn't getting passed as compiler option.

daniel-rikowski commented 9 years ago

So is there no solution to this problem?

I encountered the same problem trying to install hornetseye (which looks awesome BTW!)

OS: Fedora 22 x86-64

wedesoft commented 9 years ago

Hi, Thanks. On my system the Ruby configuration contains "-fPIC".

jan@wedemob:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 8.1 (jessie)
Release:        8.1
Codename:       jessie
jan@wedemob:~$ ruby --version
ruby 2.1.5p273 (2014-11-13) [x86_64-linux-gnu]
jan@wedemob:~$ ruby -rrbconfig -e "puts RbConfig::CONFIG['CFLAGS']"
-g -O2 -fstack-protector-strong -Wformat -Werror=format-security -fPIC

CFLAGS are set in /usr/lib/x86_64-linux-gnu/ruby/2.1.0/rbconfig.rb on the current Debian. Maybe this is a bug in Fedora's Ruby version?

daniel-rikowski commented 9 years ago

I checked the flags on various machines. I'm using rbenv to install Ruby from scratch. (Disclaimer: I'm not very familiar with Linux build tools)

All systems have these in common (even on Windows)

-O3 -fno-fast-math -Wall -Wextra -Wno-unused-parameter -Wno-parentheses 
-Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith 
-Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration

Additional flags per system:

CentOS 6 / Ruby 2.1 (rbenv) -ggdb3

CentOS 7 / Ruby 2.1 (rbenv) -ggdb3

Fedora 22 / Ruby 2.2 (rbenv) -ggdb3 -Wdeprecated-declarations -Wno-packed-bitfield-compat

Windows / Ruby 2.2 (RubyInstaller) -g -fno-omit-frame-pointer

If I understand all this I'd have to compile a custom Ruby version in order to use the malloc gem?

wedesoft commented 9 years ago

When building using rbenv, you might have to specify an installation with shared libraries as follows:

CONFIGURE_OPTS=--enable-shared  rbenv install 1.9.3-p194
daniel-rikowski commented 9 years ago

With `--enabled-shared I can install malloc. Thank you!

wedesoft commented 9 years ago

Ok. The other issue can be resolved by installing libswscale-dev on Debian (or the corresponding package under Fedora).

On August 16, 2015 10:09:35 AM GMT+01:00, daniel-rikowski notifications@github.com wrote:

With `--enabled-shared I can install malloc. Thank you!

(Now I am affected by https://github.com/wedesoft/hornetseye-v4l2/issues/1 )


Reply to this email directly or view it on GitHub: https://github.com/wedesoft/malloc/issues/3#issuecomment-131505449

Jan Wedekind http://www.wedesoft.de/

arnoldu commented 7 years ago

I can confirm this behaviour under Ubuntu Xenial. It all boils down to this command failing:

g++ -shared -o ext/malloc.so ext/init.o ext/malloc.o -L/usr/local/lib -Wl,-R -Wl,/usr/local/lib -L/usr/local/lib -lruby-static -L. -fstack-protector -rdynamic -Wl,-export-dynamic -lgmp -lc

with a similar error message :

/usr/bin/ld: ext/init.o: Die Umlagerung von ext/init.o: error adding symbols: Ungültiger Wert collect2: error: ld returned 1 exit status rake aborted!

I have no idea why this isn't working. I can btw compile successfully the same code under Raspberry Pi Debian 8 but want to compile on Ubuntu Xenial.

wedesoft commented 7 years ago

Hi @arnoldu I just tested malloc on a Ubuntu Xenial container and it works as follows:

apt-get update
apt-get install ruby-dev g++
gem install rake
gem install malloc --verbose

You failing command is attempting to link with -lruby-static. This means that the Ruby version you are using was compiled without enabling shared libraries (also see other comments in this thread).

On Ubuntu Xenial the linking statement should rather look like this:

g++  -shared -o ext/malloc.so ext/init.o ext/malloc.o -L/usr/lib -lruby-2.3 -L. -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -fstack-protector -rdynamic -Wl,-export-dynamic -lpthread -lgmp -ldl -lcrypt -lm   -lc
arnoldu commented 7 years ago

Thanks Jan, I got one step further after reinstalling ruby 2.3 completly. But now I encounter this problem when running one of your gems with "gem install hornetseye-*": Whatever gem I want to install on Xenial I get this error:

g++ -DNDEBUG -DHAVE_CONFIG_H -D__STDC_CONSTANT_MACROS -Wdate-time -D_FORTIFY_SOURCE=2 -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/ruby-2.3.0 -I/usr/include/x86_64-linux-gnu/ruby-2.3.0 -I/usr/include/ffmpeg -c -o ext/colourspace.o ext/colourspace.cc ext/colourspace.cc:32:31: error: use of enum ‘PixelFormat’ without previous declaration enum PixelFormat *format,

Do you have a hint, what could this be?

Kind Regards Arnold from Hamburg

wedesoft commented 7 years ago

Hi @arnoldu That is probably hornetseye-ffmpeg. The FFmpeg library has changed again.

Regards Jan

wedesoft commented 7 years ago

@arnoldu sorry, I think that is rather hornetseye-frame. Not sure why that is failing.

wedesoft commented 7 years ago

@arnoldu have you installed libswscale-dev? Also see installation documentation for other packages required.

arnoldu commented 7 years ago

Yep, I double checked and followed the instructions very exactly. I am sure libswscale-dev is installed. What I dont understand is why the sources can't compile using the gcc version 5.4.0 - or have headers changed between various versions of libraries?

wedesoft commented 7 years ago

Hi @arnoldu , It looks like hornetseye-frame was out of date (FFmpeg headers have changed PixelFormat to AVPixelFormat). I just released a new version (hornetseye-frame version 1.1.2) which should install under Ubuntu 16.04 as follows:

apt-get update
apt-get install ruby-dev g++ libboost-dev libswscale-dev
gem install rake
gem install hornetseye-frame

Thanks for reporting the issue.

arnoldu commented 7 years ago

Hi Jan,

sorry to bother you again, but the error is not gone away with hornetsframe 1.1.2 :

Building native extensions. This could take a while... ERROR: Error installing hornetseye-frame: ERROR: Failed to build gem native extension.

 current directory: /var/lib/gems/2.3.0/gems/hornetseye-frame-1.1.2

/usr/bin/ruby2.3 -rubygems /var/lib/gems/2.3.0/gems/rake-12.0.0/exe/rake RUBYARCHDIR=/var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/hornetseye-frame-1.1.2 RUBYLIBDIR=/var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/hornetseye-frame-1.1.2 Please install 'yard' if you want to generate documentation g++ -MM ext/colourspace.cc ext/frame.cc ext/init.cc | sed -e :a -e N -e 's/\n/\$/g' -e ta | sed -e 's/ \\$ / /g' -e 's/\$/\n/g' | sed -e 's/^/ext\//' > .depends.mf g++ -MM ext/colourspace.cc ext/frame.cc ext/init.cc | sed -e :a -e N -e 's/\n/\$/g' -e ta | sed -e 's/ \\$ / /g' -e 's/\$/\n/g' | sed -e 's/^/ext\//' > .depends.mf g++ -DNDEBUG -DHAVE_CONFIG_H -DSTDC_CONSTANT_MACROS -Wdate-time -D_FORTIFY_SOURCE=2 -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/ruby-2.3.0 -I/usr/include/x86_64-linux-gnu/ruby-2.3.0 -I/usr/include/ffmpeg -c -o ext/colourspace.o ext/colourspace.cc ext/colourspace.cc: In function ‘void setupFormat(const string&, int, int, char, AVPixelFormat, uint8_t*, int)’: ext/colourspace.cc:36:15: error: ‘PIX_FMT_GRAY8’ was not declared in this scope format = PIX_FMT_GRAY8; ^ ext/colourspace.cc:40:15: error: ‘PIX_FMT_RGB24’ was not declared in this scope format = PIX_FMT_RGB24; ^ ext/colourspace.cc:44:15: error: ‘PIX_FMT_BGR24’ was not declared in this scope format = PIX_FMT_BGR24; ^ ext/colourspace.cc:48:15: error: ‘PIX_FMT_BGRA’ was not declared in this scope format = PIX_FMT_BGRA; ^ ext/colourspace.cc:52:15: error: ‘PIX_FMT_YUV420P’ was not declared in this scope format = PIX_FMT_YUV420P; ^ ext/colourspace.cc:65:15: error: ‘PIX_FMT_YUV420P’ was not declared in this scope format = PIX_FMT_YUV420P; ^ ext/colourspace.cc:76:15: error: ‘PIX_FMT_YUYV422’ was not declared in this scope format = PIX_FMT_YUYV422; ^ ext/colourspace.cc:82:15: error: ‘PIX_FMT_UYVY422’ was not declared in this scope format = PIX_FMT_UYVY422; ^ rake aborted! Command failed with status (1): [g++ -DNDEBUG -DHAVE_CONFIG_H -DSTDC_CONS...] /var/lib/gems/2.3.0/gems/hornetseye-frame-1.1.2/Rakefile:119:in block in <top (required)>' /var/lib/gems/2.3.0/gems/rake-12.0.0/exe/rake:27:in

' Tasks: TOP => default => all => ext/hornetseye_frame.so => ext/colourspace.o (See full trace by running task with --trace)

rake failed, exit code 1

Gem files will remain installed in /var/lib/gems/2.3.0/gems/hornetseye-frame-1.1.2 for inspection. Results logged to /var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/hornetseye-frame-1.1.2/gem_make.out

Kind regards

Arnold

wedesoft commented 7 years ago

Hi @arnoldu I cannot reproduce the error using an Ubuntu:Xenial container. However I replaced PIXFMT with AV_PIXFMT and updated several Gems. I hope that will help.

arnoldu commented 7 years ago

Hi Jan,

I can confirm that sudo gem install hornetseye-frame works now. An the best: I have not needed to change anything :-)

Am 06.03.2017 um 23:59 schrieb Arnold Ude:

Hi Jan,

sorry to bother you again, but the error is not gone away with hornetsframe 1.1.2 :

Building native extensions. This could take a while... ERROR: Error installing hornetseye-frame: ERROR: Failed to build gem native extension.

current directory: /var/lib/gems/2.3.0/gems/hornetseye-frame-1.1.2

/usr/bin/ruby2.3 -rubygems /var/lib/gems/2.3.0/gems/rake-12.0.0/exe/rake RUBYARCHDIR=/var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/hornetseye-frame-1.1.2 RUBYLIBDIR=/var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/hornetseye-frame-1.1.2 Please install 'yard' if you want to generate documentation g++ -MM ext/colourspace.cc ext/frame.cc ext/init.cc | sed -e :a -e N -e 's/\n/\$/g' -e ta | sed -e 's/ \\$ / /g' -e 's/\$/\n/g' | sed -e 's/^/ext\//' > .depends.mf g++ -MM ext/colourspace.cc ext/frame.cc ext/init.cc | sed -e :a -e N -e 's/\n/\$/g' -e ta | sed -e 's/ \\$ / /g' -e 's/\$/\n/g' | sed -e 's/^/ext\//' > .depends.mf g++ -DNDEBUG -DHAVE_CONFIG_H -DSTDC_CONSTANT_MACROS -Wdate-time -D_FORTIFY_SOURCE=2 -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/ruby-2.3.0 -I/usr/include/x86_64-linux-gnu/ruby-2.3.0 -I/usr/include/ffmpeg -c -o ext/colourspace.o ext/colourspace.cc ext/colourspace.cc: In function ‘void setupFormat(const string&, int, int, char, AVPixelFormat, uint8_t*, int)’: ext/colourspace.cc:36:15: error: ‘PIX_FMT_GRAY8’ was not declared in this scope format = PIX_FMT_GRAY8; ^ ext/colourspace.cc:40:15: error: ‘PIX_FMT_RGB24’ was not declared in this scope format = PIX_FMT_RGB24; ^ ext/colourspace.cc:44:15: error: ‘PIX_FMT_BGR24’ was not declared in this scope format = PIX_FMT_BGR24; ^ ext/colourspace.cc:48:15: error: ‘PIX_FMT_BGRA’ was not declared in this scope format = PIX_FMT_BGRA; ^ ext/colourspace.cc:52:15: error: ‘PIX_FMT_YUV420P’ was not declared in this scope format = PIX_FMT_YUV420P; ^ ext/colourspace.cc:65:15: error: ‘PIX_FMT_YUV420P’ was not declared in this scope format = PIX_FMT_YUV420P; ^ ext/colourspace.cc:76:15: error: ‘PIX_FMT_YUYV422’ was not declared in this scope format = PIX_FMT_YUYV422; ^ ext/colourspace.cc:82:15: error: ‘PIX_FMT_UYVY422’ was not declared in this scope format = PIX_FMT_UYVY422; ^ rake aborted! Command failed with status (1): [g++ -DNDEBUG -DHAVE_CONFIG_H -DSTDC_CONS...] /var/lib/gems/2.3.0/gems/hornetseye-frame-1.1.2/Rakefile:119:in block in <top (required)>' /var/lib/gems/2.3.0/gems/rake-12.0.0/exe/rake:27:in

' Tasks: TOP => default => all => ext/hornetseye_frame.so => ext/colourspace.o (See full trace by running task with --trace)

rake failed, exit code 1

Gem files will remain installed in /var/lib/gems/2.3.0/gems/hornetseye-frame-1.1.2 for inspection. Results logged to /var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/hornetseye-frame-1.1.2/gem_make.out

Kind regards

Arnold

-- Mit freundlichen Grüßen

UDE-Consult GmbH Arnold Ude

wedesoft commented 7 years ago

Hi, Ok, let me know if there are any more problems.

Regards Jan

On 8. März 2017 15:58:59 GMT+00:00, ArnoldU notifications@github.com wrote:

Hi Jan,

I can confirm that sudo gem install hornetseye-frame works now. An the best: I have not needed to change anything :-)

Am 06.03.2017 um 23:59 schrieb Arnold Ude:

Hi Jan,

sorry to bother you again, but the error is not gone away with hornetsframe 1.1.2 :

Building native extensions. This could take a while... ERROR: Error installing hornetseye-frame: ERROR: Failed to build gem native extension.

current directory:

/var/lib/gems/2.3.0/gems/hornetseye-frame-1.1.2 /usr/bin/ruby2.3 -rubygems /var/lib/gems/2.3.0/gems/rake-12.0.0/exe/rake

RUBYARCHDIR=/var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/hornetseye-frame-1.1.2

RUBYLIBDIR=/var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/hornetseye-frame-1.1.2 Please install 'yard' if you want to generate documentation g++ -MM ext/colourspace.cc ext/frame.cc ext/init.cc | sed -e :a -e N -e 's/\n/\$/g' -e ta | sed -e 's/ \\$ / /g' -e 's/\$/\n/g' | sed -e 's/^/ext\//' > .depends.mf g++ -MM ext/colourspace.cc ext/frame.cc ext/init.cc | sed -e :a -e N -e 's/\n/\$/g' -e ta | sed -e 's/ \\$ / /g' -e 's/\$/\n/g' | sed -e 's/^/ext\//' > .depends.mf g++ -DNDEBUG -DHAVE_CONFIG_H -D__STDC_CONSTANT_MACROS -Wdate-time -D_FORTIFY_SOURCE=2 -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/ruby-2.3.0 -I/usr/include/x86_64-linux-gnu/ruby-2.3.0 -I/usr/include/ffmpeg -c -o ext/colourspace.o ext/colourspace.cc ext/colourspace.cc: In function ‘void setupFormat(const string&, int,

int, char, AVPixelFormat, uint8_t*, int)’: ext/colourspace.cc:36:15: error: ‘PIX_FMT_GRAY8’ was not declared in this scope format = PIX_FMT_GRAY8; ^ ext/colourspace.cc:40:15: error: ‘PIX_FMT_RGB24’ was not declared in this scope format = PIX_FMT_RGB24; ^ ext/colourspace.cc:44:15: error: ‘PIX_FMT_BGR24’ was not declared in this scope format = PIX_FMT_BGR24; ^ ext/colourspace.cc:48:15: error: ‘PIX_FMT_BGRA’ was not declared in this scope format = PIX_FMT_BGRA; ^ ext/colourspace.cc:52:15: error: ‘PIX_FMT_YUV420P’ was not declared in this scope format = PIX_FMT_YUV420P; ^ ext/colourspace.cc:65:15: error: ‘PIX_FMT_YUV420P’ was not declared in this scope format = PIX_FMT_YUV420P; ^ ext/colourspace.cc:76:15: error: ‘PIX_FMT_YUYV422’ was not declared in this scope format = PIX_FMT_YUYV422; ^ ext/colourspace.cc:82:15: error: ‘PIX_FMT_UYVY422’ was not declared in this scope format = PIX_FMT_UYVY422; ^ rake aborted! Command failed with status (1): [g++ -DNDEBUG -DHAVE_CONFIG_H -D__STDC_CONS...] /var/lib/gems/2.3.0/gems/hornetseye-frame-1.1.2/Rakefile:119:in block in <top (required)>' /var/lib/gems/2.3.0/gems/rake-12.0.0/exe/rake:27:in

' Tasks: TOP => default => all => ext/hornetseye_frame.so => ext/colourspace.o (See full trace by running task with --trace)

rake failed, exit code 1

Gem files will remain installed in /var/lib/gems/2.3.0/gems/hornetseye-frame-1.1.2 for inspection. Results logged to

/var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/hornetseye-frame-1.1.2/gem_make.out

Kind regards

Arnold

-- Mit freundlichen Grüßen

UDE-Consult GmbH Arnold Ude

  • Geschäftsführer - Schafshagenberg 35 21077 Hamburg Tel. (040) 76 10 30 13

-- You are receiving this because you modified the open/close state. Reply to this email directly or view it on GitHub: https://github.com/wedesoft/malloc/issues/3#issuecomment-285081537

-- Diese Nachricht wurde von meinem Android-Mobiltelefon mit K-9 Mail gesendet.