[CMake] Is this the rigth way to build a shared library?
dexter810
meghna.vasudeva at gmail.com
Fri Jun 28 01:24:53 EDT 2019
This is my CMakeLists.txt which is successfully building a shared library, I
just wanted to confirm if it's the right way and it:
cmake_minimum_required(VERSION 3.6)
project(main)
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/build/deps/yara/src/yara/libyara/include)
add_library(main SHARED main.cpp)
link_libraries (
-L${CMAKE_CURRENT_SOURCE_DIR}/build/src/
-L${CMAKE_CURRENT_SOURCE_DIR}/build/deps/yara/src/yara/libyara/.libs
yaracpp yara pthread ssl crypto)
When I do ldd libmain.so I get:
linux-vdso.so.1 (0x00007ffee6583000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6
(0x00007f7e1be18000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1
(0x00007f7e1bc00000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f7e1b80f000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f7e1b471000)
/lib64/ld-linux-x86-64.so.2 (0x00007f7e1c3a4000)
CMakeLists.txt for creating a successfully running executable:
cmake_minimum_required(VERSION 3.6)
project(main CXX C)
add_executable(main main.cpp)
target_include_directories(main PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/build/deps/yara/src/yara/libyara/include)
target_link_libraries (main
-L${CMAKE_CURRENT_SOURCE_DIR}/build/src/
-L${CMAKE_CURRENT_SOURCE_DIR}/build/deps/yara/src/yara/libyara/.libs
yaracpp yara pthread ssl crypto)
on doing ldd main, I got:
linux-vdso.so.1 (0x00007ffe723d4000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0
(0x00007fc0c644b000)
libcrypto.so.1.1 => /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1
(0x00007fc0c5f80000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6
(0x00007fc0c5bf7000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fc0c5859000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1
(0x00007fc0c5641000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fc0c5250000)
/lib64/ld-linux-x86-64.so.2 (0x00007fc0c68d6000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fc0c504c000)
--
Sent from: http://cmake.3232098.n2.nabble.com/
More information about the CMake
mailing list