--===============0618372871== Content-Type: multipart/alternative; boundary=001a113ab3042f9565052d83f370 --001a113ab3042f9565052d83f370 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi, On Mon, Mar 7, 2016 at 9:29 PM, Ivan wrote: > Hello! > > Here is my CMakeLists.txt: > > cmake_minimum_required(VERSION 3.3) > project(untitled19) > > set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=3Dc++11") > > set(LIBRARY_SRC library.cpp) > > add_library(libra SHARED ${LIBRARY_SRC}) > > set(SOURCE_FILES main.cpp) > add_executable(untitled19 ${SOURCE_FILES}) > target_link_libraries(untitled19 libra) > > > This works and both library and executable are compiled. Unfortunately li= brary seems to be linked into the executable: =E2=80=98nm=E2=80=99 command = shows that the executable itself exports needed functions! > > I do not think your interpreting the nm output correctly, but its hard to say without seeing it ;) Note that nm will show the functions exported by the library in the output for the executable, because the executable uses those functions. It will also indicate however that these functions are not defined inside the executable in the corresponding column with an upper-case U. When you run nm on the library itself you will notice that the same symbols have a different type in the corresponding column. In addition you can verify that the executable actually links against the library using the otool commandline tool: otool -L executable. Andreas --001a113ab3042f9565052d83f370 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hi,

On Mon, Mar 7, 2016 at 9:29 PM, Ivan <ivan@sleepyiora.pw> wrote:
Hello!

Here is my CMakeLists.txt:

cmake_minimum_required(VERSION 3.3)
project(untitled19)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=3Dc++11")

set(LIBRARY_SRC library.cpp)

add_library(libra SHARED ${LIBRARY_SRC})

set(SOURCE_FILES main.cpp)
add_executable(untitled19 ${SOURCE_FILES})
target_link_libraries(untitled19 libra)

This works and both library a=
nd executable are compiled. Unfortunately library seems to be linked into t=
he executable: =E2=80=98nm=E2=80=99 command shows that the executable itsel=
f exports needed functions!

I do not think your interpreting the nm output correctly, but its hard t= o say without seeing it ;)

Note that nm will show = the functions exported by the library in the output for the executable, bec= ause the executable uses those functions. It will also indicate however tha= t these functions are not defined inside the executable in the correspondin= g column with an upper-case U. When you run nm on the library itself you wi= ll notice that the same symbols have a different type in the corresponding = column. In addition you can verify that the executable actually links again= st the library using the otool commandline tool: otool -L executable.
=

Andreas
--001a113ab3042f9565052d83f370-- --===============0618372871== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake --===============0618372871==--