strophe / libstrophe

A simple, lightweight C library for writing XMPP clients
http://strophe.im/libstrophe
Other
401 stars 163 forks source link

Installation on beaglebone Black fails #98

Closed BramvanLeeuwen closed 7 years ago

BramvanLeeuwen commented 7 years ago

I tried to install libstrophe on a Beaglebone Black (Debian GNU/Linux 8.6 (jessie) Release: 8.6). Openssl was installed: OpenSSL> version OpenSSL 1.0.1t 3 May 2016 (error?? I tried to install 1.0.2g) but ./Configure fails. It gives : Checking for openssl/ssl.h... no configure: error: openssl not found; openssl required What to do?

BramvanLeeuwen commented 7 years ago

Besides.. open ssl was installed with: ./config --prefix=/usr/local/openssl --openssldir=/usr/local/openssl

pasis commented 7 years ago

configure script uses pkg-config to find openssl. It requires openssl.pc file in /usr/lib/pkgconfig/ or similar paths. You have installed openssl to a non-standard path and configure just don't search there.

First of all check that you have file /usr/local/openssl/lib/pkgconfig/openssl.pc. Then try this command:

PKG_CONFIG_PATH=/usr/local/openssl/lib/pkgconfig ./configure
BramvanLeeuwen commented 7 years ago

Thanks, your answer was helpful. It worked out. But I have to make a further step. Openconfig is found now, but now a next problem pops up: make install ends up with the following error message:

hf/libexpat.so -lresolv -O2 -Wl,-soname -Wl,libstrophe.so.0 -Wl,-version-script -Wl,.libs/libstrophe.ver -o .libs/libstrophe.so.0.0.0 /usr/bin/ld: /usr/lib/gcc/arm-linux-gnueabihf/4.9/../../../libssl.a(s23_clnt.o): relocation R_ARM_THM_MOVW_ABS_NC against `a local symbol' can not be used when making a shared object; recompile with -fPIC /usr/lib/gcc/arm-linux-gnueabihf/4.9/../../../libssl.a: error adding symbols: Bad value collect2: error: ld returned 1 exit status Makefile:941: recipe for target 'libstrophe.la' failed make: *** [libstrophe.la] Error 1

I hope you can help me again!

pasis commented 7 years ago

Try to rebuild your openssl with shared option:

./config --prefix=/usr/local/openssl --openssldir=/usr/local/openssl shared

When you build a shared library (libstrpohe.so in this case) you need to compile object files with gcc flag -fPIC. Since libssl.a is just an archive of object files and they are built without -fPIC in your case, it can't be linked. shared option should add -fPIC to compiler flags.

BramvanLeeuwen commented 7 years ago

Everything OK until now!! (so far as I cab see) The library files libstrophe.a libstrophe.so etcetera are now in the folder /usr/local/lib. Thank you for your help. The making of openssl cost some time in the Beaglebone. He is small but not so fast.. The whole procedure costs a morning. Some mistakes a morning again. Error preventing is also important. May be you can be so kind to answer another question I have. I have the libraries and the .a and .so files in /usr/local/lib. Is it possible to move them to another library to make it easier for the linker (to find) or is there any registration during the installation that is corrupted by moving them to another directory? I want to use the libraries in a (C++)-cross platform compiled program and have to move some files to the folder /gnueabihf/ . Or ... do I have to make a separate compilation (of the libraries) for the arm-cross-compilation? I suppose you can answer my questions easily. When not .. your answers until yet were already very much appreciated!!

pasis commented 7 years ago

I'll answer to 2 different questions here, please, let me know if I got your question wrong.

1. Paths You can move .a, .so and *.h files to any place where compiler/linker look for them. Actually you don't have to do this manually if you already have compiled sources. You can remove libstrophe from /usr/local with make uninstall and then re-install it with other prefix: make install prefix=/gnueabihf. The last example will copy strophe.h to /gnueabihf/include and libstrophe.{a,so} to /gnueabihf/lib.

The only place where libsrtophe.so can be registered is /etc/ld.so.cache. And it will be fixed with running ldconfig or installing any library with a package manager (because it runs ldconfig). Anyway, this cache is used to search for shared libraries when an application is executed and there is no harm when you have libstrophe.so there.

2. Cross-compilation You can not link library built for platform X to a program for platform Y. But you can copy library and header files to your PC for example, where you build a program for your beaglebone.

It is not clear if you cross compile your program on beaglebone for other platform. Or beaglebone is the target platform. If you need more precise answer about cross compilation, please, describe your scenario.

BramvanLeeuwen commented 7 years ago

Everything clear! You answered my questions. Thank you very much!

pasis commented 7 years ago

Please, close this issue if there is no other related question.

BramvanLeeuwen commented 7 years ago

Yes, issue is closed. Everything functions as expected.