简体   繁体   English

如何在Android的c ++库中添加新的.cpp文件,然后构建?

[英]How to add a new .cpp file to, and then build, a c++ library for Android?

I'm making a Unity3d plugin for this c++ library for Android. 我正在做Unity3d插件 C ++的Android库。 Ive gotten it to work in windows by opening the visual studio project the library makers provided, adding a new .cpp file to it with my API code and building to a dll. 通过打开库制造商提供的Visual Studio项目,通过使用我的API代码向其中添加一个新的.cpp文件并构建到dll,使其在Windows中工作。 I'm wondering now how I can add this new .cpp file to the library and build it for Android. 我现在想知道如何将这个新的.cpp文件添加到库中并为Android构建它。 So far I have installed the Android sdk and ndk on a machine with ubuntu and successfully built the original library using ndk-build (as per these instructions) I'm guessing it is not as simple as copying my .cpp file into the folder and building as there are AndroidManifest.xml files and so on. 到目前为止,我已经在装有ubuntu的计算机上安装了Android sdk和ndk,并使用ndk-build成功构建了原始库(根据这些说明),我想它并不像将.cpp文件复制到文件夹中那样简单。就像AndroidManifest.xml文件一样进行构建。

The AndroidManifest.xml file is not pertinent for an NDK build. AndroidManifest.xml文件与NDK构建无关。

You will need to find the appropriate Android.mk file. 您将需要找到适当的Android.mk文件。 You may need to add the file name into the LOCAL_SRC_FILES in that make file, although they may have it set up to compile all the .cpp files in the directory or something more intelligent along those lines. 您可能需要将文件名添加到该make文件中的LOCAL_SRC_FILES中,尽管他们可以设置该文件名来编译目录中的所有.cpp文件,或者更智能的方式。 It is, after all, a regular make file. 毕竟,它是一个常规的make文件。

See here for info on the Android.mk file specifics. 有关Android.mk文件详细信息,请参见此处

Edit: 编辑:

I suppose I should add that it would be the LOCAL_SRC_FILES preceding the relevant include $(BUILD_SHARED_LIBRARY) for the library you intend to build. 我想我应该补充一点,它将是您打算构建的库的相关include $(BUILD_SHARED_LIBRARY)之前的LOCAL_SRC_FILES Each make file may contain an arbitrary number of targets, although in the simplest case it's usually one make file to build a library. 每个生成文件可以包含任意数量的目标,尽管在最简单的情况下,通常使用一个生成文件来构建库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM