2
0

UsingCURLinWin32.txt 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. Background:
  2. Let’s say you need to have a Xmlrpc-c client running as a service.
  3. In this situation you cannot use WinInet. Details of the restriction
  4. can be found on the libcurl website or various Microsoft KB articles.
  5. The alternative is to use libcurl. This document describes the steps
  6. required to use libcurl as your client XML transport mechanism.
  7. Overview:
  8. The default projects in Xmlrpc-c create standalone executables that do
  9. not require other DLL’s (release mode). While the case can be made
  10. for this behavior pro and con, it is beyond this document to justify
  11. it. Therefore, we need to create static link libraries for libcurl
  12. that mimics this behavior. Once the link libraries are created, we
  13. can then add them (plus the requisite curl headers) into the Xmlrpc-c
  14. project. Finally, we enable the compilation of the curl transport
  15. file and tell Xmlrpc-c that we will be using curl. Lastly, we build
  16. and test the project.
  17. Steps to use CURL with Win32 Xmlrpc-c:
  18. 1. Download the CURL source. In the “include” folder of the
  19. CURL distribution, copy the curl directory to the “lib”
  20. directory of xmlrpc-c. When you are done with this step, you should
  21. have a curl.h file located in the directory xmlrpc-c\lib\curl\. The
  22. xmlrpc project looks in this relative path for the necessary headers.
  23. 2. In the CURL distribution, lib directory, is a file called
  24. Makefile.vc6. Edit this file. The line starting with CCNODBG should
  25. be changed to:
  26. CCNODBG = cl.exe /MT /O2 /DNDEBUG
  27. The /MT option links with the Multithreaded non-dll version of the c
  28. runtime. If this change is not made, the project will not link, as
  29. this is the default setting for the Xmlrpc-c projects.
  30. 3. Open a command prompt window and run the vcvars32.bat file in your
  31. Visual C++ distribution. If you are using Studio 2002 or 2003, use
  32. the “Visual Studio Command Prompt” from the Start menu to open
  33. the console.
  34. 4. Compile release and debug mode libraries. For the purposes of this
  35. tutorial, we are going to build only the curl library without ssl or
  36. zlib compression capability. In the command prompt, navigate to the
  37. curl\lib directory and execute the following commands:
  38. nmake -f Makefile.vc6 CFG=debug RTLIBCFG=static
  39. nmake -f Makefile.vc6 CFG=release RTLIBCFG=static
  40. 5. The above step should have generated two static link libraries in
  41. the curl\lib directory: libcurl.lib and libcurld.lib. Copy these
  42. files into the root of the xmlrpc-c\lib\ directory. This step ends
  43. our involvement with the actual CURL distribution. The remainder of
  44. the steps are for Xmlrpc-c.
  45. 6. Open the Xmlrpc-c Visual Studio workspace (Instructions for VC++ 6,
  46. other versions are slightly different). In File View, expand the
  47. xmlrpc project. Under "Source Files" there is an entry for
  48. xmlrpc_curl_transport.c This is not included in any build paths by
  49. default. To enable it for compilation, right click the file to change
  50. the settings. In the dropdown, select "All Configurations." Pick the
  51. General tab and uncheck the "Exclude File From Build" setting. Press
  52. OK to save your changes to the project.
  53. 7. In the "Header Files" section of the xmlrpc project is a file
  54. called "transport_config.h". Edit this file to set the
  55. MUST_BUILD_CURL_CLIENT to 1, and if you wish to change the default
  56. transport to curl, change the XMLRPC_DEFAULT_TRANSPORT to "curl".
  57. 8. Compile and test one or more of the sample client projects.
  58. USING MSVC8 - 2007/11/25
  59. ========================
  60. This is for MSVC8, but most will apply to all version of Microsoft
  61. Visual Studio.
  62. Download the CURL source. Run the buildconf.bat to generate some
  63. additional files. This builds a 'dummy' hugehelp.c, but it can also
  64. be built using the src\mkhelp.pl Perl script. You may have to build
  65. you own VCPROJ file for CURL, if you want to use MSVC. It does
  66. provide a Makefile.vc6 as mentioned above.
  67. To build all the CURL library variations, use
  68. > nmake /nologo vc-all
  69. but note this will use the /MD[d] DLL runtime. Only by adding
  70. RTCFGLIB=static to each of the makefile commands will /MT[d] be
  71. used.
  72. Essentially, for building the static Debug or Release CURL libraries,
  73. it is all the sources in the curl\lib folder. Make sure you choose /MT
  74. and /MTd for the runtime, and build both using say the name libcurl.lib.
  75. When you have Debug\libcurl.lib and Release\libcurl.lib built, you
  76. are ready to build and link them with Xmlrpc-c.
  77. After running xmlrpc-c\Windows\configurewin32.bat, loading xmlrpc.dsw
  78. will convert all the projects to VCPROJ files. In the File View, in
  79. the xmlrpc project, in the properties of xmlrpc_curl_transport.c,
  80. change 'Exclude file from build' from 'yes' to 'no', for Debug
  81. and Release.
  82. In the 'Header Files' section, open the "transport_config.h" file,
  83. and change MUST_BUILD_CURL_CLIENT to 1, and the XMLRPC_DEFAULT_TRANSPORT
  84. to "curl", if desired.
  85. As usual, for each of the 'client' projects, and rpctest, in the properties,
  86. Linker section, you can add the library libcurl.lib on the Input tab, and
  87. the relative path to the library in the General tab to something like -
  88. ..\..\curl\Debug and ..\..\curl\Release, or where ever you built or
  89. copied these static libraries too.
  90. Or you can adjust the Windows/curlink.h, to directly point to your
  91. respective Debug and Release static CURL libraries, either where you
  92. built them, or where you copied them too.
  93. Now, Xmlrpc-c should build using the CURL transport.
  94. Note, for the final linking, all RUNTIME libraries MUST be the SAME.
  95. A mixture of /MD and /MT will give big linkage problems. Any one project
  96. built with the alterate RUNTIME will show many items defined more than
  97. once. And of course, you can also NOT mix Debug with Release. That is
  98. /MDd with /MD, nor /MTd with /MT, or else there will be unresolved
  99. debug items.
  100. EOF