MAUI clang: error: no such file or directory when build iOS Project

Junior Jiang 6 Reputation points

I Create a MaUI project, and edit Project Properties -> Build -> Additional arguments enter image description here -cxx -gcc_flags "-L${ProjectDir}/lib -lopencv_world490, -force_load ${ProjectDir}/lib/libopencv_world490.a"

When build, it occurs error as follows:

/usr/local/share/dotnet/packs/Microsoft.iOS.Sdk/16.4.7132/targets/Xamarin.Shared.Sdk.targets(3,3): Error: clang++ exited with code 1:> clang: error: no such file or directory: '${ProjectDir}/lib/libopencv_world490.a'

I also put the lib folder inside three places inside project, it can not work. enter image description here

A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
2,851 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Junior Jiang 6 Reputation points
    1 person found this answer helpful.

  2. Wenyan Zhang (Shanghai Wicresoft Co,.Ltd.) 26,146 Reputation points Microsoft Vendor


    There is a duplicated thread on SO - xamarin.forms - MAUI clang: error: no such file or directory when build iOS Project - Stack Overflow, and you raised an issue at GitHub- using C/C++ library for iOS in maui project · Issue #20136 · xamarin/xamarin-macios · GitHub

    Please follow the rolfbjarne 's comment and use $(MSBuildProjectDirectory) instead of ${ProjectDir}. For the further questions, you could continue to follow the progress at GitHub.


    Solution from Junior Jiang

    I have found a solution to build successfully, however there will be new problem to use the method from .a library.

    Finally, we have found the cause that the .a can not be used. No matter what, replace {PrjectDir}/lib with (MSBuildProjectDirectory)/Platforms/iOS/lib works for me.

    This solution based on the lib folder inside Platforms/iOS.

    And if the .a related to other resource files, you will need to add these files(such as: .bundle) inside Resources/raw.

    Best Regards,

    Wenyan Zhang

    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment". Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments