Build error with OpenCV's libpng when using Affdex for Unity with another third-party video-streaming library in Swift

ios

#1

Hello, we are a start-up that would love to use Affdex in our new iOS app.

We ran into an Undefined Symbol build error when trying to build a XCode project using Affdex in Unity while integrating with third party video-streaming library in Siwft (we tried a few of video-streaming libraries, all run into the same error).

Looks like the problem has something to do with NEON optimization being activated in OpenCV used by Affdex, but not in libpng (a dependency OpenCV and the third-part video streaming library share) while png_init_filter_functions_neon in this case, for some reason is not added to the source ( ENABLE_NEON is not ON?), similar to what is described in this git issue: https://github.com/opencv/opencv/issues/7600 in OpenCV.

Would love to know which OpenCV Affdex is using and how can we go around this problem. Thank you.

Here is the full error log:

Undefined symbols for architecture arm64:
"_png_init_filter_functions_neon", referenced from:
_png_read_filter_row in libaffdex-native.a(pngrutil.o)
OBJC_CLASS$_ALAssetsLibrary”, referenced from:
objc-class-ref in libaffdex-native.a(cap_ios_video_camera.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)


#2

Replied to one of your questions here: Probably a bug in statically linked OpenCV

I think one way to go around this issue is to preload the other video streaming library before Affdex something of this sort : Qt image processing libraries clash


#3

@umang_mehta @archy_wilhes Hi, I am running into the same issue as described by the author of this post when trying to integrate the Vungle Ad SDK into my Unity Project for iOS devices. I saw your solution to preload the other video streaming library before Affdex. How exactly do I do that? Can you please describe in more detail
Thank you :slight_smile:


#4

Apologies for the delayed reply. You can do so by doing something like:

export LD_PRELOAD=/path/to/the/core-library/


#5

Hi,
I have the same error integrating Google Firebase and Affdex in my project.
Can you please be more specific how should I preload other libraries? Where should I run this or add or whatever I have to do.
Sorry but I am a newbie in iOS building and development.

Thanks in advance!


#6

@nuri_shabanov I suspect that you are encountering something unrelated to this opencv issue. Can you open a new topic with details about the problem you’re having? Thanks.


#7

The error is the same as posted here, so I guess it’s the same issue and that’s why I posted my reply here and not creating a new issue.
Btw thanks for the fast answer!


#8

Oh, I thought you were getting an error related to firebase. Are you getting this error?

Undefined symbols for architecture arm64:
"_png_init_filter_functions_neon", referenced from:
_png_read_filter_row in libaffdex-native.a(pngrutil.o)
“OBJC_CLASS$_ALAssetsLibrary”, referenced from:
objc-class-ref in libaffdex-native.a(cap_ios_video_camera.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)


#9

Yes, it’s almost the same, just different file:

Undefined symbols for architecture arm64:
"_png_init_filter_functions_neon", referenced from:
_png_read_filter_row in libaffdex-native.a(pngrutil.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)


#10

Any help with this, because I still can’t find a solution for it.


#11

The Affdex SDK uses a customized OpenCV which is based on the open source version 2.4. However, in version 3.1 of OpenCv, there was a bug which caused _png_init_filter_functions_neon to not be compiled in for arm64:

The working theory is that if you are encountering the link error above, it means you are directly or indirectly linking in a different version of libpng, possibly via a different version of opencv, possibly via some other 3rd party library.

My first suggestion is to try putting libaffdex-native earlier on the linker command line than other libraries, so that our implementation is chosen by the linker.

For additional details, also see https://stackoverflow.com/questions/35338568/error-while-compiling-ios-app-with-opencv-framework-on-real-device