Linux and Mac build issues
                                   孙文涛 2008-07-16
(1) Windows上面的lib和dll对应Linux下面的lib**.a 和lib**.so,而生成这个*.a和*.so的文件,即目标文件为*.o 和*.os
so 为Shared Object的简写。
今天我在做跨平台的build时碰到的问题就是用SCons的SharedLibrary的builder,可是在前面的编译阶段却产生的是*.o的文件,而真正需要的是*.os的文件。
在Mac上面StaticLibrary是*.a结尾,SharedLibrary 则是lib**.dylib结尾的。

(2) 今天对link和build的过程有了更新的认识:
compiler将*.cpp文件build为Object file, *.obj on Windows, *.o or *.os on POSIX platform;
link的工具会将这些object file link为一个lib或dll等。

今天早上很早就碰到了link unresolved symbol的问题,在一个project中应该是不会存在这样问题的,最后发现原来我用SCons的Glob的操作后,没有将所有子folder下面的东西都include进来所致。./win,./unix等下面的cpp没有生成*.obj文件。

(3) Typical preprocessor definitions:
以后可以参考这个去定义预处理宏
Linux and Mac build issue#if defined(OSWin_)
Linux and Mac build issue    #ifdef OM_BUILD_DLL
Linux and Mac build issue        
// dll export.
Linux and Mac build issue
        #define OM_Export       _declspec(dllexport)    
Linux and Mac build issue    
#else
Linux and Mac build issue        
// dll import, the normal way to use the library.
Linux and Mac build issue
        #define OM_Export       _declspec(dllimport)    
Linux and Mac build issue    
#endif
Linux and Mac build issue
#elif defined(OSMac_) || defined(OSLinux_)
Linux and Mac build issue    
#define OM_Export
Linux and Mac build issue
#endif

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-21
  • 2021-10-02
  • 2022-12-23
  • 2022-12-23
  • 2021-10-01
猜你喜欢
  • 2021-08-30
  • 2021-12-17
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-14
  • 2021-04-07
相关资源
相似解决方案