Linux and Mac build issue

來源:互聯網
上載者:User
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:
以後可以參考這個去定義預先處理宏

#if defined(OSWin_)
    #ifdef OM_BUILD_DLL
        // dll export.
        #define OM_Export       _declspec(dllexport)    
    #else
        // dll import, the normal way to use the library.
        #define OM_Export       _declspec(dllimport)    
    #endif
#elif defined(OSMac_) || defined(OSLinux_)
    #define OM_Export
#endif

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.