none
VS 2015 android crossplatform development for multiple shared library

    Question

  • Hi,

    I create an android native activity app using vs2015, and I added another shared library project in the solution.

    In the native activity it calls the function in my shared lib. But I meet linking issue when build the native activity. It doesn't find the function:" >android_native_app_glue.c(263): error : undefined reference to 'myTestEntry' "

    Am I missed something? Where do I set the dependency lib for native activity?

    I have set the proper path for " linker > general > shared library search path".

    Friday, March 18, 2016 9:54 AM

Answers

  • Hi wuhu,

    >>*But* it can't run in the emulator even if I set the LD_LIBRARY_PATH var.

    Do you mean you can't deploy your Android app to the emulator? Please tell us the behavior of the Android emulator. Is it can't open or it always show starting when you try deploy your app to emulator?

    Please create a new default app without Shared Project to make sure this problem is related to the emulator or the Shared Project.

    In addition, please refer to below article to troubleshooting your Android emulator.

    https://msdn.microsoft.com/en-us/library/mt228282.aspx

    >>As you see it set the shared library in my developer path, that is not my expected.

    As far as I know, the Shared Project code is compiled as part of each referencing project. So the shared library should be in the developer path. It should be the design for Shared Project. If you have any idea for this design, I suggest you post your ideas to Visual Studio User Voice and share the feedback link here. It can let other communities who has the same requirement to vote and add comments for your feedback.

    Best Regards,
    Weiwei

    Tuesday, March 22, 2016 1:28 AM
    Moderator

All replies

  • In one words I want to use the "shared library" in vs2015 android project.
    Friday, March 18, 2016 9:56 AM
  • Hi wuhu,

    >>It doesn't find the function:" >android_native_app_glue.c(263): error : undefined reference to 'myTestEntry' "

    Do you have add the using code to reference the namespace of the Shared Library? Please refer to the Visual Studio Walkthrough part in below article which introduce how to use Shared Project in cross-platform projects.

    https://developer.xamarin.com/guides/cross-platform/application_fundamentals/shared_projects/

    And you also can refer to following example, which contains how the Shared Projects work in Android project.

    https://github.com/xamarin/mobile-samples/tree/master/Tasky

    Best Regards,
    Weiwei

    Monday, March 21, 2016 5:22 AM
    Moderator
  • Hi Weiwei,

    Yes, after I added the "reference projects" property in vcxproj file, it can passed the build and can link successfully.

      <ItemGroup>
        <ProjectReference Include="..\..\test\test.vcxproj">
          <Project>{6cc65a69-1f6e-4d57-82c5-95a8d8ee3b6c}</Project>
        </ProjectReference>
      </ItemGroup>

    *But* it can't run in the emulator even if I set the LD_LIBRARY_PATH var.

    I use the NDK readelf tool to see the .so file, it prints:

    0x00000001 (NEEDED)                     Shared library: [F:\android test\Android_Native\x86\Debug\libtest.so]
    0x00000001 (NEEDED)                     Shared library: [liblog.so]
    0x00000001 (NEEDED)                     Shared library: [libandroid.so]
    0x00000001 (NEEDED)                     Shared library: [libGLESv1_CM.so]
    0x00000001 (NEEDED)                     Shared library: [libEGL.so]
    0x00000001 (NEEDED)                     Shared library: [libdl.so]
    0x00000001 (NEEDED)                     Shared library: [libc.so]
    0x0000001a (FINI_ARRAY)                 0x5d94
    0x0000001c (FINI_ARRAYSZ)               8 (bytes)

    As you see it set the shared library in my developer path, that is not my expected.

    This is a Visual Studio bug?

    Monday, March 21, 2016 7:45 AM
  • Hi wuhu,

    >>*But* it can't run in the emulator even if I set the LD_LIBRARY_PATH var.

    Do you mean you can't deploy your Android app to the emulator? Please tell us the behavior of the Android emulator. Is it can't open or it always show starting when you try deploy your app to emulator?

    Please create a new default app without Shared Project to make sure this problem is related to the emulator or the Shared Project.

    In addition, please refer to below article to troubleshooting your Android emulator.

    https://msdn.microsoft.com/en-us/library/mt228282.aspx

    >>As you see it set the shared library in my developer path, that is not my expected.

    As far as I know, the Shared Project code is compiled as part of each referencing project. So the shared library should be in the developer path. It should be the design for Shared Project. If you have any idea for this design, I suggest you post your ideas to Visual Studio User Voice and share the feedback link here. It can let other communities who has the same requirement to vote and add comments for your feedback.

    Best Regards,
    Weiwei

    Tuesday, March 22, 2016 1:28 AM
    Moderator