0

So I run into the following error when trying to run a basic test program that links to an external library (uWS - https://github.com/uWebSockets/uWebSockets):

dyld: lazy symbol binding failed: Symbol not found: _uv_loop_new
  Referenced from: /usr/local/lib/libuWS.dylib
  Expected in: flat namespace

dyld: Symbol not found: _uv_loop_new
  Referenced from: /usr/local/lib/libuWS.dylib
  Expected in: flat namespace

I've found a bunch of other questions and answers related to very similar issues, but they just talk about the library being referenced (in this case libuWS.dylib) not being able to find it's dependencies. I've checked it's dependencies with otool -L libuWS.dylib and they all exist where they should.

I noticed that all the other examples of the error had "expected in" as the library that was missing, which makes sense. I'm just not too sure what flat namespace means, and how I can make sure the symbol is found in it?

The project is build with CLion using the compiler installed with Xcode (I didn't change any settings here, so I guess whatever is the default.. pretty new to coding on macOS, sorry!)

Any pointer in the right direction would be greatly appreciated. Please let me know if I haven't provided enough information.

brads3290
  • 1,926
  • 1
  • 14
  • 20
  • You may need to set `DYLD_LIBRARY_PATH`, e.g. `export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:/usr/local/lib` (or even just `export DYLD_LIBRARY_PATH=/usr/local/lib` if you don't have anything in `DYLD_LIBRARY_PATH` to start with). This assumes the .dylib containing `_uv_loop_new` is in that same `/usr/local/lib`. – Paul R Apr 07 '17 at 16:11
  • I remember trying something with `DYLD_LIBRARY_PATH` yesterday when I was researching.. what should I have in it? It's currently empty and to be honest I don't remember clearing it, but I was pretty tired when I first came across this issue! – brads3290 Apr 07 '17 at 16:13
  • Sorry @PaulR, didn't notice your edit! That's the thing.. I have no idea which lib contains `_uv_loop_new` because it just says it expects it in `flat namespace`, which I have no clue about. EDIT: I also just added both /usr/lib and /usr/local/lib to `DYLD_LIBRARY_PATH`, and it's still complaining with the same error – brads3290 Apr 07 '17 at 16:23
  • Ah - looks like it's not a .dylib, just a static library - you may just need `-luv` (and perhaps an appropriate `-L`) - see [this question](http://stackoverflow.com/q/18816428/253056). – Paul R Apr 07 '17 at 16:30
  • 1
    Nail on the head! Cheers mate, that's got it working :) – brads3290 Apr 07 '17 at 16:36

0 Answers0