gcc,pkg-config,libyaml and etc..

order of lib imports in gcc/lib are importants

the order of lib imports in gcc/lib are importants.

I used to have this command line, the code is as follow.

 
rm -f ../../.ext/i386-mingw32/openssl.so
gcc -shared  -o ../../.ext/i386-mingw32/openssl.so openssl_missing.o ossl.o ossl_asn1.o ossl_bio.o ossl_bn.o ossl_cipher.o ossl_config.o ossl_digest.o ossl_engine.o ossl_hmac.o ossl_ns_spki.o ossl_ocsp.o ossl_pkcs12.o ossl_pkcs5.o ossl_pkcs7.o ossl_pkey.o ossl_pkey_dh.o ossl_pkey_dsa.o ossl_pkey_ec.o ossl_pkey_rsa.o ossl_rand.o ossl_ssl.o ossl_ssl_session.o ossl_x509.o ossl_x509attr.o ossl_x509cert.o ossl_x509crl.o ossl_x509ext.o ossl_x509name.o ossl_x509req.o ossl_x509revoked.o ossl_x509store.o -L.-L../..-L/mingw:/local32/lib -L.-L/local32/lib -mthreads -L/mingw/lib -L/local32/lib -LC:/MinGW/local32/lib -Wl,--enable-auto-image-base,--enable-auto-import-L/mingw/lib -L/local32/lib openssl-i386-mingw32.def-lmsvcrt-ruby210 -lcrypto -lgdi32  -lws2_32 -lwsock32  -lssl  -lgmp -lshell32 -liphlpapi -limagehlp -lshlwapi 

while it has error complaining that undefined referenced to CreateDAC@16 and etc..

then I changed the order of -l{libs}, where the

from 
-lcrypto -lgdi32 -lws2_32 -lwsock32 -lssl

to

-lssl -lcrypto -lws2_32 -lgdi32 -lwsock32

so basically I have moved -lssl, and -lcrypto in front of their dependent libraries, then the compiles just worked fine.

References: 
[ITS#5603) Linking OpenSSL on Windows requires libgdi32 and libws2_32 after libcrypto] (http://www.openldap.org/lists/openldap-bugs/200807/msg00050.html)

 

pkg-config, the libs.private

you might find that the following lines in the pkg-config’s config files.

 
Libs:-L${libdir}-lssl -lcrypto
Libs.private:-lws2_32 -lgdi32 -lcrypt32

that means, if static linked, the -lws2_32 -lgdi32 -lcrypt32 are required, though they are not parts of libraries that are exposed by this package.

http://linux.die.net/man/1/pkg-conf

 

–with-opt-dir

the --with-opt-dir if present tells the build system where to find necessary additional library and header files.

e.g.

 
wget-chttp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p125.tar.gz
tar zvxf ruby-1.9.3-p125.tar.gz
cd ruby-1.9.3-p125
./configure--prefix=/usr/local--enable-shared--disable-install-doc--with-opt-dir=/usr/local/lib
make&&install

where mine is

 
PATH_SEPARATOR=":"./configure --prefix=${LOCALDESTDIR}--enable-shared --disable-install-doc --with-opt-dir=/mingw/lib:${LOCALDESTDIR}&& \
make && \
make install

References: 
ruby安装出现没有libyaml-devel的包

 

Compiling libyaml on Windows

References:

Compiling libyaml on Windows 
Compile error while compiling libyaml under windows 7

the key is to modify the code

 
#lif defined _WIN32#   if defined(YAML_DECLARE_STATIC)#       define  YAML_DECLARE(type)  type#   elif defined(YAML_DECLARE_EXPORT)#       define  YAML_DECLARE(type)  __declspec(dllexport) type#   else#       define  YAML_DECLARE(type)  __declspec(dllimport) type#   endif                                                    #else#   define  YAML_DECLARE(type)  type                         #endif

to

 
#if defined(__MINGW32__)#   define  YAML_DECLARE(type) type#elifdefined _WIN32
#   if defined(YAML_DECLARE_STATIC)#       define  YAML_DECLARE(type)  type#   elif defined(YAML_DECLARE_EXPORT)#       define  YAML_DECLARE(type)  __declspec(dllexport) type#   else#       define  YAML_DECLARE(type)  __declspec(dllimport) type#   endif                                                    #else#   define  YAML_DECLARE(type)  type                         #endif
 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值