且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用CMAKE将FFTW添加到Android项目

更新时间:2023-01-26 14:23:49

我可以使用单精度构建,但是它不是一个很好的解决方案,因为我认为如果我执行"Clean Project"或"Refresh Linked"之类的工作C ++项目"将不再起作用,我将不得不重复下面将描述的过程:

I got the single precision build to work, but its not a great solution, since I think that if I do stuff like "Clean Project" or "Refresh Linked C++ Projects" it will not work anymore and I would have to repeat the process I will describe below:

1)我在问题中指定的CMake参数仍然相同.但是,我进入了FFTW3的CMakeLists.txt,并将ENABLE_FLOAT选项设置为ON.在此过程的这一点上,单精度更改将仅反映到x86 ABI构建中.因此,当我尝试构建项目时,Android Studio会抱怨找不到为armeabi-v7a构建的fftw3f库.
2)我想到了之前需要为每个ABI构建FFTW3的想法,因此我在defaultConfig {}中的build.gradle文件中添加了以下内容:

1) The CMake arguments that I specified in the question are still the same. However, I went into the CMakeLists.txt of FFTW3 and set the ENABLE_FLOAT option to ON. At this point in the process, the single precision change would only be reflected for the x86 ABI build. So, when I tried to build the project, Android Studio would complain about not finding the fftw3f library for the armeabi-v7a build.
2) I went with an idea I had seen before that we needed to build FFTW3 for each ABI, so I added the following to my build.gradle file inside of defaultConfig{}:

externalNativeBuild {
            cmake {
                arguments "-DANDROID_ABI=x86_64"
                abiFilters "armeabi-v7a", "arm64-v8a", "x86", "x86_64"

            }
            ndk {
                abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'

            }

将-DANDROID_ABI标志更改为要构建的ABI的位置.我真的不确定是否需要abiFilters东西,但是我很自信需要参数标志.我目前已注释掉abiFilter的内容,因为在将应用程序安装到手机中后,由于找不到我的本机库,会出现错误.
3)我用每个ABI标志构建了Android项目,这有点麻烦,所以也许我需要做

where I would change the -DANDROID_ABI flag to the ABI I wanted to build. I am really not sure whether the abiFilters stuff is needed or not, but I'm pretty confident that the argument flag is needed. I currently have commented out the abiFilter stuff because I would get errors after installing my app into my phone about not finding my native-lib.
3) I built the Android Project with each ABI flag, which is kind of a hassle, so maybe I would need do the build multiple apks method.