1DevCpp-Mingw Install & Compilation                                   Sept 2005
2==================================
3
4Reference Emails available at curl@haxx.se:
5
6  Libcurl Install and Use Issues
7  Awaiting an Answer for Win 32 Install
8  res = curl_easy_perform(curl); Error
9  Makefile Issues
10
11
12Having previously done a thorough review of what was available that met my
13requirements under GPL, I settled for Libcurl as the software of choice for
14many reasons not the least of which was the support.
15
16Background
17----------
18
19This quest started when I innocently tried to incorporate the libcurl library
20into my simple source code. I figured that a few easy steps would accomplish
21this without major headaches. I had no idea that I would be facing an almost
22insurmountable challenge.
23
24The main problem lies in two areas. First the bulk of support for libcurl
25exists for a Unix/linux command line environments. This is of little help when
26it comes to Windows O/S.
27
28Secondly the help that does exist for the Windows O/S focused around mingw
29through a command line argument environment.
30
31You may ask "Why is this a problem?"
32
33I'm using a Windows O/S with DevCpp. For those of you who are unfamiliar with
34DevCpp, it is a window shell GUI that replaces the command line environment
35for gcc. A definite improvement that I am unwilling to give up. However using
36DevCpp presented its own set of issues. Inadvertently I also made some
37careless errors such as compiling the 7.14 version of Makefile with an older
38version of source code. Thanks to Dan Fandrich for picking this up.
39
40I did eventually with the help of Daniel, Phillipe and others manage to
41implement successfully (the only mingw available version)
42curl-7.13.0-win32-ssl-devel-mingw32 into the DevCpp environment. Only the
43dynamic libcurl.dll libcurldll.a libraries worked. The static library which I
44was interested in did not. Furthermore when I tried to implement one of the
45examples included with the curl package (get info.c) it caused the executable
46to crash. Tracing the bug I found it in the code and function res =
47curl_easy_perform(curl);.
48
49At this point I had to make a choice as to whether invest my limited
50time-energy resource to fixing the bug or to compile the new version
51available. After searching the archives I found a very similar or the same bug
52reported from version 7.12x on. Daniel did inform me that he thought that this
53bug had been fixed with the latest version. So I proceeded to compile the
54latest SSL version where I faced other challenges.
55
56In order to make this process unremarkable for others using the same
57environment I decided to document the process so that others will find it
58routine. It would be a shame if newbies could not implement this excellent
59package for their use.
60
61I would like to thank the many others in this forum and in the DevCpp forum
62for their help. Without your help I may either have given up or it would have
63taken me many times longer to achieve success.
64
65The Cookbook Approach
66---------------------
67
68This discussion will be confined to a SSL static library compilation and
69installation. Limited mention and comments will be inserted where appropriate
70to help with non-SSL, dynamic libraries and executables.
71
72
73   Using Makefile from DevCpp to compile Libcurl libraries
74
75Preamble
76--------
77
78Using the latest version release - curl-7.14.0.tar.gz. Curl source code is
79platform independent. This simply means that the source code can be compiled
80for any Operating System (Linux/Unix Windows etc. and variations of thereof).
81
82The first thing to note is that inside curl-7.14.0 you will find two folders
83lib and src. Both contain Makefile.m32 (required for win mingw library or exe
84compilation) files which are different. The main difference between these two
85folders and the makefiles is that the src folder contents are used to compile
86an executable file(curl.exe) while the lib folder contents are used to compile
87a static (libcurl.a) and dynamic (libcurl.dll & libcurldll.a) file that can be
88used to compile libcurl with your own source code so that one can use and
89access all libcurl functions.
90
91Before we start please make sure that DevCpp is installed properly. In
92particular make sure you have no spaces in the name of any of the directories
93and subdirectories where DevCpp is installed. Failure to comply with the
94install instructions may produce erratic behaviour in DevCpp. For further info
95check the following sites
96
97http://aditsu.freeunixhost.com/dev-cpp-faq.html
98https://sourceforge.net/p/dev-cpp/discussion/48211/thread/2a85ea46
99
100As I have mentioned before I will confine this to the SSL Library compilations
101but the process is very similar for compilation of the executable - curl.exe;
102just substitute the src folder makefile in its stead.
103
104First use a text processor Notepad, or your own favourite text processor. To
105engage your favourite text processor, select Makefile.m32 click once with your
106mouse on file icon; icon turns blue, press the shift key and right-click on
107mouse, menu appears select "Open with", select your favourite text processor.
108
109Next read the contents of Makefile.m32. It includes instructions on its use.
110
111Method I - DOS Command Line
112---------------------------
113
114Note - The only reason I have included this method is that Method II which is
115the preferred method for compiling does not allow for the setting of option
116switches (e.g. SSL = 1 or SSL =0). At least that's what they tell me at the
117Dev-Cpp forum.
118
1191 - Make a copy of (D:\Dev-Cpp\bin) bin folder and name it "bin Original"
120place it in the Dev-Cpp installed directory (D:\Dev-Cpp\ for this example)
121
1222 - Copy the entire contents of the LIB folder of curl-7.14.0.tar.gz or zip
123version into the bin folder above (D:\Dev-Cpp\bin). The reason being is that
124the make.exe file resides in this folder. Make.exe will use - Makefile.m32,
125Makefile.inc, and the source code included in the lib folder to compile the
126source code. There is a PATH issue with make.exe that remains unresolved at
127least for me. Unless the entire source code to be compiled is placed entirely
128within the directory of make.exe an error message will be generated - "file
129xxxx.yyy not available".
130
1313- Go to Dev-Cpp\bin and double click on make .exe. You will see a DOS window
132quickly pop up and close very quickly. Not to worry! Please do not skip this
133step.
134
1354- Click on the start button\Programs\MS-DOS Prompt.Once the DOS Window is up
136Type the disk drive letter (e.g. E: ) engage the enter button. The path should
137automatically take you to the directory of the make.exe file.
138
1395- To compile the source code simply type at the DOS prompt make -f
140Makefile.m32 as per instructions contained in the Makefile.m32 file (use any
141text processor to read instructions). I don't believe that this makefile
142allows for the option of non SSL. Ignore any warnings.
143
1446- Collect and make copies of libcurl.a, libcurl.dll, libcurldll.a and any *.o
145compilations you might need in another directory outside of the bin directory
146as you will need this files shortly to set up libcurl for use with
147Dev-cpp. For most apps *.o is not required. Later on we will show what to do
148with these files.
149
1507- You are finished but before closing we need to do cleanup - erase the bin
151folder and rename the "bin Original" folder created in step 1 to bin.
152
153Note to compile a curl executable the process is probably similar but instead
154of using the LIB folder contents use the SRC folder contents and Makefiles in
155curl-7.14.0.tar.gz. File directories relative placements must be respected for
156compiling to take place successfully. This may not be possible with the PATH
157problem that make.exe experiences. If anyone has solved this PATH issue and
158please make sure it actually works on Win 9x/2000/XP before letting me
159know. Then please let me or Daniel in on the solution so that it can be
160included with these instructions. Thanks.
161
162or
163
164Method II - Dev-Cpp GUI
165-----------------------
166
1671- Copy the entire contents of the LIB folder of curl-7.14.0.tar.gz or zip
168version into any folder outside of (Dev-Cpp\bin).
169
1702- Drop the File/New/click on Project.
171
1723- New Project Dialogue box appears. Double click on the Static Library.
173
1744- Create Project Dialogue box appears. Select the LIB folder location to
175place and locate your Project File Name. Placing the Project File Name
176elsewhere may cause problems (PATH issue problem again).
177
1785- Drop down the Project/Project Options. Project Options Dialogue box
179appears.
180
1816- Select the Makefile tab in the Project Options Dialogue Box. Check Box -
182Use Custom Makefile. Click on the Folder icon at the extreme right of the
183Check Box. Select Makefile.m32 in the folder wherever you have placed the
184contents of the LIB Folder. Press OK and close the Dialogue Box.
185
1867- Drop the Menu Project/Click on Add to Project. Open File Dialogue Box
187appears.  The Dialogue Box should open in the folder wherever you have placed
188the contents of the LIB Folder. If not go there.
189
1908- Select Crtl-A to select all files in the LIB folder. Click on open to add
191files and close box. Wait till all files are added. This may take 30 seconds
192or longer.
193
1949- Drop the Menu Execute/Click on Compile.
195
19610- That's it.
197
198
199   The following steps must be completed if Curl is to work properly
200   =================================================================
201
202LIB folder inclusions (*.a placement)
203-------------------------------------
204
2051- Refer to Method I - DOS Command Line point # 6 Take libcurl.a, libcurldll.a
206and install it in the directory C( or whichever drive Dev is installed)
207:\Dev-Cpp\lib.
208
209
210Include Folder
211--------------
212
2131- Create a new folder by the name of curl (do not change the name curl to
214some other name as it will cause major issues) in the directory
215C:\Dev-Cpp\include.
216
2172- Copy the entire contents of the curl folder of curl-7.14.0.tar.gz or zip
218 version into the newly created curl directory - C:\Dev-Cpp\include\curl.
219
220Links To Include And Lib Folder
221-------------------------------
222
2231- Drop the Menu - Tools\Compiler Options\Directories\Libraries. Make sure
224that C( or whichever drive Dev is installed):\DEV-CPP\lib is included.
225
2262- Next select the Menu - Tools\Compiler Options\Directories\C Includes. Make
227sure that C:\DEV-CPP\include and C:\Dev-Cpp\include\curl are included.
228
2293- Next select the Menu - Tools\Compiler Options\Directories\C++
230Includes. Make sure that C:\DEV-CPP\include and C:\Dev-Cpp\include\curl are
231included.
232
233Linker Links
234------------
235
2361- Drop the Menu - Tools\Compiler Options\Directories\Compiler.
237
2382- Make sure that the box "Add these commands to the linker command line" is
239checked.
240
2413- Include in the white space immediately below the box referred in 2 -lcurl
242-lws2_32.
243
244SSL Files
245---------
246
2471- Get the latest openSSL (as of time of this writing)
248openssl-0.9.7e-win32-bin.zip for the minimalist package of the openssl-0.9.7e
249binaries ported to MS Windows 95/98/NT/XP using the MingW32/GCC-3.1
250development environment. The file may be downloaded at
251http://curl.haxx.se/download/.
252
2532- Open the above zip file. You will find two files - SDL.dll,
254SDL_mixer.dll. Install them in the directory C:\WINDOWS\SYSTEM32 for Win 9x
255users and c:\winnt\system32 for NT-family users.
256
257Multithreading Files
258--------------------
259
260To be completed
261
262#define
263-------
264
2651- Make sure that your program includes the following - #define CURL_STATICLIB
266must be declared FIRST before any other define functions may be
267added. Otherwise you may experience link errors.
268
2692- Don't forget to include   #include "curl/curl.h".
270
271e.g.
272    #define CURL_STATICLIB
273#include <windows.h>
274    #include "curl/curl.h"
275#include <fstream>
276#include <iostream>
277#include <vector>
278etc...
279
280
281Static or Dynamic Library
282-------------------------
283
284The above steps apply for the use by a static library. Should you choose to
285use a dynamic library you will be required to perform these additional steps.
286
2871- Refer to Method I - DOS Command Line point # 6. Install libcurl.dll in the
288directory C:\WINDOWS\SYSTEM32 for Win 9x users and c:\winnt\system32 for
289NT-family users.
290
2912- Refer to Linker Links point 3 - Replace -lcurl with -lcurldll.
292
293Voila you're done.
294
295The non-SSL static Library build may not be possible to use at least as of the
296time of this writing - v7.14. Check reference emails - Phillipe and I found it
297impossible to fully compile as certain files were missing for linking. No big
298loss as SSL is a major plus.
299
300Hope this Helps
301
302Tom
303