如何:TFS->检出C/C ++源文件->通过CMakeLists构建库->使用Android Studio [英] HowTo: TFS --> check out C/C++ source files --> build libs through CMakeLists --> using Android Studio

查看:274
本文介绍了如何:TFS->检出C/C ++源文件->通过CMakeLists构建库->使用Android Studio的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

标题说明了我的目的,并说出了我在尝试实现它时遇到的各种问题:

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

  1. 使用Android Studio TFVC-Plugin签出TFS项目并不是很困难-但是我无法将本机代码项目作为模块导入我的Android应用程序中.我试图通过settings.gradle和新模块将其包括在内,但没有成功.
  2. 我使用cmakelists.txt链接到我签出的路径构建了本机(C)库.但是似乎没有将依赖关系设置为100%正确.我可以包括所有适用于编译器的文件,但是在生成时会收到以下错误消息:未找到'File_a.h'".目录:

    AndroidStudioProjects
                |
                + My_Android_Application
                |
                + TFVC_Workspace
                            |
                            + Lib_a
                            |        |
                            |        - File_a.h
                            |        -File_b.h
                            |        -File_b.c
                            |
                            + Lib_b取决于Lib_a
                                    |
                                    -File_c.h
                                    -File_c.c
                                    -File_d.h
                                    -File_d.c
  3. 我尝试根据使用不同的CMakeLists.txt >指南,但是由于我的TFS文件没有存储在我的Android Studio中的CMakeLists的子目录中,因此卡住了.
  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.非常抱歉,目录树质量不好-无法将其改进.如果您需要有关文件/结构的更多信息,请告诉我!

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 (位于C:/Users//AndroidStudioProjects/Android_Project/app中)

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)

更新 如果我没有在Lib_a中包含File_a.h,则编译器不会抱怨,因为可以通过target_include_directories找到标头,但是当我构建时,仍然缺少Lib_a.h的错误!

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!

推荐答案

我解决了包含问题,方法是在"File_a.h" include语句之前添加"../Lib_a/".由于库中有许多文件需要调整,并且它们来自TFS,所以这并不是我一直在寻找的答案.我以为在CMakeLists中指定库依赖项之后,您可以简单地包含该文件.现在:如何设置CMakeLists不必更改TFS项目中的include语句?

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?!

这篇关于如何:TFS->检出C/C ++源文件-&gt;通过CMakeLists构建库->使用Android Studio的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆