Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
149 views
in Technique[技术] by (71.8m points)

HowTo: TFS --> check out C/C++ source files --> build libs through CMakeLists --> using Android Studio

The title explains my purpose and speaks out different problems i encountered trying to implement it:

  1. Check out a TFS-Project with the Android Studio TFVC-Plugin was not very difficult - but i am not able to import the native code project as a module in my Android application. I tried to include it through settings.gradle and by new module without success.
  2. I built the native (C) libraries using cmakelists.txt linking to the path i checked out. But it seems the dependencies are not set up 100% correct. I can include all files fine (for the compiler) but when i build i get the following error message: "'File_a.h' not found". Directory:

    AndroidStudioProjects
    ? ? ? ? ? ? |
    ? ? ? ? ? ? + My_Android_Application
    ? ? ? ? ? ? |
    ? ? ? ? ? ? + TFVC_Workspace
    ? ? ? ? ? ? ? ? ? ? ? ?|
    ? ? ? ? ? ? ? ? ? ? ? ? + Lib_a
    ? ? ? ? ? ? ? ? ? ? ? ?|? ? ? ? |
    ? ? ? ? ? ? ? ? ? ? ? ?|? ? ? ? - File_a.h
    ? ? ? ? ? ? ? ? ? ? ? ?|? ? ? ? - File_b.h
    ? ? ? ? ? ? ? ? ? ? ? ?|? ? ? ? - File_b.c
    ? ? ? ? ? ? ? ? ? ? ? ?|
    ? ? ? ? ? ? ? ? ? ? ? ? + Lib_b depending on Lib_a
    ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? |
    ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? - File_c.h
    ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? - File_c.c
    ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? - File_d.h
    ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? - File_d.c
  3. I tried to use different CMakeLists.txt according to this guide, but since my TFS files are not stored in subdirectories to the CMakeLists in my Android Studio i got stuck.

I am not able to bring all the bricks together and i think theres (JUST a BIT) confusion in my hung up brain - therefore your help to figure out errors, wrong approaches, broken design, etc. is highly appreciated!

P.S. sorry so much for the bad Directory Tree - was not able to make it better. If you need more informations about files/structure please let me know!

CMakeLists.txt (located in C:/Users//AndroidStudioProjects/Android_Project/app)

cmake_minimum_required(VERSION 3.4.1)
set(TFC_Path C:/Users/<user>/AndroidStudioProjects/TFVC/)
add_library( TFC_Lib_a 
             SHARED   
             ${TFC_Path}/Lib_a/File_a.h
             ${TFC_Path}/Lib_a/File_b.c                                   
             )
target_include_directories( TFC_Lib_a PUBLIC ${TFC_Path}/Interface_headers)


add_library( TFC_Lib_b 
             SHARED   
             ${TFC_Path}/Lib_b/File_c.c
             ${TFC_Path}/Lib_b/File_d.c                                   
             )

#since not all headers are automatically included, though File_a.h was listed in add_library(Lib_a), but Lib_b needs that header i am adding following line:
target_include_directories( TFC_Lib_a PUBLIC ${TFC_Path}/Lib_a) 

target_link_libraries( applications_jni TFC_Lib_b)
target_link_libraries( TFC_Lib_b TFC_Lib_a)

Update If i dont include File_a.h in Lib_a the compiler is not complaining, since the header is found through target_include_directories, but when i build the error of missing Lib_a.h remains!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Well i solved the include problem by adding a "../Lib_a/" before the "File_a.h" include statement. Since there are lots of files in the libraries to adjust and they are from a TFS, so this is not really the answer i was looking for. I thought that after specifying the library dependencies in CMakeLists you could simply include the file. Now: How to set up CMakeLists to not have to change the include statements from a TFS project?!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...