我有一個makefile,它構建了我的項目中使用的libcurl靜態庫(在Linux上完美工作)。使用MSYS構建libcurl
我想在Windows 7上使用MSYS構建libcurl,但我很掙扎。
在配置腳本解決「錯誤」後make命令已運行和我收到此錯誤:
file.c:569: error: too many arguments to function 'Curl_pgrsSetDownloadCounter'
此時make文件終止。
我有一個makefile,它構建了我的項目中使用的libcurl靜態庫(在Linux上完美工作)。使用MSYS構建libcurl
我想在Windows 7上使用MSYS構建libcurl,但我很掙扎。
在配置腳本解決「錯誤」後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
通常情況下你可以使用這個腳本來構建任何C/C使用的MinGW/MSYS在Windows上,如開羅,GLEW,JPEG ++庫, libjpeg-turbo,libpng,libxml2,sqlite,zlib,freetype,fontconfig等。
是否有任何警告?你是否對代碼進行了更改,或者只是執行標準./configure && make?哪個版本的curl和MSYS?我最近在MSYS上編譯了curl-7.33,並沒有問題。我剛剛檢查過,這個函數確實需要兩個參數,所以在構建時可能會出現其他問題。 – Brandin
那麼有一堆我沒有包括的其他錯誤(只有終止之前的錯誤)。我使用CURL 7.34和MSYS 1.0。我使用./configure --disabled-shared。 – user3083672
嗯。和你一樣,我可以使用MSYS編譯libcurl,但是在從makefile中遞歸運行時出現這些錯誤。 – user3083672