Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

unity 5.4 il2cpp linking problem.

Discussion in 'Android' started by LordDarkon76, Jul 29, 2016.

  1. LordDarkon76

    LordDarkon76

    Joined:
    Apr 1, 2015
    Posts:
    22
    Hello.

    My project correctly build and run on mono, but then I try to build using il2cpp, it return me errors.

    I know that the problem are 2 plugings, Is there anything in my side, that I can do to solve my issue?,
    If there isn't, any tip that I can give to my plugin provider??

    Kind Regards.



    Failed running C:/android-ndk-r10e/toolchains/llvm-3.6/prebuilt/windows-x86_64/bin/clang++ -o "Temp/StagingArea\assets\bin\Data\Native\x86\libil2cpp.so.debug" -Wl,-soname,libil2cpp.so.debug --sysroot "C:/android-ndk-r10e/platforms/android-9/arch-x86" -gcc-toolchain "C:/android-ndk-r10e/toolchains/x86-4.9/prebuilt/windows-x86_64" -target i686-none-linux-android -shared -fuse-ld=gold -Wl,--no-undefined -Wl,-z,noexecstack -Wl,--gc-sections -Wl,--build-id "Temp/StagingArea\Il2Cpp\il2cppOutput\x86\Bulk_Assembly-CSharp-firstpass_0.o" "Temp/StagingArea\Il2Cpp\il2cppOutput\x86\Bulk_Assembly-CSharp_0.o" "Temp/StagingArea\Il2Cpp\il2cppOutput\x86\Bulk_Assembly-CSharp_1.o" "Temp/StagingArea\Il2Cpp\il2cppOutput\x86\Bulk_Assembly-CSharp_2.o" "Temp/StagingArea\Il2Cpp\il2cppOutput\x86\Bulk_Assembly-CSharp_3.o" "Temp/StagingArea\Il2Cpp\il2cppOutput\x86\Bulk_Assembly-CSharp_4.o" "Temp/StagingArea\Il2Cpp\il2cppOutput\x86\Bulk_CaptureAndSaveLib_0.o" "Temp/StagingArea\Il2Cpp\il2cppOutput\x86\Bulk_Generics_0.o" "Temp/StagingArea\Il2Cpp\il2cppOutput\x86\Bulk_Generics_1.o" "Temp/StagingArea\Il2Cpp\il2cppOutput\x86\Bulk_Generics_2.o" "Temp/StagingArea\Il2Cpp\il2cppOutput\x86\Bulk_Generics_3.o" "Temp/StagingArea\Il2Cpp\il2cppOutput\x86\Bulk_Generics_4.o" "Temp/StagingArea\Il2Cpp\il2cppOutput\x86\Bulk_Generics_5.o" "Temp/StagingArea\Il2Cpp\il2cppOutput\x86\Bulk_Generics_6.o" "Temp/StagingArea\Il2Cpp\il2cppOutput\x86\Bulk_Generics_7.o" "Temp/StagingArea\Il2Cpp\il2cppOutput\x86\Bulk_Generics_8.o" "Temp/StagingArea\Il2Cpp\il2cppOutput\x86\Bulk_Generics_9.o" "Temp/StagingArea\Il2Cpp\il2cppOutput\x86\Bulk_ImageVideoContactPicker_0.o" "Temp/StagingArea\Il2Cpp\il2cppOutput\x86\Bulk_Mono.Security_0.o" "Temp/StagingArea\Il2Cpp\il2cppOutput\x86\Bulk_Mono.Security_1.o" "Temp/StagingArea\Il2Cpp\il2cppOutput\x86\Bulk_mscorlib_0.o" "Temp/StagingArea\Il2Cpp\il2cppOutput\x86\Bulk_mscorlib_1.o" "Temp/StagingArea\Il2Cpp\il2cppOutput\x86\Bulk_mscorlib_2.o" "Temp/StagingArea\Il2Cpp\il2cppOutput\x86\Bulk_mscorlib_3.o" "Temp/StagingArea\Il2Cpp\il2cppOutput\x86\Bulk_mscorlib_4.o" "Temp/StagingArea\Il2Cpp\il2cppOutput\x86\Bulk_mscorlib_5.o" "Temp/StagingArea\Il2Cpp\il2cppOutput\x86\Bulk_mscorlib_6.o" "Temp/StagingArea\Il2Cpp\il2cppOutput\x86\Bulk_mscorlib_7.o" "Temp/StagingArea\Il2Cpp\il2cppOutput\x86\Bulk_OSCsharp_0.o" "Temp/StagingArea\Il2Cpp\il2cppOutput\x86\Bulk_System.Core_0.o" "Temp/StagingArea\Il2Cpp\il2cppOutput\x86\Bulk_System_0.o" "Temp/StagingArea\Il2Cpp\il2cppOutput\x86\Bulk_System_1.o" "Temp/StagingArea\Il2Cpp\il2cppOutput\x86\Bulk_TUIOsharp_0.o" "Temp/StagingArea\Il2Cpp\il2cppOutput\x86\Bulk_UnityEngine.UI_0.o" "Temp/StagingArea\Il2Cpp\il2cppOutput\x86\Bulk_UnityEngine.UI_1.o" "Temp/StagingArea\Il2Cpp\il2cppOutput\x86\Bulk_UnityEngine_0.o" "Temp/StagingArea\Il2Cpp\il2cppOutput\x86\Bulk_UnityEngine_1.o" "Temp/StagingArea\Il2Cpp\il2cppOutput\x86\Bulk_UnityEngine_2.o" "Temp/StagingArea\Il2Cpp\il2cppOutput\x86\Bulk_UnityEngine_3.o" "Temp/StagingArea\Il2Cpp\il2cppOutput\x86\GenericMethods0.o" "Temp/StagingArea\Il2Cpp\il2cppOutput\x86\GenericMethods1.o" "Temp/StagingArea\Il2Cpp\il2cppOutput\x86\Il2CppAttributes.o" "Temp/StagingArea\Il2Cpp\il2cppOutput\x86\Il2CppCodeRegistration.o" "Temp/StagingArea\Il2Cpp\il2cppOutput\x86\Il2CppCompilerCalculateTypeValuesTable.o" "Temp/StagingArea\Il2Cpp\il2cppOutput\x86\Il2CppDelegateWrappersManagedToNativeTable.o" "Temp/StagingArea\Il2Cpp\il2cppOutput\x86\Il2CppGenericClassTable.o" "Temp/StagingArea\Il2Cpp\il2cppOutput\x86\Il2CppGenericInstDefinitions.o" "Temp/StagingArea\Il2Cpp\il2cppOutput\x86\Il2CppGenericMethodDefinitions.o" "Temp/StagingArea\Il2Cpp\il2cppOutput\x86\Il2CppGenericMethodPointerTable.o" "Temp/StagingArea\Il2Cpp\il2cppOutput\x86\Il2CppGenericMethodTable.o" "Temp/StagingArea\Il2Cpp\il2cppOutput\x86\Il2CppGuids.o" "Temp/StagingArea\Il2Cpp\il2cppOutput\x86\Il2CppInvokerTable.o" "Temp/StagingArea\Il2Cpp\il2cppOutput\x86\Il2CppMarshalingFunctionsTable.o" "Temp/StagingArea\Il2Cpp\il2cppOutput\x86\Il2CppMetadataRegistration.o" "Temp/StagingArea\Il2Cpp\il2cppOutput\x86\Il2CppMetadataUsage.o" "Temp/StagingArea\Il2Cpp\il2cppOutput\x86\Il2CppMethodPointerTable.o" "Temp/StagingArea\Il2Cpp\il2cppOutput\x86\Il2CppTypeDefinitions.o" -L "C:\Program Files\Unity\Editor\Data\PlaybackEngines\AndroidPlayer\Variations\il2cpp\Release/StaticLibs/x86" -lil2cpp -lbdwgc -L "C:/android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.9/libs/x86" -lgnustl_static

    Temp/StagingArea\Il2Cpp\il2cppOutput/Bulk_CaptureAndSaveLib_0.cpp:137: error: undefined reference to '_SaveImage'
    Temp/StagingArea\Il2Cpp\il2cppOutput/Bulk_CaptureAndSaveLib_0.cpp:137: error: undefined reference to '_SaveImage'
    Temp/StagingArea\Il2Cpp\il2cppOutput/Bulk_ImageVideoContactPicker_0.cpp:134: error: undefined reference to '_PickImage'
    Temp/StagingArea\Il2Cpp\il2cppOutput/Bulk_ImageVideoContactPicker_0.cpp:143: error: undefined reference to '_PickVideo'
    Temp/StagingArea\Il2Cpp\il2cppOutput/Bulk_ImageVideoContactPicker_0.cpp:152: error: undefined reference to '_PickContact'
    Temp/StagingArea\Il2Cpp\il2cppOutput/Bulk_ImageVideoContactPicker_0.cpp:134: error: undefined reference to '_PickImage'
    Temp/StagingArea\Il2Cpp\il2cppOutput/Bulk_ImageVideoContactPicker_0.cpp:143: error: undefined reference to '_PickVideo'
    Temp/StagingArea\Il2Cpp\il2cppOutput/Bulk_ImageVideoContactPicker_0.cpp:152: error: undefined reference to '_PickContact'
    clang++.exe: error: linker command failed with exit code 1 (use -v to see invocation)
    UnityEngine.Debug:LogError(Object)
    NativeCompiler:RunProgram(ProcessStartInfo) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/NativeCompiler.cs:60)
    NativeCompiler:Execute(String, String) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/NativeCompiler.cs:26)
    UnityEditor.Android.<CompileDynamicLibrary>c__AnonStorey2:<>m__6(TargetArchCompilerSettings)
    <ParallelFor>c__AnonStorey7C`1:<>m__11A(Object) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/NativeCompiler.cs:89)
     
  2. sdf_eee

    sdf_eee

    Joined:
    May 30, 2015
    Posts:
    55
    Same here!

    Try to IL2CPP build on Android, I get this error.

    Temp/StagingArea\Il2Cpp\il2cppOutput/Bulk_CaptureAndSaveLib_0.cpp:7000: error: undefined reference to '_ReportAchievement'

    _ReportAchievement is my custom iOS native code(.mm).

    How can I fix it?
     
  3. sdf_eee

    sdf_eee

    Joined:
    May 30, 2015
    Posts:
    55
    I solved this problem.

    Insert #if UNITY_IPHONE for all iOS native bind functions in C# script.
    In my case, [DLLImport]. may InternalCall and PInvoke are same.
     
  4. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    1,167
    @LordDarkon76 : here is your actual error

    Some functions are missing. If they should not be there - then some #ifdefs are really needed.
    Related files: CaptureAndSaveLib, ImageVideoContactPicker.
     
  5. LordDarkon76

    LordDarkon76

    Joined:
    Apr 1, 2015
    Posts:
    22
    I know that the error undefined references.

    I'm using two plugins
    https://www.assetstore.unity3d.com/en/#!/content/28597
    https://www.assetstore.unity3d.com/en/#!/content/18755

    Both have a dll.

    Opening the first one with ilspy I found


    public class CallNative
    {
    [DllImport("__Internal")]
    private static extern int _SaveImage(string str);

    public static int SaveImageToCameraRoll(string path)
    {
    if (Application.get_platform() == 8)
    {
    return CallNative._SaveImage(path);
    }
    return 0;
    }
    }


    So to make it work I only need to add the #if UNITY_IOS or because its a dll it should have a different define???
     
  6. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    1,167
    I don't know which specific platform is this "8" but looks like the code should be #ifdef'd.
     
  7. Dinacode

    Dinacode

    Joined:
    Nov 25, 2014
    Posts:
    5
    I have the same problem (5.4.0f3 and 5.4.0p1) , It is running on mono but doesn´t on il2cpp.
    If I remove Official Facebook plugin (facebook-unity-sdk-7.8.0) it works. How can I fix it?

    Thanks
     
  8. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    1,167
    Report it to Facebook.