【问题标题】:objective-c smb volume mount fsmountservervolumesyncObjective-c smb 卷挂载 fsmountservervolumesync
【发布时间】:2012-05-09 18:26:54
【问题描述】:

我尝试使用找到的代码以编程方式安装卷 here

我在编译时遇到这个错误。

Ld /Users/alex/Library/Developer/Xcode/DerivedData/SambaTestApp-bthesiirajzqwebkatfdkbgalpwc/Build/Products/Debug/SambaTestApp normal x86_64
    cd "/Users/alex/Documents/Xcode Projects/SambaTestApp"
    setenv MACOSX_DEPLOYMENT_TARGET 10.7
    /Developer/usr/bin/clang -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.7.sdk -L/Users/alex/Library/Developer/Xcode/DerivedData/SambaTestApp-bthesiirajzqwebkatfdkbgalpwc/Build/Products/Debug -F/Users/alex/Library/Developer/Xcode/DerivedData/SambaTestApp-bthesiirajzqwebkatfdkbgalpwc/Build/Products/Debug -filelist /Users/alex/Library/Developer/Xcode/DerivedData/SambaTestApp-bthesiirajzqwebkatfdkbgalpwc/Build/Intermediates/SambaTestApp.build/Debug/SambaTestApp.build/Objects-normal/x86_64/SambaTestApp.LinkFileList -mmacosx-version-min=10.7 -fobjc-arc -framework Foundation -o /Users/alex/Library/Developer/Xcode/DerivedData/SambaTestApp-bthesiirajzqwebkatfdkbgalpwc/Build/Products/Debug/SambaTestApp

Undefined symbols for architecture x86_64:
  "_FSMountServerVolumeSync", referenced from:
      _main in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

我的代码是:

#import <Foundation/Foundation.h>

int main (int argc, const char * argv[])
{

    @autoreleasepool {

        NSString * user = @"user";
        NSString * password = @"pass";
        NSURL * url = [NSURL URLWithString: @"smb://lemon"];
        NSURL * mountDir = [NSURL URLWithString: @"/review"];
        OptionBits flags = 0;
        OSStatus err = FSMountServerVolumeSync (
                                                (__bridge CFURLRef) url, 
                                                (__bridge CFURLRef) mountDir, 
                                                (__bridge CFStringRef) user, 
                                                (__bridge CFStringRef) password, 
                                                NULL, 
                                                flags);

        if(err != noErr)
            NSLog( @"some kind of error in FSMountServerVolumeSync - %d", err );
    }
    return 0;
}

【问题讨论】:

  • 我正在尝试做同样的事情,但我收到一条错误消息“函数 'FSMountServerVolumeSync' 的隐式声明在 C99 中无效”,我已尝试导入 但没有运气。你能帮帮我吗?

标签: xcode macos linker compiler-errors core-services


【解决方案1】:

您需要链接到 CoreServices 框架。

【讨论】:

    猜你喜欢
    • 2019-08-24
    • 1970-01-01
    • 1970-01-01
    • 2020-08-07
    • 2021-10-26
    • 2021-07-16
    • 1970-01-01
    • 2020-09-16
    • 2019-10-09
    相关资源
    最近更新 更多