Programming/golang2022. 2. 17. 18:26

 

$ vi hello.go
$ go build hello.go 
$ go run hello.go 
hello world

$ file hello
hello: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, with debug_info, not stripped

$ ldd hello
동적 실행 파일이 아닙니다

$ ls -alh
-rwxrwxr-x 1 minimonk minimonk 2.0M  2월 17 18:25 hello
-rw-rw-r-- 1 minimonk minimonk   73  2월 17 18:25 hello.go

[링크 : https://gobyexample.com/hello-world]

 

+

go install 부분을 sudo로 해서 그런가 go build도 sudo를 하지 않으면 안된다.

퍼미션 문제는 어떻게 해결할 수 있으려나...

 

$ go install -buildmode=shared std
$ sudo go build -linkshared hello.go
ls -alh
$ ls -alh
합계 32K
-rwxr-xr-x 1 root     root      20K  2월 17 18:28 hello
-rw-rw-r-- 1 minimonk minimonk   73  2월 17 18:25 hello.go

$ ldd hello
linux-vdso.so.1 (0x00007ffcfb5a4000)
libstd.so => /usr/lib/go-1.10/pkg/linux_amd64_dynlink/libstd.so (0x00007f2647852000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f2647461000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f264725d000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f264703e000)
/lib64/ld-linux-x86-64.so.2 (0x00007f2649ee5000)

[링크 : https://stackoverflow.com/questions/19431296/building-and-linking-dynamically-from-a-go-binary]

 

+

2022.02.18

$ ls -alh /usr/lib/go-1.10/pkg/linux_amd64_dynlink/*so
-rw-r--r-- 1 root root 31M  2월 17 18:28 /usr/lib/go-1.10/pkg/linux_amd64_dynlink/libstd.so

$ ldd libstd.so 
linux-vdso.so.1 (0x00007ffcbe083000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f379ff4e000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f379fd2f000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f379f93e000)
/lib64/ld-linux-x86-64.so.2 (0x00007f37a25e1000)

'Programming > golang' 카테고리의 다른 글

golang gore(repl), delve  (0) 2022.03.31
go build 옵션  (0) 2022.03.31
go lang static http server  (0) 2022.03.10
go lang rest  (0) 2022.02.11
golang  (0) 2020.05.18
Posted by 구차니