I am working on a Swift library that wraps LibRaw. I have libraw installed via homebrew and everything works great from Xcode. But when I try building my app / library from the CLI with swift
I get a linker error:
ld: library not found for -lstdc++
I unterstand, that libstdc++
is deprecated on macOS and you should link against libc++
. However, I wonder why the build works from within Xcode?
And what should be the correct fix? Should the hombrew formula for libraw patch the library to link against libc++
instead?
I can "fix" the problem by changing the libraw.pc
file installed from homebrew to:
Libs: -L${libdir} -lraw -lstdc++
--> Libs: -L${libdir} -lraw -lc++
Maybe somebody knows how it should work and can share some insights :)
I am using the following module map for my libraw systemTarget
:
module Clibraw [system] {
umbrella header "Clibraw.h"
link "raw"
export *
}
// Clibraw.h:
#import <libraw/libraw.h>
Env:
swift --version
Apple Swift version 5.4.2 (swiftlang-1205.0.28.2 clang-1205.0.19.57)
Target: x86_64-apple-darwin20.6.0
Xcode: Version 12.5.1 (12E507)
macOS: 11.5.1 (20G80)