rice@rice:~/mbedtls_study/mbedtls$ cmake -DUSE_SHARED_MBEDTLS_LIBRARY=On .
rice@rice:~/mbedtls_study/mbedtls$ make
rice@rice:~/mbedtls_study/mbedtls$ sudo make install
rice@rice:~/mbedtls_study/demo$ mkdir build
rice@rice:~/mbedtls_study/demo$ cd build
rice@rice:~/mbedtls_study/demo/build$ cmake ../
-- The C compiler identification is GNU 7.5.0
-- The CXX compiler identification is GNU 7.5.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c
-- Check for working CXX compiler: /usr/bin/c -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/rice/mbedtls_study/demo/build
rice@rice:~/mbedtls_study/demo/build$ make
Scanning dependencies of target mbedtls-test
[ 50%] Building C object CMakeFiles/mbedtls-test.dir/mbedtls-test.c.o
[100%] Linking C executable mbedtls-test
[100%] Built target mbedtls-test
rice@rice:~/mbedtls_study/demo/build$ ./mbedtls-test
SHA1: [CBD12068E2F91DF5DB148742DF108131AF76287E]
rice@rice:~/mbedtls_study/demo/build$ ./mbedtls-test
./mbedtls-test: error while loading shared libraries: libmbedcrypto.so.0: cannot open shared object file: No such file or directory
解决方法:
代码语言:javascript复制
rice@rice:~/mbedtls_study/demo/build$ sudo vim /etc/ld.so.conf //在新的一行中加入库文件所在目录
/usr/local/lib
rice@rice:~/mbedtls_study/demo/build$ sudo ldconfig //更新/etc/ld.so.cache文件