• MSVC和MinGW64编译boost

    ·

    发布于

    修改于

    MinGW-w64

    使用的是w64devkit-1.21.0。

    生成b2.exe

    bootstrap.bat gcc

    编译

    b2.exe toolset=gcc -–layout=versioned variant=debug link=static threading=multi runtime-link=static cxxstd=20
    b2.exe toolset=gcc -–layout=versioned variant=release link=static threading=multi runtime-link=static cxxstd=20

  • Visual Studio快捷键

    ·

    发布于

    修改于


  • CGO生成的头文件,_Fcomplex、_Dcomplex未定义的解决办法

    ·

    发布于

    修改于

    #ifdef _MSC_VER
    #  if _MSVC_LANG <= 201402L
    #    include <complex.h>
         typedef _Fcomplex GoComplex64;
         typedef _Dcomplex GoComplex128;
    #  else
    #    include <complex>
         typedef std::complex<float> GoComplex64;
         typedef std::complex<double> GoComplex128;
    #  endif
    #else
      typedef float _Complex GoComplex64;
      typedef double _Complex GoComplex128;
    #endif

  • 通过dll构建lib

    ·

    发布于

    修改于

    首先根据dll编写一个def文件。然后在VS执行环境里执行以下命令就可以生成对应的lib文件。

    lib /def:https_server.def /machine:x64 /out:https_server.lib

  • C EXE调用GO DLL实现HTTPS Server

    ·

    发布于

    修改于

    这是一个HTTPS Server的例子,CEXE调用GODLL的函数启动HTTPS Server,Server收到数据后会调用CEXE中的回调函数将HTTP请求数据发送给CEXE并从CEXE处获得HTTP响应数据。

    需要注意的是在C和GO之间进行变量类型转换的时候,如果使用C.CString和C.CBytes转换字符串或数据,则需要调用C.free释放内存,使用C.free的需要在import “C”前的C代码中引入头文件stdlib.h,否则会报错。


  • golang编写http server dll

    ·

    发布于

    修改于

    package main
    
    // //Needed for build
    import "C"
    import (
    	"fmt"
    	"io"
    	"net/http"
    )
    
    func homeHandler(w http.ResponseWriter, r *http.Request) {
    	header := fmt.Sprintf("%s %s %s\r\n", r.Method, r.RequestURI, r.Proto)
    	header += fmt.Sprintf("Host: %s\r\n", r.Host)
    	for k, vs := range r.Header {
    		header += fmt.Sprintf("%s: ", k)
    		for _, v := range vs {
    			header += v
    		}
    		header += "\r\n"
    	}
    	header += "\r\n"
    	fmt.Fprintf(w, "%s", header)
    	body, err := io.ReadAll(io.Reader(r.Body))
    	if err != nil {
    		http.Error(w, "Error reading request body", http.StatusInternalServerError)
    		return
    	}
    	w.Write(body)
    }
    
    //export main
    func main() {
    	http.HandleFunc("/", homeHandler)
    	http.ListenAndServe(":8000", nil)
    }
    

  • 编译openssl-1.1.1w

    ·

    发布于

    修改于

    我需要的是静态库,所以这里的内容都是围绕静态库的。

    我需要以下3个版本:

    1release/MT发布版本
    2debug/MDd大多数情况下使用的调试版本
    3debug/MTd主要用于使用debug_and_release方式编译的qt程序的调试

    下面3个配置命令分别对应上面3个版本。但要注意的是,2和3在配置完成后,一定要手动修改makefile文件,将原本的/MT改成目标参数(/MDd或/MTd)

    1. release
    perl Configure VC-WIN64A no-asm no-shared no-sse2 zlib --with-zlib-include="D:\zlib-1.3.1\build" --with-zlib-lib="D:\zlib-1.3.1\zlibstatic.lib"
    1. debug (/MDd)
    perl Configure no-asm no-shared no-sse2 zlib VC-WIN64A --debug --with-zlib-include=D:\zlib-1.3.1\build --with-zlib-lib=D:\zlib-1.3.1\zlibstaticd.lib
    1. debug (/MTd)
    perl Configure no-asm no-shared no-sse2 zlib VC-WIN64A --debug --with-zlib-include=D:\zlib-1.3.1\build --with-zlib-lib=D:\zlib-1.3.1\zlibstaticd_mtd.lib

    不拷贝手册文件

    执行nmake install命令会消耗很多时间,因为该命令会拷贝很多手册文件。我并不需要这些文件,可以使用nmake install_sw命令,该命令只拷贝软件。

    关于-–prefix和–openssldir参数

    无论我怎么指定-–prefix和–openssldir参数,都无法修改安装目录,在Windows下始终是程序目录。


  • VisualStudio.gitignore

    ·

    发布于

    修改于

    Visual Studio .gitignore文件,另外下面这个页面里还有很多其它IDE或编程语言的的.gitignore文件。

    https://github.com/github/gitignore/blob/main/VisualStudio.gitignore

    (更多…)

最新