簡體   English   中英

使用MSYS構建libcurl

[英]Building libcurl using MSYS

我有一個生成文件,該文件可構建libcurl靜態庫以在我的項目中使用(在Linux上完美運行)。

我正在嘗試使用MSYS在Windows 7上構建libcurl,但是我很掙扎。

解決configure腳本中的“錯誤”后,運行了make命令,並且我收到此錯誤:

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

此時,make文件終止。

假設您從此處下載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

通常,您可以使用此腳本在Windows上使用MinGW / MSYS構建任何C / C ++庫,例如cairo,glew,jpeg,libjpeg-turbo,libpng,libxml2,sqlite,zlib,freetype,fontconfig等。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM