如何从swiftc在命令行上链接到CoreGraphics框架

问题描述 投票:0回答:1

我正在编写命令行程序,必须使用CoreGraphics库

使用本地swiftc命令时如何链接CoreGraphics框架?

一些背景知识来解释其原理:

  1. 我正在尝试使用Apple MPS库执行MPSMatrix操作(即计算操作)。

  2. <<
  3. Apple文档here指出,即使在简单的命令行工具中,也需要链接CoreGraphics框架才能使用MPS

  4. 目前正在使用的程序是:
  5. 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框架?只是为了...
swift core-graphics
1个回答
0
投票
swiftc -framework CoreGraphics myprog.swift
© www.soinside.com 2019 - 2024. All rights reserved.