© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•4mo ago•
19 replies
butteredcoffee

✅ Help with using C++ library in C# code

hello, I am trying to use a c++ library using a .dylib (mac dll) and its giving me a weird error that i can't find a lot of info on, maybe because its unique to osx?
willow@willows-mbp csharp % set DYLD_INSERT_LIBRARIES=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/15.0.0/lib/darwin/libclang_rt.asan_osx_dynamic.dylib
willow@willows-mbp csharp % dotnet run
==10641==ERROR: Interceptors are not working. This may be because AddressSanitizer is loaded too late (e.g. via dlopen). Please launch the executable with:
DYLD_INSERT_LIBRARIES=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/15.0.0/lib/darwin/libclang_rt.asan_osx_dynamic.dylib
"interceptors not installed" && 0
willow@willows-mbp csharp % set DYLD_INSERT_LIBRARIES=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/15.0.0/lib/darwin/libclang_rt.asan_osx_dynamic.dylib
willow@willows-mbp csharp % dotnet run
==10641==ERROR: Interceptors are not working. This may be because AddressSanitizer is loaded too late (e.g. via dlopen). Please launch the executable with:
DYLD_INSERT_LIBRARIES=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/15.0.0/lib/darwin/libclang_rt.asan_osx_dynamic.dylib
"interceptors not installed" && 0

as u can see I tried setting the environment variable to the asan dylib but it didn't work. Idk why asan is coming up at all, I compiled the dylib without address sanitization. The error only occurs when I try to call this function:

[DllImport("libSpaceGame.dylib")]
public static extern void Run();
[DllImport("libSpaceGame.dylib")]
public static extern void Run();


ive never tried to use c++ with c# before, so im very new to this. Any insight is appreicated! The dylib is in the correct folder, as it complained about that before and I moved it
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

C# Code Help
C#CC# / help
3y ago
❔ SSH.Net library using in C# App question
C#CC# / help
3y ago
❔ Using c sharp bindings of a c++ library
C#CC# / help
4y ago
I need help with my c# code
C#CC# / help
15mo ago