macOS 开发 - kxsmb 编译 smb库


参考


Rake 正确方式

$ cd /Users/administrator/Downloads/kxsmb-master 
$ rake

运行:


错误方式

$ /Users/administrator/Downloads/kxsmb-master/Rakefile 

报错

Rakefile: line 34: require: command not found
Rakefile: line 35: require: command not found
Rakefile: line 39: syntax error near unexpected token `('
Rakefile: line 39: `def system_or_exit(cmd, stdout = nil)'

安装 autoconf、automake、libtool

运行 $ rake 时如果提示如下,则需要安装 autoconf、automake、libtool

rake aborted!
No Rakefile found (looking for: rakefile, Rakefile, rakefile.rb, Rakefile.rb)

(See full trace by running task with --trace)

安装方法如下:


$ curl -OL http://ftpmirror.gnu.org/autoconf/autoconf-2.69.tar.gz
$ tar -xzf autoconf-2.69.tar.gz 
$ cd autoconf-2.69
$ ./configure && make && sudo make install


//回退到上一级目录,否则安装到 autoconf 中
$ cd ..

$ curl -OL http://ftpmirror.gnu.org/automake/automake-1.14.tar.gz
$ tar -xzf automake-1.14.tar.gz
$ cd automake-1.14
$ ./configure && make && sudo make install

//回退到上一级目录,否则安装到 automake 中
$ cd ..
$ curl -OL http://ftpmirror.gnu.org/libtool/libtool-2.4.2.tar.gz
$ tar -xzf libtool-2.4.2.tar.gz
$ cd libtool-2.4.2
$ ./configure && make && sudo make install

报错 No such file or directory @ rb_sysopen

没有解决,解决了的希望能够告诉我 [哭泣]��

探索过程:

报错详情:


rake aborted!
Errno::ENOENT: No such file or directory @ rb_sysopen - /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/include/crt_externs.h
/Users/administrator/Downloads/kxsmb-master/Rakefile:52:in `copyIfNotExists'
/Users/administrator/Downloads/kxsmb-master/Rakefile:235:in `checkExtInclude'
/Users/administrator/Downloads/kxsmb-master/Rakefile:242:in `block in <top (required)>'
Tasks: TOP => default => build_all => build_smb_armv7
(See full trace by running task with --trace)

可以看出关键在于 crt_externs.h 这个文件;
进入Podfile 查看相关源码,如下:

def checkExtInclude
    extInclude = Pathname.new(EXT_INCLUDE_PATH)
    extInclude.mkpath unless extInclude.exist?   
    copyIfNotExists('crt_externs.h', "#{SIM_SDK_PATH}/usr/include/", extInclude.realpath)
end

通过finder 可以发现 /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/include/ 这个文件夹是存在的,crt_externs.h 确实不存在。
如果不存在,可以拷贝(copyIfNotExists),不至于因此进行不下去。

翻 stack,发现 crt_externs.h 可以存在sdk中。
https://stackoverflow.com/questions/24901919/crt-externs-h-on-ios

通过上文方法去寻找,找到了 crt_externs.h

$ ls /Applications/Xcode.app/Contents/Developer/Platforms/

AppleTVOS.platform      WatchOS.platform        iPhoneSimulator.platform
AppleTVSimulator.platform   WatchSimulator.platform
MacOSX.platform         iPhoneOS.platform

$ find /Applications/Xcode.app/Contents/Developer/Platforms/ -name "crt_externs.h"

/Applications/Xcode.app/Contents/Developer/Platforms//MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/crt_externs.h

crt_externs.h 复制到 /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/include/
再次运行,流程了很多,出来大段大段的进度,然而还是报错了:


../lib/util/fault.c:134:13: error: 'system' is unavailable: not available on iOS
                        result = system(cmdstring);
                                 ^
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include/stdlib.h:195:6: note: 
      'system' has been explicitly marked unavailable here
int      system(const char *) __DARWIN_ALIAS_C(system);
         ^
1 error generated.
The following command failed:
...
...
make: *** [../lib/util/fault.o] Error 1
rake aborted!
******** Build failed ********
/Users/administrator/Downloads/kxsmb-master/Rakefile:42:in `system_or_exit'
/Users/administrator/Downloads/kxsmb-master/Rakefile:219:in `block in buildArch'
/Users/administrator/Downloads/kxsmb-master/Rakefile:218:in `each'
/Users/administrator/Downloads/kxsmb-master/Rakefile:218:in `buildArch'
/Users/administrator/Downloads/kxsmb-master/Rakefile:243:in `block in <top (required)>'
Tasks: TOP => default => build_all => build_smb_armv7
(See full trace by running task with --trace)

今晚洗洗睡。。。


crt_externs.h 源码

去掉注释头,源码如下:
会不会把系统玩坏,我不知道哈 ����

#include <sys/cdefs.h>

__BEGIN_DECLS
extern char ***_NSGetArgv(void);
extern int *_NSGetArgc(void);
extern char ***_NSGetEnviron(void);
extern char **_NSGetProgname(void);
#ifdef __LP64__
extern struct mach_header_64 *
#else /* !__LP64__ */
extern struct mach_header *
#endif /* __LP64__ */
                _NSGetMachExecuteHeader(void);
__END_DECLS

猜你喜欢

转载自blog.csdn.net/lovechris00/article/details/80524801