btzy / nativefiledialog-extended

Cross platform (Windows, Mac, Linux) native file dialog library with C and C++ bindings, based on mlabbe/nativefiledialog.
zlib License
663 stars 94 forks source link

Setting up Xcode search path for nfd.hpp #111

Closed boonier closed 1 year ago

boonier commented 1 year ago

Hi there

I'm trying to add this library to my project in xcode, but I seem to be stuck on including the header files.

I've compile the static library, and linked to it. The examples are all working well too.

However, from the nfd.h header is included as <nfd.h> from nfd.hpp which suggests that it's a system wide header, right? I get this in nfd.hpp:

image

Have I missed a step in installing it in the right location?

Many thanks

btzy commented 1 year ago

On the command line you would probably add something like -I/path/to/nfd/install to your project. I'm not sure about xcode, but there's probably an equivalent place you can put the installation path.

boonier commented 1 year ago

Okay thanks, I put them in ~/includes and the search path picks them up. (I had to change <nfd.h> -> "nfd.h" in the nfd.hhp)

Now when building, I get these errors:

image

Not sure why they are prefixed with an underscore. Is it an issue with the static library; is it somehow not compiled for arm64 silicon?

Sorry, still learning this stuff!

btzy commented 1 year ago

I think the underscores are just the way name mangling works for C++ functions on your platform.

I think the undefined symbols might be prefixed with an underscore due to the name mangling conventions for arm64 silicon. The problem is probably that you didn't pass the nfd static/shared library to the linker when linking your binary. You need to add libnfd.a (or whatever your library is named) to the linker libraries list.

boonier commented 1 year ago

Thanks, yeah I think it's the name mangling as you say.

I thought I had linked it properly :

image

Undefined symbols for architecture arm64:
  "_OBJC_CLASS_$_UTType", referenced from:
      objc-class-ref in libnfd.a(nfd_cocoa.m.o)
  "_UTTypeData", referenced from:
      _AddFilterListToDialog in libnfd.a(nfd_cocoa.m.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

So the errors seem to derive from nfd_cocoa.m (for e.g. AddFilterListToDialog)

Might it be that I overlooked this stuff? https://github.com/btzy/nativefiledialog-extended#macos

boonier commented 1 year ago

I did over look that stuff. Seems to be compiling and working now :)