c++ - A probem with using static libraries in cmake project -


i have 2 c++ projects , b. project b depends on project a. project has structure split subdirectories:

project |-\inc |  |-a1.h |  |-a2.h |-\src    |-cmakelists.txt    |-\subdir_a1    |  |-cmakelists.txt    |  |-a1.cpp    |    |-\subdir_a2       |-cmakelists.txt       |-a2.cpp  project b |-\lib    |-a1.h    |-a2.h    |-lib_projecta.a |-\src    |-cmakelists.txt    |-b.cpp 

the problem project b can't resolve project's definitions. although i've added target_link_libraries cmakelists.txt in project b, have error this:

undefined reference `project_a::a1::func1()"

upd1

i managed compile project b copping libraries subdirectories (liba1.a, liba2.a) , linking them project. wonder if it's possible tune project a, can 1 file lib_projecta.a

upd2

code:

project a

add_library (adapter    adapter.cpp  )  target_link_libraries (adapter public    net  # project's subdirectory     utils # project's subdirectory  ) 

project b

add_library (anthill    functional_block.cpp)  target_link_libraries(anthill    ${project_source_dir}/lib/libjsoncpp.a   ${project_source_dir}/lib/libadapter.a    ${project_source_dir}/lib/libnet.a     # can't compile without      ${project_source_dir}/lib/libutils.a   # can't compile without ) 

the best solution use object option:

 add_library(myobjects object a.c b.c) 

Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -