[GNU] Cross-Compiler

Cross-Compiler is a compiler that can compile a executable file which can execute on a different platform.

Like gcc on Linux can get a ARM executable file.

The advantage is that we can get the exe file through a high-performance x86 PC, instead of ARM CPU. And it’ll make the compile time more faster.

 

LIBRARY_PATH / LD_LIBRARY_PATH :

LIBRARY_PATH: 

環境變數用於在程式編譯期間查找動態連結程式庫時指定查找共用庫的路徑,例如,指定gcc編譯需要用到的動態連結程式庫的目錄。設置方法如下(其中,LIBDIR1和LIBDIR2為兩個庫目錄):

export LIBRARY_PATH=LIBDIR1:LIBDIR2:$LIBRARY_PATH

LD_LIBRARY_PATH: 

環境變數用於在程式載入運行期間查找動態連結程式庫時指定除了系統預設路徑之外的其他路徑,注意,LD_LIBRARY_PATH中指定的路徑會在系統預設路徑之前進行查找。設置方法如下(其中,LIBDIR1和LIBDIR2為兩個庫目錄):

export LD_LIBRARY_PATH=LIBDIR1:LIBDIR2:$LD_LIBRARY_PATH

舉個例子,我們開發一個程式,經常會需要使用某個或某些動態連結程式庫,為了保證程式的可攜性,可以先將這些編譯好的動態連結程式庫放在自己指定的目錄下,然後按照上述方式將這些目錄加入到LD_LIBRARY_PATH環境變數中,這樣自己的程式就可以動態連結後載入庫檔運行了。

區別與使用:

開發時,設置LIBRARY_PATH,以便gcc能夠找到編譯時需要的動態連結程式庫。

發佈時,設置LD_LIBRARY_PATH,以便程式載入運行時能夠自動找到需要的動態連結程式庫。

來自 <http://ryan0988.pixnet.net/blog/post/171244470-%E4%BB%80%E9%BA%BC%E6%98%AFcross-compiler-%3F>

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s