Building libcURL for QNX 6.3.2 and Windows XP from source

by

To have access on files using FTP, HTTP and directly from file system I use the free library libcurl. Another important aspect is portability as the application should work on QNX using qcc/gcc 4.2.3 and on Windows using VC9/VS2008. So I give libcurl a try. The build process for libcURL is as stated in the documentation very straight forward. But there where two little pitfalls discovered when using VS2008.

Getting the archive from the download page is the same for both operating systems. The executable curl and the library libcurl are distributed in a single archive.

Building for QNX 6.3.2 using gcc 4.2.3

For QNX I decided to only use the required libraries for my project.

As root set the used default compiler for qcc:

# qcc -V4.2.3,gcc_ntox86 -set-default
cc: default set to "4.2.3,gcc_ntox86"
$ cd /usr/src
$ tar -xzf archive/curl-7.18.2.tar.gz
$ cd curl-7.18.2
$ mkdir /usr/src/curl-install
$ ./configure CC=qcc --prefix=/usr/src/curl-install --enable-http --enable-ftp --enable-file \
 --disable-ares --disable-ldap --disable-ldaps --disable-dict --disable-telnet \
 --disable-tftp --disable-sspi --disable-crypto-auth --without-ssl --without-zlib \
 --without-libssh2 --without-gnutls --without-nss --without-libidn
...
$ make
...
$ make install
...

And everything showed up as expected in /usr/src/curl-install.

Building for Windows XP using VS2008

The documented build process is tailored for VC6 and VC8. But VS2008 aka VC9 is a little bit different. So I have had to solve two problems. But here are the steps to succeed.

unzip curl-7.18.2.zip or the tar.gz from above
start cmd.exe

curl-7.18.2> cd D:\_xi\curl\curl-7.18.2
curl-7.18.2> "C:\Programme\Microsoft Visual Studio 9.0\VC\bin\vcvars32.bat"
curl-7.18.2> nmake vc

fails with:

NMAKE : fatal error U1065: invalid option '-'

Due to http://www-1.ibm.com/support/docview.wss? uid=swg21201892 this is caused by a set MAKEFLAGS.

curl-7.18.2> set MAKEFLAGS=
curl-7.18.2> nmake vc8

Microsoft (R) Program Maintenance Utility Version 9.00.21022.08
Copyright (C) Microsoft Corporation.  All rights reserved.

generate VC8 makefiles

curl-7.18.2\lib> cd lib
curl-7.18.2\lib>nmake /f Makefile.vc8 CFG=release-dll

Microsoft (R) Program Maintenance Utility Version 9.00.21022.08
Copyright (C) Microsoft Corporation.  All rights reserved.

cl.exe /O2 /DNDEBUG /MD /I. /I../include /nologo /W3 /EHsc /DWIN32 /FD /c /DBUILDING_LIBCURL /Fo"release-dll\base64.obj"
.\base64.c
base64.c
cl.exe /O2 /DNDEBUG /MD /I. /I../include /nologo /W3 /EHsc /DWIN32 /FD /c /DBUILDING_LIBCURL /Fo"release-dll\cookie.obj"
.\cookie.c
cookie.c
...
LINK : fatal error LNK1181: cannot open input file 'bufferoverflowu.lib'

As stated in http://softwarecommunity.intel.com/isn/Community/en-US/forums/thread/30252971.aspx VS2008 does not need and there has no bufferoverflowu.lib.

Therefore I removed the bufferoverflowu.lib from the WINLIBS definition in lib\Makefile.vc8 and save it as src\Makefile.vc9. And everything works.

curl-7.18.2\lib>nmake /f Makefile.vc9 CFG=release-dll
curl-7.18.2\lib>nmake /f Makefile.vc9 CFG=debug-dll
curl-7.18.2\lib>nmake /f Makefile.vc9 CFG=release
curl-7.18.2\lib>nmake /f Makefile.vc9 CFG=debug

D:\_xi\curl\curl-7.18.2\lib>cd ..\src

Analog to the one above remove bufferoverflowu from src\Makefile.vc8 and save it as src\Makefile.vc9.

D:\_xi\curl\curl-7.18.2\src>nmake /f Makefile.vc9 CFG=release

Microsoft (R) Program Maintenance Utility Version 9.00.21022.08
Copyright (C) Microsoft Corporation.  All rights reserved.

link.exe /incremental:no /libpath:"../lib" /nologo /out:curl.exe /subsystem:console \
 /machine:X86 libcurl.lib wsock32.lib wldap32.lib hugehelpr.obj writeoutr.obj \
 urlglobr.obj getpassr.obj homedirr.obj curlutilr.obj strtoofftr.obj mainr.obj curlr.res

The curl.exe does obiously need the runtime of VS2008. Therefore install the Microsoft Visual C++ 2008 Redistributable Package (x86), e.g. from MSDN there it is named as vcredist_x86.exe. Be sure to copy the curl.exe.manifest along with the binary.

Advertisements

Tags: , , , , , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: