xamarin / xamarin-macios

.NET for iOS, Mac Catalyst, macOS, and tvOS provide open-source bindings of the Apple SDKs for use with .NET managed languages such as C#
Other
2.44k stars 509 forks source link

Binding native static library build fail. #15062

Closed xtuzy closed 2 years ago

xtuzy commented 2 years ago

Steps to Reproduce

  1. Download source code from https://github.com/xtuzy/ApplePDF/tree/ApplePDF
  2. Build ApplePDF.Demo.Maui project for ios

Expected Behavior

Build success

Actual Behavior

Build Fail Show:

Undefined symbols for architecture x86_64:
1>      "_??0FPDF_CharsetFontMap_@@QEAA@AEBU0@@Z", referenced from:
1>         -u command line option
1>      "_??0_FPDF_SYSFONTINFO@@QEAA@AEBU0@@Z", referenced from:
1>         -u command line option
1>      "_FPDFPath_GetMatrix", referenced from:
1>         -u command line option
1>      "_??0FPDF_COLORSCHEME_@@QEAA@AEBU0@@Z", referenced from:
1>         -u command line option
1>      "_FPDFFormObj_GetMatrix", referenced from:
1>         -u command line option
1>      "_??0FS_POINTF_@@QEAA@AEBU0@@Z", referenced from:
1>         -u command line option
1>      "_??0FPDF_IMAGEOBJ_METADATA@@QEAA@AEBU0@@Z", referenced from:
1>         -u command line option
1>      "_??0_FX_DOWNLOADHINTS@@QEAA@AEBU0@@Z", referenced from:
1>         -u command line option
1>      "_??0_FPDF_FORMFILLINFO@@QEAA@AEBU0@@Z", referenced from:
1>         -u command line option
1>      "_FPDFPath_SetMatrix", referenced from:
1>         -u command line option
1>      "_??0_FPDF_SYSTEMTIME@@QEAA@AEBU0@@Z", referenced from:
1>         -u command line option
1>      "_??0_IFSDK_PAUSE@@QEAA@AEBU0@@Z", referenced from:
1>         -u command line option
1>      "_??0_FX_FILEAVAIL@@QEAA@AEBU0@@Z", referenced from:
1>         -u command line option
1>      "_??0_IPDF_JsPlatform@@QEAA@AEBU0@@Z", referenced from:
1>         -u command line option
1>      "_FPDFTextObj_GetFontName", referenced from:
1>         -u command line option
1>      "_??0FPDF_FILEWRITE_@@QEAA@AEBU0@@Z", referenced from:
1>         -u command line option
1>      "_??0FPDF_LIBRARY_CONFIG_@@QEAA@AEBU0@@Z", referenced from:
1>         -u command line option
1>      "_??0FPDF_FILEHANDLER_@@QEAA@AEBU0@@Z", referenced from:
1>         -u command line option
1>      "_??0FS_SIZEF_@@QEAA@AEBU0@@Z", referenced from:
1>         -u command line option
1>      "_FPDFImageObj_GetMatrix", referenced from:
1>         -u command line option
1>      "_??0_FS_RECTF_@@QEAA@AEBU0@@Z", referenced from:
1>         -u command line option
1>      "_??0_FS_QUADPOINTSF@@QEAA@AEBU0@@Z", referenced from:
1>         -u command line option
1>      "_FPDFTextObj_GetMatrix", referenced from:
1>         -u command line option
1>      "_??0_FS_MATRIX_@@QEAA@AEBU0@@Z", referenced from:
1>         -u command line option
1>      "_??0FPDF_FILEACCESS@@QEAA@AEBU0@@Z", referenced from:
1>         -u command line option
1>      "_??0FPDF_BSTR_@@QEAA@AEBU0@@Z", referenced from:
1>         -u command line option
1>    ld: symbol(s) not found for architecture x86_64
1>    clang: error: linker command failed with exit code 1 (use -v to see invocation)

I don't know what it mean, i checked the .a file have x86_64 sharex-20220519011331

I download .a from pdfium-lib, native developer can use it.

I use .a file according to https://docs.microsoft.com/en-us/xamarin/ios/platform/native-interop

Environment

Version information ``` Microsoft Visual Studio Community 2022 Version 17.3.0 Preview 1.0 VisualStudio.17.Preview/17.3.0-pre.1.0+32505.426 Microsoft .NET Framework Version 4.8.09032 Installed Version: Community Visual C++ 2022 00482-10000-00261-AA687 Microsoft Visual C++ 2022 ASP.NET and Web Tools 2019 17.3.122.33185 ASP.NET and Web Tools 2019 AvaloniaPackage Extension 1.0 AvaloniaPackage Visual Studio Extension Detailed Info Azure App Service Tools v3.0.0 17.3.122.33185 Azure App Service Tools v3.0.0 C# Inline Color Vizualizer 1.3 See samples of the colors you use within your C# code. C# Tools 4.3.0-1.22254.1+9919d7e7bd753404a5d2328e5e3fb2de635169f3 C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used. Code alignment 15.1.118.0 Code alignment helps you present your code beautifully, enhancing clarity and readability. CodeMaid 12.0 CodeMaid is an open source Visual Studio extension to cleanup and simplify our C#, C++, F#, VB, PHP, PowerShell, R, JSON, XAML, XML, ASP, HTML, CSS, LESS, SCSS, JavaScript and TypeScript coding. CodeNav 1.0 Show the code structure of your current document Common Azure Tools 1.10 Provides common services for use by Azure Mobile Services and Microsoft Azure Tools. CreateUnitTestBoilerplateCommand Extension 1.0 CreateUnitTestBoilerplateCommand Visual Studio Extension Detailed Info Extensibility Message Bus 1.2.6 (master@34d6af2) Provides common messaging-based MEF services for loosely coupled Visual Studio extension components communication and integration. GitHub Copilot 1.14.0.1 (v1.14.0.1@c80f05666) GitHub Copilot is an AI pair programmer that helps you write code faster and with less work. GitHub Copilot Agent 1.14.5744 (v1.14.0) IndentRainbowPackage Extension 1.0 IndentRainbowPackage Visual Studio Extension Detailed Info Microsoft JVM Debugger 1.0 Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines Mono Debugging for Visual Studio 17.3.7 (c1ffb2a) Support for debugging Mono processes with Visual Studio. NamespaceFixer 2.9.0 VS Extension to fix namespaces following C# and VB.NET convention NuGet Package Manager 6.3.0 NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/ Open Command Line 2.4.236 2.4.236 Razor (ASP.NET Core) 17.0.0.2222701+751db1ebea5e6a9ecc7fa57fe447180422afa610 Provides languages services for ASP.NET Core Razor. ReloadPreviewTool Extension 1.0 ReloadPreviewTool Visual Studio Extension Detailed Info StylerPackage Extension 1.0 StylerPackage Visual Stuido Extension Detailed Info SubwordNavigation 2.0.0 Provides subword navigation for Visual Studio. Syntax Visualizer 1.0 An extension for visualizing Roslyn SyntaxTrees. Test Adapter for Boost.Test 1.0 Enables Visual Studio's testing tools with unit tests written for Boost.Test. The use terms and Third Party Notices are available in the extension installation directory. Test Adapter for Google Test 1.0 Enables Visual Studio's testing tools with unit tests written for Google Test. The use terms and Third Party Notices are available in the extension installation directory. TypeScript Tools 17.0.10420.2001 TypeScript Tools for Microsoft Visual Studio UnoPlatformPackage Extension 1.0 UnoPlatformPackage Visual Studio Extension Detailed Info Visual Basic Tools 4.3.0-1.22254.1+9919d7e7bd753404a5d2328e5e3fb2de635169f3 Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used. Visual F# Tools 17.1.0-beta.22178.3+6da0245a7ce4bb8483b8d1f2993c8ecaea967ad9 Microsoft Visual F# Tools Visual Studio Inline Suggestions 2.2.1994.35131 Ghost text API for Visual Studio inline suggestions Visual Studio IntelliCode 2.2 AI-assisted development for Visual Studio. Visual Studio Spell Check Everywhere VSSpellCheckEverywhere An extension that enables spell checking within any Visual Studio file editor or tool window that uses WPF text boxes. https://GitHub.com/EWSoftware/VSSpellChecker Visual Studio Spell Checker VSSpellChecker An editor extension that checks the spelling of comments, strings, and plain text as you type or interactively with tool windows. https://GitHub.com/EWSoftware/VSSpellChecker VisualStudio.DeviceLog 1.0 Information about my package VisualStudio.Mac 1.0 Mac Extension for Visual Studio VSPackage Extension 1.0 VSPackage Visual Studio Extension Detailed Info Xamarin 17.3.0.91 (main@7802af5) Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android. Xamarin Designer 17.3.0.30 (remotes/origin/main@fb6442dc1) Visual Studio extension to enable Xamarin Designer tools in Visual Studio. Xamarin Templates 17.2.15 (2e3b60e) Templates for building iOS, Android, and Windows apps with Xamarin and Xamarin.Forms. Xamarin.Android SDK 12.3.99.58 (main/64b22fc) Xamarin.Android Reference Assemblies and MSBuild support. Mono: adf1bc4 Java.Interop: xamarin/java.interop/release/6.0.3xx@2a882d2d ProGuard: Guardsquare/proguard/v7.0.1@912d149 SQLite: xamarin/sqlite/3.38.2@7b1e016 Xamarin.Android Tools: xamarin/xamarin-android-tools/main@fc3c2ac Xamarin.iOS and Xamarin.Mac SDK 15.11.0.87 (406f3098e) Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support. ```

Build Logs

Output-Build.txt

Example Project (If Possible)

chamons commented 2 years ago

I downloaded the relevant native library and can confirm with nm those symbols do not exist:

 nm /Users/donblas/Downloads/release/lib/libpdfium.a  | grep 0_FX_FILEAVAIL
nm /Users/donblas/Downloads/release/lib/libpdfium.a --arch x86_64  | grep CharsetFontMap  

And those symbols are part of the ApplePDF.Binding project:

% git grep CharsetFontMap
ApplePDF.Binding/PDFiumCore.cs:            [SuppressUnmanagedCodeSecurity, DllImport("pdfium", EntryPoint = "??0FPDF_CharsetFontMap_@@QEAA@AEBU0@@Z", CallingConvention = __CallingConvention.Cdecl)]
ApplePDF.Binding/PDFiumCore.cs:        internal static readonly global::System.Collections.Concurrent.ConcurrentDictionary<IntPtr, global::PDFiumCore.FPDF_CharsetFontMap> NativeToManagedMap = new global::System.Collections.Concurrent.ConcurrentDictionary<IntPtr, global::PDFiumCore.FPDF_CharsetFontMap>();

Given this, this is not a Xamarin.iOS or Mac bug. Please consider reaching out to the ApplePDF for assistance.

xtuzy commented 2 years ago

@chamons Hello, Can build binding library at VisualStudio? Yestoday i try to build webp library at VisualStudio, it have Paired to Mac, but fail, see https://twitter.com/H_N_B_D_D/status/1529874720602181634?s=20&t=RRvACXRzpQlH3Q43k-GWsQ , Today i copy project to mac, use VisualStudio for Mac build it, success!

chamons commented 2 years ago

@xtuzy - For IDE issues such as pairing to a mac the best way for reaching out to that team is to open an issue at https://developercommunity.visualstudio.com/home

That team is not accessible from github issues.