Macos .a linking issues: "library not loaded"

Hi Yall,

We’re trying to get a big golang project accessible in Unity on OS X. golang offers a C exporter that outputs a header .a library (buildmode=c-shared or c-archive).

The plan was to make a bundle that includes that library while doing necessary. When Unity tries to load our bundle, there’s runtime error that the .a library in the bundle can’t be found (see below). This will be an exciting project to share more about if we can get this step going.

I already tried putting a copy of the .a in the obvious places (alongside the .bundle the Plugins dir and alongside the bundle’s binary).

Runtime error: (buildmode=c-shared)

Couldn’t open /…/PDI.bundle/Contents/MacOS/PDI, error: dlopen(/…/PDI.bundle/Contents/MacOS/PDI, 2): Library not loaded: libloplex.a

Update:

Using golang’s export buildmode=c-archive mode addresses the library not found issue, buuut it consistently crashes Unity when it goes to load/link our bundle. Unity’s trap mechanism doesn’t even get invoked – it’s a force quit. I’ve looked at about 10-15 of them now and they do change here and there, but they hover around this area:

0 libsystem_kernel.dylib 0x00007fff53effcee __psynch_cvwait + 10
1 libsystem_pthread.dylib 0x00007fff5403c662 _pthread_cond_wait + 732
2 libmono.0.dylib 0x00000001395691e2 0x1394c9000 + 655842
3 libmono.0.dylib 0x0000000139559faa 0x1394c9000 + 593834
4 libmono.0.dylib 0x00000001395588a6 0x1394c9000 + 587942
5 ??? 0x0000000139776e58 GC_allocate_ml + 32
6 ??? 0x000000013aa85a37 0 + 5279078967
7 ??? 0x000000013aa843e6 0 + 5279073254
8 ??? 0x000000013aa8420b 0 + 5279072779
9 ??? 0x000000013aa83e86 0 + 5279071878
10 ??? 0x000000013aa74869 0 + 5279008873
11 ??? 0x000000013aa83d93 0 + 5279071635
12 ??? 0x000000013a53d465 0 + 5273539685
13 ??? 0x000000013a5d0cde 0 + 5274143966
14 ??? 0x000000013a5d0a78 0 + 5274143352
15 ??? 0x000000013a55cda0 0 + 5273669024
16 ??? 0x000000013a5d08a6 0 + 5274142886
17 ??? 0x000000013a5d03cf 0 + 5274141647
18 ??? 0x000000013a5578f5 0 + 5273647349
19 ??? 0x000000012365a3ba 0 + 4888830906
20 libmono.0.dylib 0x00000001394d3036 0x1394c9000 + 41014
21 libmono.0.dylib 0x00000001395fec9e mono_runtime_invoke + 117
22 com.unity3d.UnityEditor5.x 0x0000000100ec89da ScriptingInvocation::Invoke(ScriptingExceptionPtr*, bool) + 106
23 com.unity3d.UnityEditor5.x 0x0000000100e794a7 MonoBehaviour::CallMethodIfAvailable(int) + 455
24 com.unity3d.UnityEditor5.x 0x00000001008052cb void BaseBehaviourManager::CommonUpdate() + 507
25 com.unity3d.UnityEditor5.x 0x000000010080508f BehaviourManager::Update() + 47
26 com.unity3d.UnityEditor5.x 0x0000000100ab5198 InitPlayerLoopCallbacks()::UpdateScriptRunBehaviourUpdateRegistrator::Forward() + 40
27 com.unity3d.UnityEditor5.x 0x0000000100ab58f3 PlayerLoop() + 963
28 com.unity3d.UnityEditor5.x 0x0000000101834a74 PlayerLoopController::UpdateScene(bool) + 564
29 com.unity3d.UnityEditor5.x 0x000000010183046c PlayerLoopController::UpdateSceneIfNee