在MinGW下编译STLport

时间:2022-11-09 20:01:06

    MinGW 内置的标准库对Unicode不支持,所以我要在MinGW下编译STLport。

    MinGW版本:我的MinGW并不是选择的整合安装包,而是到www.mingw.org上下载当前的release版本组合起来的,g++的版本是3.42,make(mingw32-make)的版本是3.80。

    STLport版本:5.13,当前最新的release版本。

    假设mingw的安装目录为$mingwdir,stlport的安装目录为$stlportdir。

   1.将$mingwdir/bin设置在系统的path中。

   2.打开控制台,输入下面的命令:

  •  cd $stlport/build/lib
  •  configure -c gcc 
  • mingw32-make -fgcc.mak clean install-shared install-static

   3.经过漫长的等待,stlport就生成了,在$stlportdir/bin下面有动态版本,在$stlportdir/lib下面有动态和静态的库文件,可以把动态链接库复制到系统目录下面共享,把include和lib目录前置到mingw内置的库之前。

    4.注意事项:

  • STLport默认的编译目标all是只编译动态版本的 ,如果你只想要动态或者静态版本可以选择性编译。
  • mingw32-make -fgcc.mak clean 用来清除编译结果。
  • mingw32-make -fgcc.mak clobber 用来清除临时文件。    

    5.STLport在mingw中的使用

         先把$stlportdir/bin加入到系统path中,或者干脆把他们复制到系统文件夹,以便于执行的时候查找到它们。

  • 使用stlport动态库的方法:g++ main.cpp -mthreads -I$stlportdir/stlport -L$stlport/lib -lstlport.5.1 (stlport.5.1为ld指定stlport的动态链接库,如版本不同,就更改文件名)
  • 使用stlport静态库的方法:g++ main.cpp -mthreads -static D_STLP_USE_STATIC_LIB  -I$stlportdir/stlport -L$stlport/lib  -lstlport.5.1

    6.关于其他版本的stlport

        我尝试用g++3.42编译stlport 4.x版本,但是没有成功,在msys下面会提示编译错误。用g++3.42编译stlport5.0x的时候,则必须在msys下面输入上面的命令行内容才能编译成功,而5.1x则不需要这样。