我有一个makefile,用于构建libcurl静态库以在我的项目中使用(在Linux上完美运行)。
我正在尝试使用MSYS在Windows 7上构建libcurl,但我正在努力。
解决了配置脚本中的'errors'后,运行了make命令,我收到了这个错误:
file.c:569: error: too many arguments to function 'Curl_pgrsSetDownloadCounter'
此时make文件终止。
答案 0 :(得分: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
通常你可以使用这个脚本在Windows上使用MinGW / MSYS构建任何C / C ++库,例如cairo,glew,jpeg,libjpeg-turbo,libpng,libxml2,sqlite,zlib,freetype,fontconfig等。 / p>