0

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!

Nihao mao
  • 1
  • 1
  • Replace the colons in `CFLAGS` with a space and `-I` — you must specify each directory as a separate `-I` option. I would 3/4 expect to specify the `lib` directory and not the `lib/.libs` sub-directory for the libraries, too. – Jonathan Leffler Apr 12 '20 at 06:06
  • Thanks for your help! I changed it to: export CFLAGS='-I../missing_libs/curl-7.68.0/include/lib -I../missing_libs/json-c/ -I../missing_libs/openssl-1.0.2/' It still throws the same errors, so i guess there are other problems. As for the lib/.libs, im supposed to link my LDFLAGS to the folder with the .a and .so files right? – Nihao mao Apr 12 '20 at 08:26
  • Typically, if you have a `.libs` subdirectory, you've been using `libtool` (whether you knew it or not), and there's a `.la` file in the `lib` directory containing the `.libs` subdirectory which will do the job correctly. However, I'm not an expert on this; you may be OK as you are. I'm not sure what else you need to fix. You don't show the command that was executed when the compilation failed, AFAICS, so it is hard to know what's going wrong. – Jonathan Leffler Apr 12 '20 at 08:45

1 Answers1

0

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!

Nihao mao
  • 1
  • 1