去当当网买书,价格更低,送货上门,货到付款。

Windows下使用Subversion Client API编程环境配置

我上研期间所在的项目需要使用subversion的特性,在天涯上发表过这篇文章,今天把它再转在这里。

    当我把编译subversion需要的头文件和依赖的库都配好时,编译能通过,链接却总有问题。当时想找篇使用subversion client api编程的指导文档,好难,网上的相关文章很少,周围的人也都不熟悉subversion,摸索了一个多周,总算迈出最艰难的第一步。小结一下,希望各位大虾不吝赐教。

当时我的环境如下 :

[ OS  ]
     
Windows XP Professional 版本2002 Service Pack 2

[ IDE ]
     Visual C++ 6.0

[ Subversion1.4.2 ]
     
http://subversion.tigris.org/downloads/subversion-1.4.2.zip

[ TortoiseSVN1.4.1 ]
     
http://nchc.dl.sourceforge.net/s ... win32-svn-1.4.2.msi

[ 必须的头文件和静态库 ]
     1)subversion 自身API头文件和静态库:
               http://subversion.tigris.org/downloads/svn-win32-1.4.2_dev.zip
     2)subversion依赖的头文件和库:
               http://subversion.tigris.org/downloads/subversion-deps-1.4.2.zip
               http://subversion.tigris.org/fil ... n-win32-libintl.zip      
               http://subversion.tigris.org/fil ... db-4.4.20-win32.zip

[ 需要加入vc动态链接库的lib文件 ]
     ibsvn_client-1.lib 
     libsvn_delta-1.lib 
     libsvn_diff-1.lib 
     libsvn_fs-1.lib 
     libsvn_fs_base-1.lib 
     libsvn_fs_fs-1.lib 
     libsvn_ra-1.lib 
     libsvn_ra_dav-1.lib 
     libsvn_ra_local-1.lib
     libsvn_ra_svn-1.lib 
     libsvn_repos-1.lib 
     libsvn_subr-1.lib 
     libsvn_wc-1.lib 
     libapr.lib 
     libaprutil.lib 
     xml.lib 
     libneon.lib 
     intl3_svn.lib 
     libdb44s.lib     
     WS2_32.Lib 
     shfolder.lib

注意:起初我没有加入shfolder.lib,结果链接的时候有如下错误:
     libsvn_subr-1.lib(config_win.obj) : error LNK2001: unresolved external symbol __imp__SHGetFolderPathA@20
     libsvn_subr-1.lib(config_win.obj) : error LNK2001: unresolved external symbol __imp__SHGetFolderPathW@20
     Debug/mini_client.exe : fatal error LNK1120: 2 unresolved externals

     就是这个困扰我很久,后来经老张帮助才查到,SHGetFolderPath是Windwos动态链接库shell32.dll的一个函数。MSDN2005对这个函数有如下注释:

This function is a superset of SHGetSpecialFolderPath, included with earlier versions of the Shell. On systems preceeding those including Shell32.dll version 5.0 (Windows Millennium Edition (Windows Me) and Windows 2000), SHGetFolderPath was obtained through SHFolder.dll, distributed with Microsoft Internet Explorer 4.0 and later versions. SHFolder.dll always calls the current platform's version of this function. If that fails, it will try to simulate the appropriate behavior. SHFolder.dll continues to be included for backward compatibility, though the function is now implemented in Shell32.dll.
Note                       
On older systems that require the redistributable SHFolder.dll, you must explicitly link to SHFolder.lib before you link to Shell32.lib.     

     这就是为什么必须要加入shfolder.lib的原因了。

     还有一点需要注意:
      需要在VC的"project setting"对话框 -〉"C/C++"选项 -〉"Use runtime Library"下拉菜单中选择"Debug Multithreaded Dll";也就是相当于将Project Options的第二个参数改为/MDd。否则会出现下面的错误: 
     Linking...
     MSVCRT.lib(MSVCRT.dll) : error LNK2005: _strncmp already defined in LIBC.lib(strncmp.obj)
     MSVCRT.lib(MSVCRT.dll) : error LNK2005: _free already defined in LIBC.lib(free.obj)
     MSVCRT.lib(MSVCRT.dll) : error LNK2005: _strchr already defined in LIBC.lib(strchr.obj)
     MSVCRT.lib(MSVCRT.dll) : error LNK2005: _calloc already defined in LIBC.lib(calloc.obj)
     MSVCRT.lib(MSVCRT.dll) : error LNK2005: _malloc already defined in LIBC.lib(malloc.obj)
     MSVCRT.lib(MSVCRT.dll) : error LNK2005: __close already defined in LIBC.lib(close.obj)
     …...
     MSVCRT.lib(MSVCRT.dll) : error LNK2005: __write already defined in LIBC.lib(write.obj)
     LINK : warning LNK4098: defaultlib "MSVCRT" conflicts with use of other libs; use /NODEFAULTLIB:library
     Debug/mini_client.exe : fatal error LNK1169: one or more multiply defined symbols found
     Error executing link.exe.

     OK!现在从http://svn.collab.net/repos/svn/tags/1.3.2/tools/examples/ 下载 minimal_client.c (一个小的subversion client api演示程序)就能编译运行了。

O(∩_∩)O~~

当当网买书,价格更低,送货上门,货到付款.

posted @ 2009-02-22 22:23  ColinSong  阅读(4046)  评论(4编辑  收藏  举报