分类 IT Technology 下的文章

int family = iterator->ai_family;
t_socket sock;
const char *err = inet_trycreate(&sock, family, SOCK_STREAM);
if (err) {
    continue; // check next
} else {
    t_timeout tm;
    struct addrinfo connecthints;
    memset(&connecthints, 0, sizeof(connecthints));
    connecthints.ai_socktype = SOCK_STREAM;
    /* make sure we try to connect only to the same family */
    connecthints.ai_family = family;
    
    if (family == PF_INET6) {
        int yes = 1;
        setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, (void *)&yes, sizeof(yes));
    }
    timeout_markstart(&tm);
    err = inet_tryconnect(&sock, &family, (const char *)hbuf, "3006", &tm, &connecthints);
    if (err) {
        socket_destroy(&sock);
        continue; // check next
    } else {
        // find success one
        CCLOG("== xx:%s", hbuf);
    }
}

编译png

$cmake .. -DPNG_STATIC=ON -DZLIB_INCLUDE_DIR=/home/u0u0/works/Cocos2d-thirdpart/tarballs/zlib-1.2.8/ -DZLIB_LIBRARY=/home/u0u0/works/Cocos2d-thirdpart/tarballs/zlib-1.2.8/

编译websockets

$cmake .. -DOPENSSL_ROOT_DIR=/home/u0u0/works/Cocos2d-thirdpart/tarballs/openssl-1.1.0c -DZLIB_INCLUDE_DIR=/home/u0u0/works/Cocos2d-thirdpart/tarballs/zlib-1.2.8/ -DZLIB_LIBRARY=/home/u0u0/works/Cocos2d-thirdpart/tarballs/zlib-1.2.8/ -DLWS_WITH_LIBUV=OFF -DLWS_WITH_SSL=ON -DLWS_WITH_SHARED=OFF -DLWS_WITHOUT_TEST_SERVER=ON -DLWS_WITHOUT_TEST_SERVER_EXTPOLL=ON -DLWS_WITHOUT_TEST_PING=ON -DLWS_WITHOUT_TEST_ECHO=ON -DLWS_WITHOUT_TEST_CLIENT=ON -DLWS_WITHOUT_TEST_FRAGGLE=ON -DLWS_IPV6=ON

编译OpenSSL

在 Linux 下自定义OpenSSL库,需要安装到一个路径,以便curl能找到。

./config --prefix=/home/u0u0/works/projects/Cocos2d-thirdpart/tarballs/openssl_install --openssldir=/home/u0u0/works/projects/Cocos2d-thirdpart/tarballs/openssl_install
make
make install

编译curl

./configure --enable-static --disable-ldap --enable-ipv6 --with-zlib=/home/u0u0/works/Cocos2d-thirdpart/tarballs/zlib-1.2.8/ --with-ssl=/home/u0u0/works/projects/Cocos2d-thirdpart/tarballs/openssl_install --prefix=/home/u0u0/works/projects/Cocos2d-thirdpart/tarballs/curl_install
make
make install

编译OpenAL

$sudo apt-get install libasound2-dev
$cmake .. -DLIBTYPE=STATIC -DALSOFT_INSTALL=OFF -DALSOFT_REQUIRE_ALSA=ON

  1. 安装配置 mbpfan 风扇控制器: https://github.com/linux-on-mac/mbpfan
    mbpfan.service文件从github获取。

    sudo apt-get install mbpfan
    sudo cp mbpfan.service /etc/systemd/system/
    sudo systemctl enable mbpfan.service
    sudo systemctl daemon-reload
    sudo systemctl start mbpfan.service
  2. “软件和更新”中启用附加驱动,使用专有驱动。
  3. 安装最新的tlp电源管理。

    sudo apt install tlp
    sudo systemctl enable tlp.service
    sudo systemctl daemon-reload
    sudo systemctl start mbpfan.service
    sudo tlp start

macOS 10.14之后不支持交叉编译32位程序。退求其次,虚拟机装ubunut来解决问题。
ubunut 64系统,默认不带32相关头文件和库,需要

sudo apt-get install libc6-dev-i386
sudo apt-get install linux-libc-dev:i386

之后就能正确交叉编译了。

32位 luajit

D:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars32.bat
msvcbuild.bat

64位 luajit

D:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat
msvcbuild.bat gc64