Open JetForMe opened 1 year ago
A solution that could help would be the ability to specify (multiple) search paths for C headers and libraries on the command line
You can specify additional search paths for C headers and libraries like this, -Xcc -I/opt/homebrew/include/gdal -Xcc -I/opt/homebrew/include -L /opt/homebrew/lib/gdal
.
This should not be something specified in Package.swift, as it’s platform-dependent.
You can specify platform-dependent build options using SPM.
You can specify additional search paths for C headers and libraries like this,
-Xcc -I/opt/homebrew/include/gdal -Xcc -I/opt/homebrew/include -L /opt/homebrew/lib/gdal
.
Thanks for that. It seems there’s no way to do that in Xcode; I'll file a bug with Apple.
You can specify platform-dependent build options using SPM.
I mean it's platform-independent, as in as the package author, I can't know where things live on a user's system. They need to be able to specify that for their system. It's not clear to me what default search paths are build into Swift, but /opt/homebrew
is certainly not one of them.
They need to be able to specify that for their system. It's not clear to me what default search paths are build into Swift, but /opt/homebrew is certainly not one of them.
Oh, the pkg-config .pc
files are supposed to provide those paths on linux, and it looks like SPM also expects Homebrew to provide those on macOS.
Yeah, that seems to be the case, but it seems to be unreliable at best with Homebrew.
I frequently work with C libraries, like libmodbus or libgdal, and it seems the only way for Swift to find the headers and libraries is if pkg-config is properly set up. But I just installed GDAL via
brew install gdal
, and it did not installlibgdal.pc
anywhere. I recall it similarly did not installlibmodbus.pc
anywhere, and I had to hand-craft that file.Describe the solution you'd like
A solution that could help would be the ability to specify (multiple) search paths for C headers and libraries on the command line, e.g.
Describe alternatives you've considered
This should not be something specified in
Package.swift
, as it’s platform-dependent.See this post.