【问题标题】:Do I need to give the option (-arch i386) for both compilation/link?我是否需要为编译/链接提供选项(-arch i386)?
【发布时间】:2023-03-11 13:04:01
【问题描述】:
正如this post 中的询问和回答,我需要为 SWIG/C# 集成提供 -arch i386 选项。
我是否需要同时提供编译/链接选项?
g++ -c -arch i386 example.cxx example_wrap.cxx
g++ -arch i386 -bundle -undefined suppress -flat_namespace example.o example_wrap.o -o libexample.dylib
【问题讨论】:
标签:
macos
shared-libraries
swig
【解决方案1】:
你试过了吗?使用支持 64 位的机器在 OS X 10.6 上使用 C 程序进行的简单测试表明,通常您确实需要为两者指定 -arch。
$ gcc -arch i386 -o x.o x.c
$ gcc x.o -o x.dylib
ld: warning: in x.o, file was built for i386 which is not the architecture being linked (x86_64)
直观地说,链接器确实需要知道要链接哪组特定于体系结构的库。