0

I need some general guidance regarding the correct way to link either static or dynamic libraries in a Visual Studio Cross-Platform C++ Mobile App project.

Specifically, I'm trying to link my project with a libpng build, but I doubt this is specific to that library.

I have built libpng (and zlib) successfully. The Universal Windows App project in the solution runs and uses the libpng API just fine. The Android project, however, is giving me undefined reference errors to the libpng functions and very high blood pressure.

The various libpng types defined in headers are not causing errors, only the function definitions. I'm also fairly sure the compiler(s)/linker can find the files in the first place, since when I remove references to them from the project options, I get file not found errors instead of undefined references. I have little experience with Clang or GCC, and have never attempted to build with them from Visual Studio before.

I have already examined this SO question, but the accepted answer actually contains misinformation. I've also seen this other SO question, which seems to describe the same problem, but that question is concerned with Eclipse; its solution involves makefiles, which isn't applicable in my case.

I have tried every permutation I could come up with modifying various project settings in both the native activity and static library projects: adding various directories to project settings, forward-slashes-vs-backslashes, manually specifying -l commands on the command line to ensure the link order was correct, all for naught.

Clearly, I'm missing something (probably basic) to getting Clang or GCC to link with a third-party library in a Visual Studio project. I appreciate any thoughts anyone might offer me. Thank you.

Community
  • 1
  • 1
Dan
  • 333
  • 4
  • 12
  • Have you considered not using Visual Studio to build, so you can use the existing android toolchain? You can still use Visual studio as an editor. – Gabe Sechan Apr 29 '17 at 19:36
  • @GabeSechan Visual Studio allows you to use the NDK toolchain. I've tried compiling with Clang 3.8 and GCC 4.9, but the results are identical. – Dan Apr 30 '17 at 00:32

1 Answers1

0

Instead of banging my head on this any longer, I decided to build the libraries myself within the solution rather than link to them externally. (The provided Visual Studio templates make it trivial to drop in existing and have it work across all your projects right out of the box.)

This is less of an answer then an alternate solution, but it was the route I ended up taking, and in the end I think it was perhaps the better choice. (To state the obvious, if I end up needing those libraries for multiple projects, then this isn't the most efficient approach. But for now it wasn't worth the headache for me.)

Should anyone ever come across this question in the future and have an answer I would still very much appreciate hearing their input!

Dan
  • 333
  • 4
  • 12