开发者

Can I build both 32-bit and 64-bit architectures of a library on Mac OS?

开发者 https://www.devze.com 2023-04-13 02:45 出处:网络
I need to build a library (Ipopt) on Mac OS X and use it from two different programs (Python & Matlab). However, one program is 32-bit and the other is 64-bit. Do I have to build two separate libr

I need to build a library (Ipopt) on Mac OS X and use it from two different programs (Python & Matlab). However, one program is 32-bit and the other is 64-bit. Do I have to build two separate libraries of the two architectures then set the path accordingly for each program? Or can I build both architecture开发者_JAVA技巧s in the same library file(s) and the program will select the correct architecture to load? If I can, then how?

Thanks!


You can build both architectures and combine them into a single binary. The tool to do this is lipo.

For example, if you had built libpopt as a 32 bit library and placed it in lib/, and built it again as a 64 bit library and placed that in lib64/, then the command to combine these two could be:

lipo lib/libpopt.a lib64/libpopt.a -create -output libUniversal/libpopt.a

For more information, see the lipo man page (here, or through man lipo).

0

精彩评论

暂无评论...
验证码 换一张
取 消