'Undefined symbols for architecture x86_64' for libtorch in swift unit test

When trying to build my tests, I exclusively run into errors such as the following:

Undefined symbols for architecture x86_64:
  "vtable for c10::AutogradMetaInterface", referenced from:
      c10::AutogradMetaInterface::AutogradMetaInterface() in TorchModule.o

None of my fixes have worked so far. I have created an objective-c bridging header for my tests, and here is my Podfile:

# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'

target 'FinalDancer' do
  # Comment the next line if you don't want to use dynamic frameworks

  # Pods for FinalDancer
  pod 'LibTorch', '~> 1.4.0'

  target 'FinalDancerTests' do
    inherit! :search_paths
    # Pods for testing
    pod 'LibTorch', '~> 1.4.0'


Hope this helps, thanks!

For some reason, my xcconfig for test didn’t have the following line:
LIBRARY_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/LibTorch/install/lib"
It was also missing some OTHER_LDFLAGS like pytorch_qnnpack.

Not really sure why or how this fixed it, but I pasted those lines in. There is some code duplication that my compiler is warning me of but my tests are running.

1 Like

@Bryan_Wang has your issue been resolved?

Hi @xta0,

The issue hasn’t been resolved, unfortunately. Instead, there is a runtime error

Unsupported TypeMeta in ATen: float (please report this error)

I suspect that it’s this issue: https://gitmemory.com/issue/pytorch/pytorch/25489/526862641, but I’m not sure how to fix it.

I tried looking for examples of unit tests in the Helloworld project, but there don’t seem to be any examples I can pull from. Any help would be appreciated!


Seems like it’s duplicated with https://github.com/pytorch/pytorch/issues/32040. I can come up with a PR to disable NNPACK, but not sure if it’ll fix your issue. Anyway, I’ll give an update here once I have the PR.

@xta0 Seems like the exact issue I’m experiencing. Thank you!

@Bryan_Wang can you try to apply this PR? https://github.com/pytorch/pytorch/pull/39868? Let me know if the issue still exist. Thanks

I’ll let you know what happens!

Edit: Actually, how do I apply this PR to my XCode project? I am quite new to this. Or if you would like me to test on a sample project, I can do that as well.