我正在编写命令行程序,必须使用CoreGraphics库
使用本地swiftc命令时如何链接CoreGraphics框架?
一些背景知识来解释其原理:
我正在尝试使用Apple MPS库执行MPSMatrix操作(即计算操作)。
Apple文档here指出,即使在简单的命令行工具中,也需要链接CoreGraphics框架才能使用MPS
import CoreGraphics
import Metal
import Foundation
import Accelerate
import MetalPerformanceShaders
guard let device = MTLCreateSystemDefaultDevice() else {
fatalError( "Failed to get the system's default Metal device." )
}
let N = 1000000
// Create a Metal buffer of length N
let buffer = device.makeBuffer(length: N * MemoryLayout<Float32>.size)
// Create a vector descriptor
let descriptor = MPSVectorDescriptor(length: N, dataType: .float32)
// Create a vector with descriptor
let vector = MPSVector(buffer: buffer!, descriptor: descriptor)
此刻在MTLCreateSystemDefaultDevice()调用上失败,我认为这是因为我尚未链接CoreGraphics框架-这就是问题-如何从命令行链接它。
我正在编写命令行程序,并且必须使用CoreGraphics库。使用本机swiftc命令时,如何链接CoreGraphics框架?只是为了...
swiftc -framework CoreGraphics myprog.swift