gcc,pkg-config,libyaml and etc..

21067 단어 tools

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:  루비 설치에 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

 
 StackEdit Viewer

좋은 웹페이지 즐겨찾기