can not install ruby-1.8.7-p249 on rvm - ruby

$ rvm install ruby-1.8.7-p249
Installing Ruby from source to: /home/sayuj/.rvm/rubies/ruby-1.8.7-p249, this may take a while depending on your cpu(s)...
ruby-1.8.7-p249 - #fetching
ruby-1.8.7-p249 - #extracted to /home/sayuj/.rvm/src/ruby-1.8.7-p249 (already extracted)
ruby-1.8.7-p249 - #configuring
ruby-1.8.7-p249 - #compiling
ERROR: Error running 'make ', please read /home/sayuj/.rvm/log/ruby-1.8.7-p249/make.log
ERROR: There has been an error while running make. Halting the installation.
EDIT
I use Ubuntu 11.10
$ cat /home/sayuj/.rvm/log/ruby-1.8.7-p249/make.log
[2011-10-17 15:34:49] make
gcc -g -O2 -fPIC -DRUBY_EXPORT -D_GNU_SOURCE=1 -L. -rdynamic -Wl,-export-dynamic main.o libruby-static.a -lrt -ldl -lcrypt -lm -o miniruby
rbconfig.rb updated
gcc -shared -Wl,-soname,libruby.so.1.8 array.o bignum.o class.o compar.o dir.o dln.o enum.o enumerator.o error.o eval.o file.o gc.o hash.o inits.o io.o marshal.o math.o numeric.o object.o pack.o parse.o process.o prec.o random.o range.o re.o regex.o ruby.o signal.o sprintf.o st.o string.o struct.o time.o util.o variable.o version.o dmyext.o -lrt -ldl -lcrypt -lm -o libruby.so.1.8.7
compiling Win32API
compiling bigdecimal
make[1]: Entering directory `/home/sayuj/.rvm/src/ruby-1.8.7-p249/ext/bigdecimal'
gcc -shared -o ../../.ext/x86_64-linux/bigdecimal.so bigdecimal.o -L. -L../.. -L. -rdynamic -Wl,-export-dynamic -Wl,-R -Wl,/home/sayuj/.rvm/rubies/ruby-1.8.7-p249/lib -L/home/sayuj/.rvm/rubies/ruby-1.8.7-p249/lib -lruby -lrt -ldl -lcrypt -lm -lc
make[1]: Leaving directory `/home/sayuj/.rvm/src/ruby-1.8.7-p249/ext/bigdecimal'
compiling curses
make[1]: Entering directory `/home/sayuj/.rvm/src/ruby-1.8.7-p249/ext/curses'
gcc -shared -o ../../.ext/x86_64-linux/curses.so curses.o -L. -L../.. -L. -rdynamic -Wl,-export-dynamic -Wl,-R -Wl,/home/sayuj/.rvm/rubies/ruby-1.8.7-p249/lib -L/home/sayuj/.rvm/rubies/ruby-1.8.7-p249/lib -lruby -lncurses -ltinfo -lrt -ldl -lcrypt -lm -lc
make[1]: Leaving directory `/home/sayuj/.rvm/src/ruby-1.8.7-p249/ext/curses'
compiling dbm
compiling digest
make[1]: Entering directory `/home/sayuj/.rvm/src/ruby-1.8.7-p249/ext/digest'
gcc -shared -o ../../.ext/x86_64-linux/digest.so digest.o -L. -L../.. -L. -rdynamic -Wl,-export-dynamic -Wl,-R -Wl,/home/sayuj/.rvm/rubies/ruby-1.8.7-p249/lib -L/home/sayuj/.rvm/rubies/ruby-1.8.7-p249/lib -lruby -lrt -ldl -lcrypt -lm -lc
cp ../.././ext/digest/digest.h ../../.ext/x86_64-linux
make[1]: Leaving directory `/home/sayuj/.rvm/src/ruby-1.8.7-p249/ext/digest'
compiling digest/bubblebabble
make[1]: Entering directory `/home/sayuj/.rvm/src/ruby-1.8.7-p249/ext/digest/bubblebabble'
gcc -shared -o ../../../.ext/x86_64-linux/digest/bubblebabble.so bubblebabble.o -L. -L../../.. -L. -rdynamic -Wl,-export-dynamic -Wl,-R -Wl,/home/sayuj/.rvm/rubies/ruby-1.8.7-p249/lib -L/home/sayuj/.rvm/rubies/ruby-1.8.7-p249/lib -lruby -lrt -ldl -lcrypt -lm -lc
make[1]: Leaving directory `/home/sayuj/.rvm/src/ruby-1.8.7-p249/ext/digest/bubblebabble'
compiling digest/md5
make[1]: Entering directory `/home/sayuj/.rvm/src/ruby-1.8.7-p249/ext/digest/md5'
gcc -shared -o ../../../.ext/x86_64-linux/digest/md5.so md5init.o md5ossl.o -L. -L../../.. -L. -rdynamic -Wl,-export-dynamic -Wl,-R -Wl,/home/sayuj/.rvm/rubies/ruby-1.8.7-p249/lib -L/home/sayuj/.rvm/rubies/ruby-1.8.7-p249/lib -lruby -lcrypto -lrt -ldl -lcrypt -lm -lc
make[1]: Leaving directory `/home/sayuj/.rvm/src/ruby-1.8.7-p249/ext/digest/md5'
compiling digest/rmd160
make[1]: Entering directory `/home/sayuj/.rvm/src/ruby-1.8.7-p249/ext/digest/rmd160'
gcc -shared -o ../../../.ext/x86_64-linux/digest/rmd160.so rmd160init.o rmd160ossl.o -L. -L../../.. -L. -rdynamic -Wl,-export-dynamic -Wl,-R -Wl,/home/sayuj/.rvm/rubies/ruby-1.8.7-p249/lib -L/home/sayuj/.rvm/rubies/ruby-1.8.7-p249/lib -lruby -lcrypto -lrt -ldl -lcrypt -lm -lc
make[1]: Leaving directory `/home/sayuj/.rvm/src/ruby-1.8.7-p249/ext/digest/rmd160'
compiling digest/sha1
make[1]: Entering directory `/home/sayuj/.rvm/src/ruby-1.8.7-p249/ext/digest/sha1'
gcc -shared -o ../../../.ext/x86_64-linux/digest/sha1.so sha1init.o sha1ossl.o -L. -L../../.. -L. -rdynamic -Wl,-export-dynamic -Wl,-R -Wl,/home/sayuj/.rvm/rubies/ruby-1.8.7-p249/lib -L/home/sayuj/.rvm/rubies/ruby-1.8.7-p249/lib -lruby -lcrypto -lrt -ldl -lcrypt -lm -lc
make[1]: Leaving directory `/home/sayuj/.rvm/src/ruby-1.8.7-p249/ext/digest/sha1'
compiling digest/sha2
make[1]: Entering directory `/home/sayuj/.rvm/src/ruby-1.8.7-p249/ext/digest/sha2'
gcc -shared -o ../../../.ext/x86_64-linux/digest/sha2.so sha2.o sha2init.o -L. -L../../.. -L. -rdynamic -Wl,-export-dynamic -Wl,-R -Wl,/home/sayuj/.rvm/rubies/ruby-1.8.7-p249/lib -L/home/sayuj/.rvm/rubies/ruby-1.8.7-p249/lib -lruby -lrt -ldl -lcrypt -lm -lc
make[1]: Leaving directory `/home/sayuj/.rvm/src/ruby-1.8.7-p249/ext/digest/sha2'
compiling dl
make[1]: Entering directory `/home/sayuj/.rvm/src/ruby-1.8.7-p249/ext/dl'
gcc -shared -o ../../.ext/x86_64-linux/dl.so handle.o ptr.o dl.o sym.o -L. -L../.. -L. -rdynamic -Wl,-export-dynamic -Wl,-R -Wl,/home/sayuj/.rvm/rubies/ruby-1.8.7-p249/lib -L/home/sayuj/.rvm/rubies/ruby-1.8.7-p249/lib -lruby -ldl -lrt -ldl -lcrypt -lm -lc
cp dlconfig.h ../../.ext/x86_64-linux
cp ../.././ext/dl/dl.h ../../.ext/x86_64-linux
make[1]: Leaving directory `/home/sayuj/.rvm/src/ruby-1.8.7-p249/ext/dl'
compiling etc
make[1]: Entering directory `/home/sayuj/.rvm/src/ruby-1.8.7-p249/ext/etc'
gcc -shared -o ../../.ext/x86_64-linux/etc.so etc.o -L. -L../.. -L. -rdynamic -Wl,-export-dynamic -Wl,-R -Wl,/home/sayuj/.rvm/rubies/ruby-1.8.7-p249/lib -L/home/sayuj/.rvm/rubies/ruby-1.8.7-p249/lib -lruby -lrt -ldl -lcrypt -lm -lc
make[1]: Leaving directory `/home/sayuj/.rvm/src/ruby-1.8.7-p249/ext/etc'
compiling fcntl
make[1]: Entering directory `/home/sayuj/.rvm/src/ruby-1.8.7-p249/ext/fcntl'
gcc -shared -o ../../.ext/x86_64-linux/fcntl.so fcntl.o -L. -L../.. -L. -rdynamic -Wl,-export-dynamic -Wl,-R -Wl,/home/sayuj/.rvm/rubies/ruby-1.8.7-p249/lib -L/home/sayuj/.rvm/rubies/ruby-1.8.7-p249/lib -lruby -lrt -ldl -lcrypt -lm -lc
make[1]: Leaving directory `/home/sayuj/.rvm/src/ruby-1.8.7-p249/ext/fcntl'
compiling gdbm
compiling iconv
make[1]: Entering directory `/home/sayuj/.rvm/src/ruby-1.8.7-p249/ext/iconv'
gcc -shared -o ../../.ext/x86_64-linux/iconv.so iconv.o -L. -L../.. -L. -rdynamic -Wl,-export-dynamic -Wl,-R -Wl,/home/sayuj/.rvm/rubies/ruby-1.8.7-p249/lib -L/home/sayuj/.rvm/rubies/ruby-1.8.7-p249/lib -lruby -lrt -ldl -lcrypt -lm -lc
make[1]: Leaving directory `/home/sayuj/.rvm/src/ruby-1.8.7-p249/ext/iconv'
compiling io/wait
make[1]: Entering directory `/home/sayuj/.rvm/src/ruby-1.8.7-p249/ext/io/wait'
gcc -shared -o ../../../.ext/x86_64-linux/io/wait.so wait.o -L. -L../../.. -L. -rdynamic -Wl,-export-dynamic -Wl,-R -Wl,/home/sayuj/.rvm/rubies/ruby-1.8.7-p249/lib -L/home/sayuj/.rvm/rubies/ruby-1.8.7-p249/lib -lruby -lrt -ldl -lcrypt -lm -lc
make[1]: Leaving directory `/home/sayuj/.rvm/src/ruby-1.8.7-p249/ext/io/wait'
compiling nkf
make[1]: Entering directory `/home/sayuj/.rvm/src/ruby-1.8.7-p249/ext/nkf'
gcc -shared -o ../../.ext/x86_64-linux/nkf.so nkf.o -L. -L../.. -L. -rdynamic -Wl,-export-dynamic -Wl,-R -Wl,/home/sayuj/.rvm/rubies/ruby-1.8.7-p249/lib -L/home/sayuj/.rvm/rubies/ruby-1.8.7-p249/lib -lruby -lrt -ldl -lcrypt -lm -lc
make[1]: Leaving directory `/home/sayuj/.rvm/src/ruby-1.8.7-p249/ext/nkf'
compiling openssl
make[1]: Entering directory `/home/sayuj/.rvm/src/ruby-1.8.7-p249/ext/openssl'
gcc -I. -I../.. -I../../. -I../.././ext/openssl -DRUBY_EXTCONF_H=\"extconf.h\" -fPIC -g -O2 -fPIC -c ossl_pkcs7.c
ossl_pkcs7.c: In function ‘ossl_pkcs7si_new’:
ossl_pkcs7.c:89:5: warning: passing argument 2 of ‘ASN1_dup’ from incompatible pointer type [enabled by default]
/usr/include/openssl/asn1.h:955:7: note: expected ‘void * (*)(void **, const unsigned char **, long int)’ but argument is of type ‘char * (*)()’
ossl_pkcs7.c: In function ‘DupPKCS7SignerPtr’:
ossl_pkcs7.c:102:5: warning: passing argument 2 of ‘ASN1_dup’ from incompatible pointer type [enabled by default]
/usr/include/openssl/asn1.h:955:7: note: expected ‘void * (*)(void **, const unsigned char **, long int)’ but argument is of type ‘char * (*)()’
ossl_pkcs7.c: In function ‘ossl_pkcs7ri_new’:
ossl_pkcs7.c:115:5: warning: passing argument 2 of ‘ASN1_dup’ from incompatible pointer type [enabled by default]
/usr/include/openssl/asn1.h:955:7: note: expected ‘void * (*)(void **, const unsigned char **, long int)’ but argument is of type ‘char * (*)()’
ossl_pkcs7.c: In function ‘DupPKCS7RecipientPtr’:
ossl_pkcs7.c:128:5: warning: passing argument 2 of ‘ASN1_dup’ from incompatible pointer type [enabled by default]
/usr/include/openssl/asn1.h:955:7: note: expected ‘void * (*)(void **, const unsigned char **, long int)’ but argument is of type ‘char * (*)()’
ossl_pkcs7.c: At top level:
ossl_pkcs7.c:573:1: error: unknown type name ‘STACK’
ossl_pkcs7.c: In function ‘pkcs7_get_certs_or_crls’:
ossl_pkcs7.c:593:15: warning: assignment from incompatible pointer type [enabled by default]
ossl_pkcs7.c:596:31: warning: pointer type mismatch in conditional expression [enabled by default]
ossl_pkcs7.c: In function ‘ossl_pkcs7_set_certificates’:
ossl_pkcs7.c:611:11: warning: assignment from incompatible pointer type [enabled by default]
ossl_pkcs7.c: In function ‘ossl_pkcs7_get_certificates’:
ossl_pkcs7.c:621:5: warning: passing argument 1 of ‘ossl_x509_sk2ary’ from incompatible pointer type [enabled by default]
ossl.h:121:7: note: expected ‘struct stack_st_X509 *’ but argument is of type ‘int *’
ossl_pkcs7.c: In function ‘ossl_pkcs7_set_crls’:
ossl_pkcs7.c:651:10: warning: assignment from incompatible pointer type [enabled by default]
ossl_pkcs7.c: In function ‘ossl_pkcs7_get_crls’:
ossl_pkcs7.c:661:5: warning: passing argument 1 of ‘ossl_x509crl_sk2ary’ from incompatible pointer type [enabled by default]
ossl.h:122:7: note: expected ‘struct stack_st_X509_CRL *’ but argument is of type ‘int *’
make[1]: *** [ossl_pkcs7.o] Error 1
make[1]: Leaving directory `/home/sayuj/.rvm/src/ruby-1.8.7-p249/ext/openssl'
make: *** [all] Error 1
How can I fix this?

From here : http://ahmy.yulrizka.com/2011/10/ruby-ree-1-8-7-openssl-error/
rvm pkg install openssl
And from one of the answers here: https://stackoverflow.com/a/8544958/178975
rvm install ruby-1.8.7 --with-openssl-dir=<rvm_dir>/usr
where rvm_dir could be $HOME/.rvm or /usr/local/rvm or wherever you have installed rvm

Looks like the problem is:
ossl_pkcs7.c:573:1: error: unknown type name ‘STACK’
My guess is its a dependancy issue.
Look at the output of:
rvm notes
And ensure you have followed all the steps for Ubuntu.
One obvious thing is that Ubuntu 11.10 is only just out - might be worth searching/posting on the Ubuntu forums to see if anyone there has had any issues with it and rvm.

Be sure to install ruby with rvm and giving the open-ssl-dir explicitly like this:
rvm cleanup
rvm install ruby-1.8.7 --with-openssl-dir=$HOME/.rvm/usr

Related

Understanding error from ld "archive member is not mach-o or llvm bitcode file"

I'm getting the following error when trying to link a code on a Mac (Montery). First let me say that up until a recent upgrade to Xcode the code built fine. GCC is 10, OpenMPI and it's a Fortran code. Now there are multiple executables which build and one libaray. The library compiles fine and is archived via ar (ar -ruvs). For example, here's a compile and build line for a code.
mpif90 -O2 -g -fexternal-blas -fbacktrace -fcheck=all,no-array-temps -fallow-argument-mismatch -I../../LIBSTELL/Release -I/opt/local/include -I. -c ../Sources/boozer_coords.f
mpif90 -shared -Wl,-no_compact_unwind -O2 -g -fexternal-blas -fbacktrace -fcheck=all,no-array-temps -fallow-argument-mismatch -I../../LIBSTELL/Release -I/opt/local/include -o xbooz_xform booz_jac.o read_wout_booz.o foranl.o allocate_boozer.o transpmn.o boozer_xform.o setup_booz.o write_boozmn.o harfun.o trigfunc.o booz_params.o vcoords.o boozer.o free_mem_boozer.o boozer_coords.o booz_persistent.o ../../LIBSTELL/Release/libstell.a -L/usr/lib -L/opt/local/lib -lopenblas -lscalapack -L/opt/local/lib -lnetcdf -lnetcdff -L/opt/local/lib -lfftw3 -L/opt/local/lib -lhdf5hl_fortran -lhdf5_hl -lhdf5_fortran -lhdf5 -lz -ldl -lm
This works fine and produces an executable. However, there is another code which links to this code. For that reason archives are made of the compiled code.
mpif90 -ffree-form -ffree-line-length-none -ffixed-line-length-none -O2 -g -fexternal-blas -fbacktrace -fcheck=all,no-array-temps -fallow-argument-mismatch -I../../LIBSTELL/Release -I../../BOOTSJ/Release -I/opt/local/include -I/opt/local/include -I. -c ../Sources/thrift_main.f90
mpif90 -shared -Wl,-no_compact_unwind -O2 -g -fexternal-blas -fbacktrace -fcheck=all,no-array-temps -fallow-argument-mismatch -I../../LIBSTELL/Release -I/opt/local/include -o xthrift thrift_interface_mod.o thrift_runtime.o thrift_main.o ../../BOOTSJ/Release/libbootsj.a ../../LIBSTELL/Release/libstell.a -L/usr/lib -L/opt/local/lib -lopenblas -lscalapack -L/opt/local/lib -lnetcdf -lnetcdff -L/opt/local/lib -lfftw3 -L/opt/local/lib -lhdf5hl_fortran -lhdf5_hl -lhdf5_fortran -lhdf5 -lz -ldl -lm
ld: in ../../BOOTSJ/Release/libbootsj.a(parambs.mod), archive member 'parambs.mod' with length 2800 is not mach-o or llvm bitcode file '../../BOOTSJ/Release/libbootsj.a' for architecture x86_64
collect2: error: ld returned 1 exit status
I've had limited success trying to understand the source of this error. Here's what the table for the archive looks like.
ar -t ../BOOTSJ/Release/libbootsj.a
__.SYMDEF SORTED
SIMPUN.o
al31.o
allocate_angles.o
allocate_radial.o
bongrid.o
bootsj.o
caprsh2.o
datain.o
deallocate_all.o
denmf.o
do_fft.o
driver.o
fraction.o
grad.o
othersums.o
output.o
parambs.o
positiv.o
read_boozer.o
reorganz.o
smooth1.o
sumit.o
temp.o
tok_fraction.o
trig.o
vmec0.o
woflam.o
parambs.mod
trig.mod
vmec0.mod
OK so I was adding the module files (.mod) to the archive. This was incorrect. Only the Object (.o) files should be in the archive.
If I understand correctly the compiler will use the -I <path> command to look for (.mod) files. So the archive only needs the object files.

"ld: library not found for -lc" in mac big sur

I try to writed a redis module by clone the git project https://github.com/RedisLabs/RedisModulesSDK.git
and type the "Make" command in my mac with big sur version, below message display in the console.
But there is a error "ld: library not found for -lc".
How to fix it. I try the same command in a linux os, it works find.
gcc -g -fPIC -O3 -std=gnu99 -Wall -Wno-unused-function -I../ -c -o util.o util.c
gcc -g -fPIC -O3 -std=gnu99 -Wall -Wno-unused-function -I../ -c -o strings.o strings.c
gcc -g -fPIC -O3 -std=gnu99 -Wall -Wno-unused-function -I../ -c -o sds.o sds.c
gcc -g -fPIC -O3 -std=gnu99 -Wall -Wno-unused-function -I../ -c -o vector.o vector.c
gcc -g -fPIC -O3 -std=gnu99 -Wall -Wno-unused-function -I../ -c -o alloc.o alloc.c
gcc -g -fPIC -O3 -std=gnu99 -Wall -Wno-unused-function -I../ -c -o periodic.o periodic.c
ar rcs librmutil.a util.o strings.o sds.o vector.o alloc.o periodic.o
gcc -I../ -Wall -g -fPIC -lc -lm -std=gnu99 -c -o module.o module.c
clang: warning: -lc: 'linker' input unused [-Wunused-command-line-argument]
clang: warning: -lm: 'linker' input unused [-Wunused-command-line-argument]
ld -o module.so module.o -bundle -undefined dynamic_lookup -v -L../rmutil -lrmutil -lc
#(#)PROGRAM:ld PROJECT:ld64-609.8
BUILD 15:07:46 Dec 18 2020
configured to support archs: armv6 armv7 armv7s arm64 arm64e arm64_32 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em
Library search paths:
../rmutil
/usr/lib
/usr/local/lib
Framework search paths:
/Library/Frameworks/
/System/Library/Frameworks/
ld: library not found for -lc
make[1]: *** [module.so] Error 1
make: *** [module.so] Error 2
To prevent this error on 11.x+: ld: library not found for -lc
the path /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib needs to be added with -L
https://github.com/macports/macports-ports/commit/0a780d32e0ae3997ed2f2d611cee604d1476cdb5

Compile Error Boost library undefined reference to `shm_open'

I can't compile my project.
When I run make command I get the following error.
If I try compile shareMemoryWriter.cpp alone with command
g++ -std=c++11 shareMemoryWriter.cpp main2.cpp -o main -lpthread -lrt
the compile succeed
operating system: linux mint
Makefile:
CC = g++
CFLAGS=-Wall -g -std=c++11 -lpthread -lrt
LDFLAGS= -std=c++11 -lpthread -lrt
SOURCES=main.cpp \
daq.cpp \
srs.cpp \
fec.cpp \
chip.cpp \
detector.cpp \
chamber.cpp \
chamberSpecs.cpp \
multilayer.cpp \
layer.cpp \
readout.cpp \
connector.cpp \
connectorSpecs.cpp \
createEvents.cpp \
event.cpp \
shareMemoryWriter.cpp \
Coordinates.cpp
OBJECTS=$(SOURCES:.cpp=.o)
EXECUTABLE=main
all: $(SOURCES) $(EXECUTABLE)
$(EXECUTABLE): $(OBJECTS)
$(CC) $(LDFLAGS) $(OBJECTS) -o $#
.cpp.o:
$(CC) $(CFLAGS) -c $< -o $#
clean:
$(RM) *.o *~ $(MAIN)
depend: $(SRCS)
makedepend $^
Make compile output:
make
g++ -Wall -g -std=c++11 -lpthread -lrt -c main.cpp -o main.o
g++ -Wall -g -std=c++11 -lpthread -lrt -c daq.cpp -o daq.o
g++ -Wall -g -std=c++11 -lpthread -lrt -c srs.cpp -o srs.o
g++ -Wall -g -std=c++11 -lpthread -lrt -c fec.cpp -o fec.o
g++ -Wall -g -std=c++11 -lpthread -lrt -c chip.cpp -o chip.o
g++ -Wall -g -std=c++11 -lpthread -lrt -c detector.cpp -o detector.o
g++ -Wall -g -std=c++11 -lpthread -lrt -c chamber.cpp -o chamber.o
g++ -Wall -g -std=c++11 -lpthread -lrt -c chamberSpecs.cpp -o chamberSpecs.o
g++ -Wall -g -std=c++11 -lpthread -lrt -c multilayer.cpp -o multilayer.o
g++ -Wall -g -std=c++11 -lpthread -lrt -c layer.cpp -o layer.o
g++ -Wall -g -std=c++11 -lpthread -lrt -c readout.cpp -o readout.o
g++ -Wall -g -std=c++11 -lpthread -lrt -c connector.cpp -o connector.o
g++ -Wall -g -std=c++11 -lpthread -lrt -c connectorSpecs.cpp -o connectorSpecs.o
g++ -Wall -g -std=c++11 -lpthread -lrt -c createEvents.cpp -o createEvents.o
g++ -Wall -g -std=c++11 -lpthread -lrt -c event.cpp -o event.o
g++ -Wall -g -std=c++11 -lpthread -lrt -c shareMemoryWriter.cpp -o shareMemoryWriter.o
g++ -Wall -g -std=c++11 -lpthread -lrt -c Coordinates.cpp -o Coordinates.o
g++ -std=c++11 -lpthread -lrt main.o daq.o srs.o fec.o chip.o detector.o chamber.o chamberSpecs.o multilayer.o layer.o readout.o connector.o connectorSpecs.o createEvents.o event.o shareMemoryWriter.o Coordinates.o -o main
shareMemoryWriter.o: In function `boost::interprocess::shared_memory_object::priv_open_or_create(boost::interprocess::ipcdetail::create_enum_t, char const*, boost::interprocess::mode_t, boost::interprocess::permissions const&)':
/usr/include/boost/interprocess/shared_memory_object.hpp:309: undefined reference to `shm_open'
/usr/include/boost/interprocess/shared_memory_object.hpp:315: undefined reference to `shm_open'
/usr/include/boost/interprocess/shared_memory_object.hpp:327: undefined reference to `shm_open'
/usr/include/boost/interprocess/shared_memory_object.hpp:334: undefined reference to `shm_open'
shareMemoryWriter.o: In function `boost::interprocess::ipcdetail::mutexattr_wrapper::mutexattr_wrapper(bool)':
/usr/include/boost/interprocess/sync/posix/pthread_helpers.hpp:37: undefined reference to `pthread_mutexattr_init'
/usr/include/boost/interprocess/sync/posix/pthread_helpers.hpp:38: undefined reference to `pthread_mutexattr_setpshared'
/usr/include/boost/interprocess/sync/posix/pthread_helpers.hpp:40: undefined reference to `pthread_mutexattr_settype'
shareMemoryWriter.o: In function `boost::interprocess::ipcdetail::mutexattr_wrapper::~mutexattr_wrapper()':
/usr/include/boost/interprocess/sync/posix/pthread_helpers.hpp:45: undefined reference to `pthread_mutexattr_destroy'
shareMemoryWriter.o: In function `boost::interprocess::ipcdetail::posix_condition::posix_condition()':
/usr/include/boost/interprocess/sync/posix/condition.hpp:132: undefined reference to `pthread_condattr_setpshared'
shareMemoryWriter.o: In function `boost::interprocess::ipcdetail::semaphore_open(sem_t*&, boost::interprocess::ipcdetail::create_enum_t, char const*, unsigned int, boost::interprocess::permissions const&)':
/usr/include/boost/interprocess/sync/posix/semaphore_wrapper.hpp:61: undefined reference to `sem_open'
/usr/include/boost/interprocess/sync/posix/semaphore_wrapper.hpp:69: undefined reference to `sem_open'
/usr/include/boost/interprocess/sync/posix/semaphore_wrapper.hpp:77: undefined reference to `sem_open'
shareMemoryWriter.o: In function `boost::interprocess::ipcdetail::semaphore_close(sem_t*)':
/usr/include/boost/interprocess/sync/posix/semaphore_wrapper.hpp:105: undefined reference to `sem_close'
shareMemoryWriter.o: In function `boost::interprocess::ipcdetail::semaphore_post(sem_t*)':
/usr/include/boost/interprocess/sync/posix/semaphore_wrapper.hpp:148: undefined reference to `sem_post'
shareMemoryWriter.o: In function `boost::interprocess::ipcdetail::semaphore_try_wait(sem_t*)':
/usr/include/boost/interprocess/sync/posix/semaphore_wrapper.hpp:164: undefined reference to `sem_trywait'
collect2: error: ld returned 1 exit status
make: *** [main] Error 1
Don't do this:
CFLAGS=-Wall -g -std=c++11 -lpthread -lrt
Linker flags do not belong on your compile line, only on link line.
Don't do this either:
LDFLAGS= -std=c++11 -lpthread -lrt
The -std=c++11 is a compile flag, and doesn't belong on your link line.
This:
$(CC) $(LDFLAGS) $(OBJECTS) -o $#
puts libraries at the beginning of the link line. They should be at the end. This answer explains why that's important.

Can't link static lib for android NDK, cygwin gcc

I have PROJ4 library, succesfully compiled under cygwin and installed to /usr/local.
I'm trying to compile as:
$ arm-linux-androideabi-gcc -o conftest -mthumb temp.c -lproj -L/usr/local/lib -lproj -lz -lm -ldl
C:/dev/Android/android-ndk-r7c/android-8-toolchain/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld.exe: cannot find -lproj
collect2: ld returned 1 exit status
What am I doing wrong?
Try
$ arm-linux-androideabi-gcc -o conftest -mthumb temp.c /usr/local/lib/libproj.a -lz -lm -ldl
Well, the problem is that android-gcc doesn't understand cygwin path, so we need to use windows path:
$ arm-linux-androideabi-gcc -o conftest -mthumb temp.c -lproj -Lc:/path/to/lib -lproj -lz -lm -ldl

Error installing mysql2 gem on Ubuntu Server 11.10: /usr/bin/ld: cannot find -lmysqlclient_r

I got the same error on Ubuntu Server 11.10 x64 mentioned in some other posts:
Post #1
Post #2
The mysql2 gem cannot be compiled due "cannot find -lmysqlclient_r "
I'm using:
Ruby v1.8.7
MySQL v5.5.25-1
Rails 3.2.3
Gem 1.8.24
I installed the package libmysqlclient-dev and it still doesn't work.
The files
- libmysqlclient_r.a
- libmysqlclient_r.so
- libmysqlclient_r.so.18
- libmysqlclient_r.so.18.0.0
are located at /usr/lib/x86_64-linux-gnu/
So I created symlinks in /usr/lib/
Ii still doesn't work :(
Any idea??
$ sudo gem install mysql2
Building native extensions. This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
/usr/bin/ruby1.8 extconf.rb
checking for rb_thread_blocking_region()... no
checking for rb_wait_for_single_fd()... no
checking for mysql.h... yes
checking for errmsg.h... yes
checking for mysqld_error.h... yes
creating Makefile
make
gcc -I. -I. -I/usr/lib/ruby/1.8/x86_64-linux -I. -DHAVE_MYSQL_H -DHAVE_ERRMSG_H -DHAVE_MYSQLD_ERROR_H -I/usr/include/mysql -DBIG_JOINS=1 -fno-strict-aliasing -g -fPIC -fno-strict-aliasing -g -g -O2 -fPIC -Wall -funroll-loops -c mysql2_ext.c
./client.h:16:1: warning: ârb_thread_blocking_regionâ defined but not used [-Wunused-function]
gcc -I. -I. -I/usr/lib/ruby/1.8/x86_64-linux -I. -DHAVE_MYSQL_H -DHAVE_ERRMSG_H -DHAVE_MYSQLD_ERROR_H -I/usr/include/mysql -DBIG_JOINS=1 -fno-strict-aliasing -g -fPIC -fno-strict-aliasing -g -g -O2 -fPIC -Wall -funroll-loops -c result.c
result.c: In function ârb_mysql_result_fetch_rowâ:
result.c:258:31: warning: variable âtokensâ set but not used [-Wunused-but-set-variable]
result.c:272:58: warning: variable âtokensâ set but not used [-Wunused-but-set-variable]
result.c:315:33: warning: variable âtokensâ set but not used [-Wunused-but-set-variable]
gcc -I. -I. -I/usr/lib/ruby/1.8/x86_64-linux -I. -DHAVE_MYSQL_H -DHAVE_ERRMSG_H -DHAVE_MYSQLD_ERROR_H -I/usr/include/mysql -DBIG_JOINS=1 -fno-strict-aliasing -g -fPIC -fno-strict-aliasing -g -g -O2 -fPIC -Wall -funroll-loops -c client.c
client.c: In function ârb_mysql_client_infoâ:
client.c:539:3: warning: variable âwrapperâ set but not used [-Wunused-but-set-variable]
gcc -shared -o mysql2.so mysql2_ext.o result.o client.o -L. -L/usr/lib -L. -Wl,-Bsymbolic-functions -rdynamic -Wl,-export-dynamic -Wl,-rpath,/usr/lib/x86_64-linux-gnu -lruby1.8 -L/usr/lib/x86_64-linux-gnu -lmysqlclient_r -lpthread -lz -lm -lrt -ldl -lpthread -lrt -ldl -lcrypt -lm -lc
/usr/bin/ld: cannot find -lmysqlclient_r
collect2: ld returned 1 exit status
make: *** [mysql2.so] Error 1

Resources