How to link Libraries in non-standard locations for compilation

531 Views Asked by At

I'm new to linux, and am trying to compile and install some libraries.

Unfortunately, things are quite difficult as I am unable to obtain sudo access to my machine, and had to install the libraries in non-standard locations.

I'm having trouble getting the compiler to find the libraries I installed.

One of the libraries (https://github.com/tpm2-software/tpm2-tss/blob/master/INSTALL.md) I'm trying to install has dependencies on the other libraries, and I am getting the following error code when trying to compile, and am unable to fix it.

src/tss2-esys/esys_crypto_ossl.c:11:10: fatal error: openssl/evp.h: No such file or directory
 #include <openssl/evp.h>
compilation terminated.

make[1]: *** [Makefile:14063: src/tss2-fapi/api/libtss2_fapi_la-Fapi_AuthorizePolicy.lo] Error 1
In file included from ./src/tss2-fapi/fapi_int.h:11, from src/tss2-fapi/api/Fapi_ChangeAuth.c:18:
./src/tss2-fapi/ifapi_policy_instantiate.h:13:10: fatal error: json-c/json.h: No such file or directory
 #include <json-c/json.h>
compilation terminated.

So far, I've been trying to compile it in bash using the following commands:

./bootstrap

export PKG_CONFIG_PATH=/home/me/test/lib/pkgconfig:$PKG_CONFIG_PATH
export LDFLAGS='-L../missing_libs -lssl  -L../missing_libs -lz  -L../missing_libs/json-c/.libs -ljson-c  -L../missing_libs/curl-7.68.0/lib/.libs -lcurl  -L../openssl-1.0.2 -lcrypto'
export CFLAGS='-I../missing_libs/curl-7.68.0/include/lib:../missing_libs/json-c:../missing_libs/openssl-1.0.2'

./configure --prefix=/home/me/test --with-udevrulesdir=/lib/udev --disable-doxygen-doc

make -j$(nproc)

The LDFLAGS are the folders that contain my .so and .a files, while the CFLAGS are the folders that contain my h files.

Can I check if anyone knows what I am not linking properly?

Thanks!

1

There are 1 best solutions below

0
On BEST ANSWER

I found the problem. Apparently I was linking to the wrong place.

Since library was searching for , I should not link to the directory where json.h is, but the directory where json-c/json.h is.

So for my CFLAGS should be "-I../missing_libs" instead of "-I../missing_libs/json-c"

Thanks for the help Jonathan!