1

I was wondering if anyone knew how to link a .so dynamic library (or a .a static library for that mater) in Microsoft visual studio. The following steps have not worked for either .a or .so.

I'm playing around with the vs-android plugging to develop in Android NDK using MVS and I'm trying to add a custom library, compiled as a .so, to the project.

1 - I've created a dynamic library (.so) project alongside one of the sample projects (the san-angeles project), in the same solution.

2 - I've set the .so project, let's call it "engine" as a dependency of san-angeles. The engine.so file is generated without any problems, and appears in the {SolutionFolder?}/Android/Debug folder.

3 - I've added engine.so to the linker additional includes of san-angeles and the {SolutionFolder?}/Android/Debug folder (as a full path, something like C:/projects/.../Debug) to the additional linker directories.

But when I compile san-angeles I get the error:

"arm-linux-androideabi-g++.exe: engine.so: No such file or directory"

So I'm guessing I need to do something else to add a .so/.a to a project? Maybe change the name to libengine.so or something like that? A lot of the default includes have the lib prefix, so I don't know if it's something along those lines.

Thank you for the help, Jaime

Simon Kissane
  • 4,373
  • 3
  • 34
  • 59
JaimeBarrachina
  • 430
  • 8
  • 21

2 Answers2

0

For anybody stumbling on this problem:

  1. Add the directory where the .so resides in Linker -> General -> Additional Library Directories. The project you are compiling must be also a Dynamic Library .so for the linker to be available. This appends the -L flag to the commandline
  2. In the Linker -> Command Line append your .so to the Additional Options with the -l flag with quotes, e.g. -l"MyDynamicLibraryWithoutLibPrefixAndExtension". In my case I wanted to link libassimp.so -> -l"assimp"
vikAy
  • 314
  • 6
  • 15
-2

Ok, so in my case this was solved by:

1 - Naming the generated engine.a as libengine.a

2 - Instead of, from MVS, adding engine.a to Preferences/Linker/Additional Dependencies, I added to Preferences/Linker/Command Line -l"engine"

With this, the project finally managed to find and engine.a

Hope this helps someone else. :)

JaimeBarrachina
  • 430
  • 8
  • 21
  • 1
    Your question involved using an .so but your answer used .a - did you ever manage to link in an .so? – Mike Weir Aug 05 '13 at 19:55
  • No, sorry, once it got working with a .a I didn't bother pushing it. – JaimeBarrachina Aug 09 '13 at 15:29
  • I am having the same issue and unfortunately your suggested fix does not help, still get the error: Severity Code Description Project File Line Suppression State Error MSB6006 "clang.exe" exited with code 1. Android2.NativeActivity C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Application Type\Android\3.0\Android.Common.targets 119 What does work however is when i add the .so/.a lib directly in the solution explorer. Although this seems to work it is still less than ideal for multi architecture builds. Thanks – Sixjac Nov 09 '21 at 00:02