2013-12-22 56 views
0

我有一个makefile,它构建了我的项目中使用的libcurl静态库(在Linux上完美工作)。使用MSYS构建libcurl

我想在Windows 7上使用MSYS构建libcurl,但我很挣扎。

在配置脚本解决“错误”后make命令已运行和我收到此错误:

file.c:569: error: too many arguments to function 'Curl_pgrsSetDownloadCounter' 

此时make文件终止。

+0

是否有任何警告?你是否对代码进行了更改,或者只是执行标准./configure && make?哪个版本的curl和MSYS?我最近在MSYS上编译了curl-7.33,并没有问题。我刚刚检查过,这个函数确实需要两个参数,所以在构建时可能会出现其他问题。 – Brandin

+0

那么有一堆我没有包括的其他错误(只有终止之前的错误)。我使用CURL 7.34和MSYS 1.0。我使用./configure --disabled-shared。 – user3083672

+0

嗯。和你一样,我可以使用MSYS编译libcurl,但是在从makefile中递归运行时出现这些错误。 – user3083672

回答

1

假设你从这里下载的MinGW/MSYS: https://sourceforge.net/projects/mingw/files/latest/download?source=files

安装的MinGW/MSYS,并确保您编辑msys/etc/fstab添加以下行(带标签两条路之间):

C:/<path_to_MinGW>  /mingw 

然后使用记事本或记事本++创建一个名为build.sh的ANSI文本文件并在其中粘贴以下代码:

(您需要将文件顶部的两个路径更改为反映您的文件夹;也是在你的情况下,不需要NASM但我建议你把它)

#!/bin/sh 

# ================================================================================================================================== 
#  _____  __     ______   _          __ 
# /___/___//___ ______ /____/___ _ __(_)________ ____ ____ ___ ___ ____//_ 
#  \__ \/ _ \/ __////__ \ /__//__ \ |///___/ __ \/ __ \/ __ `__ \/ _ \/ __ \/ __/ 
# ___//__/ /_/ /_///_/// /___////|///// /_//////////__/////_ 
# /____/\___/\__/\__,_/ .___/ /_____/_/ /_/|___/_/_/ \____/_/ /_/_/ /_/ /_/\___/_/ /_/\__/ 
#      /_/                  
# ================================================================================================================================== 

# make sure you edit msys/etc/fstab 
# add: C:/<path_to_MinGW>  /mingw 

LIBRARY_SOURCES="/d/MyLibs" 
NASM="/d/mobileFX/Projects/Software/Coconut/IDE/Studio/etc/3rd_party/nasm/nasm.exe" 

cd $LIBRARY_SOURCES 

# ================================================================================================================================== 
#  __ ____ _ __  
# //// /_(_) /____ 
# //// __/// ___/ 
# //_///_//(__ ) 
# \____/\__/_/_/____/ 
#       
# ================================================================================================================================== 

function move_head 
{ 
    count=`ls $1 | wc -l` 
    if [ "$count" -eq "1" ] 
    then   
     t=`ls $1/* -1 -d`  
     for s in `ls -d -1 $1/**/*` 
     do   
      mv $s $1 
     done 
     rm -rf $t 
    fi 
} 

# ================================================================================================================================== 
#  __ __   __  __   __ ____  _______  __ 
# ////___ ____/ /___ _/ /____ /|/ (_)___/____/ | // 
# //// __ \/ __/__ `/ __/ _ \ //|_/// __ \//__ | | /|// 
# //_///_///_///_///_/ __///////// /_//| |/ |// 
# \____/ .___/\__,_/\__,_/\__/\___/ /_/ /_/_/_/ /_/\____/ |__/|__/ 
#  /_/                
# ================================================================================================================================== 

function update_mingw 
{ 
    mingw-get install msys-wget-bin 
    mingw-get install libtool 
    mingw-get install unzip 

    # Download package config and copy executable to mingw/bin 
    wget -c http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/pkg-config_0.23-3_win32.zip 
    7z x ./pkg-config_0.23-3_win32.zip -o./pkg-config -y >& /dev/null 
    rm -f ./pkg-config_0.23-3_win32.zip 
    cp ./pkg-config/bin/pkg-config.exe $MINGW/bin/ 
    rm -rf ./pkg-config 

    # Download glib 
    wget -c http://ftp.gnome.org/pub/gnome/binaries/win32/glib/2.28/glib_2.28.1-1_win32.zip 
    7z x ./glib_2.28.1-1_win32.zip -o./glib -y >& /dev/null 
    rm -f ./glib_2.28.1-1_win32.zip 
    cp ./glib/bin/libglib-2.0-0.dll $MINGW/bin/ 
    rm -rf ./glib 

    # Fixes pkg-config 
    curl -L -s -o gettext-runtime_0.18.1.1-2_win32.zip "http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/gettext-runtime_0.18.1.1-2_win32.zip" 
    7z x ./gettext-runtime_0.18.1.1-2_win32.zip -o./gettext -y >& /dev/null 
    rm -f ./gettext-runtime_0.18.1.1-2_win32.zip 
    cp ./gettext/bin/intl.dll $MINGW/bin/ 
    rm -rf ./gettext 

    # NASM 
    rm -rf $NASM >& /dev/null 
    curl -L -s -o nasm-2.07-win32.zip "https://sourceforge.net/projects/nasm/files/Win32%20binaries/2.07/nasm-2.07-win32.zip/download" 
    7z x ./nasm-2.07-win32.zip -o$NASM -y >& /dev/null 
    rm -f nasm-2.07-win32.zip 
    t=`ls $NASM/* -1 -d` 
    for i in `ls -d -1 $NASM/**/*`; do mv $i $NASM; done 
    rm -rf $t 

} 

# ================================================================================================================================== 
#  ____      __    __ __ _ __     _   
# /__ \____ _  ______//___ ____ _____//// (_) /_ _________ ______(_)__ _____ 
# //// __ \ | /|// __ \//__ \/ __ `/ __///// __ \/ ___/ __ `/ ___//_ \/ ___/ 
# //_///_//|/ |///////_///_///_/// /___///_/////_///// __(__ ) 
# /_____/\____/|__/|__/_/ /_/_/\____/\__,_/\__,_/ /_____/_/_.___/_/ \__,_/_/ /_/\___/____/ 
#                         
# ================================================================================================================================== 

function download_libraries_sources 
{ 
    # IMPORTANT: Make sure you download files as <library_name>.tar.gz 

    echo "Download common libraries (stable versions 21 Mar 2016), please wait..." 

    curl -L -o curl.zip     "http://curl.haxx.se/download/curl-7.47.1.zip" 
    curl -L -o openssl.tar.gz   "https://www.openssl.org/source/openssl-1.0.2g.tar.gz" 
} 

# ================================================================================================================================== 
#  ______  __     __  ___ __                 
# /____/ __/ /__________ ______/ /_ /(_) /_ _________ ________ __ _________ __ _______________ _____ 
# /__/ | |/_/ __/ ___/ __ `/ ___/ __////__ \/ ___/ __ `/ ___///// ___/ __ \////___/ ___/ _ \/ ___/ 
# //____> </ /_/// /_///__/ /_ ////_/////_/////_//(__ ) /_///_/////__/ __(__ ) 
# /_____/_/|_|\__/_/ \__,_/\___/\__/ /_/_/_.___/_/ \__,_/_/ \__,//____/\____/\__,_/_/ \___/\___/____/ 
#                 /____/           
# ================================================================================================================================== 

function delete_sources 
{ 
    # Delete all library foldes 
    echo "Deleting old sources, please wait..." 
    for i in `ls -d */`; do 
     t=$(basename "$i") 
     echo "+ deleting $t, please wait..." 
     rm -rf $t >& /dev/null 
    done 
} 

function extract_library_sources 
{ 
    # Save sources 
    mkdir ./.src >& /dev/null 

    # Extract all library sources 
    echo "Extracting sources, please wait..." 

    for i in `ls *.zip`; do 
     echo + extracting $i... 
     7z x $i -o$(basename "$i" .zip) >& /dev/null 
     mv $i ./.src 
    done 

    for i in `ls *.gz *.xz *.bz2`; do 
     n=`(tar -tf "$i" | head -1 | cut -f1 -d"/") 2>/dev/null` 
     t=$(basename "$i" .tar.gz)  
     t=$(basename "$t" .tar.xz)  
     t=$(basename "$t" .tar.bz2)  
     echo "+ extracting $i to $t ($n) ..." 
     tar xf $i >& /dev/null 
     mv $n $t 
     mv $i ./.src 
    done 

    # Detect master folders within library root and move them to root 
    for i in `ls -d */`; do move_head $i; done 
} 

# ================================================================================================================================== 
#  ______      _ __  __ _ __     _   
# /____/___ ____ ___ ____ (_) /__ // (_) /_ _________ ______(_)__ _____ 
# // /__ \/ __ `__ \/ __ \/// _ \ // // __ \/ ___/ __ `/ ___//_ \/ ___/ 
# //___/ /_/////// /_////__///___///_/////_///// __(__ ) 
# \____/\____/_/ /_/ /_/ .___/_/_/\___/ /_____/_/_.___/_/ \__,_/_/ /_/\___/____/ 
#      /_/                
# ================================================================================================================================== 

function compile_libraries 
{ 
export "INCLUDE_PATH=/usr/local/include" 
export "LIBRARY_PATH=/usr/local/lib" 
export "BINARY_PATH=/usr/local/bin" 

export "CFLAGS=-I/usr/local/include" 
export "CPPFLAGS=-I/usr/local/include" 
export "LDFLAGS=-L/usr/local/lib" 

export "PKG_CONFIG_PATH=/usr/local/lib/pkgconfig" 

# ================================================================================================================================== 
# openssl - OK 
# OpenSSL is a well known standard library supporting SSL, i.e. the encrypted HTTPS web protocol. 
# Depends on: nothing 
# Required by: libcurl 
# ================================================================================================================================== 

cd $LIBRARY_SOURCES/openssl 
./Configure mingw --prefix=/usr/local shared 
make depend 
make 
make install 

# ================================================================================================================================== 
# libcurl - OK 
# libcurl is a well known library supporting URLs (networking, web protocols) 
# Depends on: libz, OpenSSL 
# Required by: XMLHttp 
# ================================================================================================================================== 

cd $LIBRARY_SOURCES/curl 
./configure --prefix=/usr/local --enable-shared=no --with-zlib=/usr/local 
make 
make install-strip 
make distclean 
./configure --prefix=/usr/local --enable-shared=yes --with-zlib=/usr/local 
make 
make install-strip 

} 

update_mingw 
download_libraries_sources 
delete_sources 
extract_library_sources 
compile_libraries 

通常情况下你可以使用这个脚本来构建任何C/C使用的MinGW/MSYS在Windows上,如开罗,GLEW,JPEG ++库, libjpeg-turbo,libpng,libxml2,sqlite,zlib,freetype,fontconfig等。