Go uses static link library compilation to generate executable files. A third party files are used, no source code construction

Time:2019-11-24

Both go build and go install need to be compiled using source code. But sometimes we only have. A or. So files. We can’t get the source code of the third-party library. At this time, we need to compile the static link library;

Above is the file distribution before the experiment.

To compile a command using a static link library:

➜  src go tool compile -I ../pkg/darwin_amd64/  callyx.go 
➜  src go tool link -o call2 -L ../pkg/darwin_amd64/ callyx.o

Post experiment file distribution:

As we can see from the figure, the executable is generated.

Resources come from the network. If it helps you, please pay attention to cnblogs.com/xuyaowen

 

Recommended Today

Docker learning (5) basic command of dockerfile

To learn dockerfile, you need to understand its basic commands From – base image Try to use the official reference image [x] From Tomcat: 8.5.50-jdk8-openjdk 񖓿 make reference image (based on Tomcat: 8.5.50-jdk8-openjdk) [x] From CentOS ා make a base image based on CentOS: latest [x] From scratch? Does not depend on any reference image […]