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

Junior Jiang 26 Reputation points
2024-02-19T08:50:22.91+00:00

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

.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
3,231 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Junior Jiang 26 Reputation points
    2024-02-23T03:27:56.0133333+00:00
    1 person found this answer helpful.

  2. Wenyan Zhang (Shanghai Wicresoft Co,.Ltd.) 29,381 Reputation points Microsoft Vendor
    2024-02-22T04:44:13.9+00:00

    Hello,

    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.


    Update

    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.

    https://github.com/xamarin/xamarin-macios/issues/20136

    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