`

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
 
分享到:
评论

相关推荐

    arm-linux-gcc-4.4.3.tar.gz

    这些通常包括`build-essential`,`binutils`,`pkg-config`等。通过运行以下命令可以安装它们: ```bash sudo apt-get update sudo apt-get install build-essential binutils-dev libncurses5-dev libncursesw5-...

    \Linux下库的设置:ld.so.conf_文件与PKG_CONFIG_PATH变量

    $ gcc sample.c -o sample `pkg-config --cflags --libs glib-2.0` 可以看到,使用 pkg-config 工具可以使得编译和连接命令变得统一,不论库安装在什么目录下。 在使用 pkg-config 工具时,需要注意两个基本的前提...

    Ubuntu Mapnik、Python-Mapnik 安装

    sudo apt-get install python zlib1g-dev clang make pkg-config curl # 下载并解压 Mapnik wget -O mapnik.tar.bz2 \\192.168.80.166\data\mapnik3-x\mapnik.tar.bz2 tar jxvf mapnik.tar.bz2 cd mapnik-3.x # ...

    linux静态库与动态库

    另外,`pkg-config`工具提供了一种更方便的方式,可以列出所有可用的包,并在编译时自动提供所需的参数,如:`gcc -o test test.c `pkg-config xxx --libs --cflags``,其中`xxx`是具体使用的包名。 总之,理解...

    linux opencv 和 ecplise 的配置

    - 在`GCC C++ Linker -> Miscellaneous`中添加`pkg-config --libs opencv`。 3. **编译测试程序**: - 创建一个简单的C++测试程序,如`drawing.cpp`。 - 使用命令`g++ `pkg-config --cflags --libs opencv` ...

    Win32下MinGW与MSYS安装介绍

    - 使用`pkg-config`工具获取GTK+相关的`include`和`library`路径。 - 在命令行下进入`D:\Gtk+\bin>`目录,执行以下命令: ```sh pkg-config --cflags gtk+-2.0 pkg-config --libs gtk+-2.0 ``` - 运行`D:\...

    mongodb-linux-x86-64-3.6.9.tgz linux 安装程序

    sudo apt-get install build-essential cmake libssl-dev pkg-config libcurl4-openssl-dev libjemalloc-dev ``` 3. **配置和编译**: 进入解压后的目录,运行`configure`脚本来生成Makefile,然后使用`make`...

    mysql读写分离配置

    export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/lib/pkgconfig ``` #### 安装配置MySQL-Proxy 1. **下载MySQL-Proxy**: 下载并解压MySQL-Proxy的二进制文件。 ```bash wget ...

    CENTOS8安装SDL2步骤分享

    在安装SDL2之前,我们需要先安装必要的编译工具和依赖项,例如`gcc`、`make`以及`pkg-config`等: ```bash sudo dnf install -y gcc make pkg-config ``` 现在我们可以开始安装SDL2库了。这里我们有一个名为`SDL2-...

    linux下更新GTK+到3.x.docx

    使用`pkg-config`来查询各库的版本,例如`pkg-config --modversion gtk+-2.0`。确保所有库的版本符合GTK+ 3.x的要求。 3. **安装步骤**: - **更新pkg-config**:如果`pkg-config`版本过低,需要先升级。在GTK+的...

    OK210-arm-linux-Qt移植开发文档

    export PKG_CONFIG_PREFIX=$TOOLCHAIN/arm-linux ``` - 通过命令`source /etc/profile`使这些设置立即生效。 3. **解压并安装TSLIB** - 解压`tslib1.4.tar.gz`文件:`tar -zxvf tslib1.4.tar.gz`。 - 进入...

    PostGIS源代码安装指南

    export PKG_CONFIG_PATH=/usr/local/protobuf-3.6.1/lib/pkgconfig export PROTOBUF_HOME=/usr/local/protobuf-3.6.1 export PATH=$CMAKE_HOME/bin:$PROTOBUF_HOME/bin:$PATH source /etc/profile ``` - **说明...

    关于raspberry的一些实例和详细说明

    apt-get install pkg-config apt-get install libgtk2.0-dev libgtk2.0 apt-get install zlib1g-dev apt-get install libpng-dev apt-get install libjpeg-dev apt-get install libtiff-dev apt-get install ...

    qemukvm详细教程[借鉴].pdf

    sudo apt-get install gcc libsdl1.2-dev zlib1g-dev libasound2-dev linux-kernel-headers pkg-config libgnutls-dev libpci1 pciutils-dev ``` 然后,下载最新的 qemu-kvm-0.12.4.tar.gz,解压缩: ```bash tar ...

    lessfs安装和使用

    - **编译**:`#gcc -Wall \`pkg-config fuse --cflags --libs\` hello.c -o hello` - **挂载**:`#./hello ./test`(此处 `test` 是一个空的挂载目录)。 - **验证**:进入挂载目录,执行 `#ls` 命令,会发现一个...

    tesserarct安装.docx

    export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig ``` 然后保存并关闭文件,使修改生效: ```bash source /etc/profile ``` #### 六、安装Tesseract OCR 完成上述步骤后,可以开始安装Tesseract OCR本身。 ```...

Global site tag (gtag.js) - Google Analytics