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