awslabs / awslabs/aws-lambda-cpp
Aws Lambda: C++ custom runtime - /usr/bin/ld: cannot find /usr/lib64/libc_nonshared.a
- 主要語言
- C++
- 星號
- 465
- 分支
- 98
- 平均合併
- 12 小時 47 分鐘
- 30 天內合併 PR
- 3
描述
I am trying to add `g++` inside `AWS Lambda C++ custom runtime`.
Now `g++` requires `.so` (shared libraries) files as well as `.a` (static libraries).
For this, I installed g++ inside chroot directory (directory `gpp`) on the Amazon Linux machine.
Now, I created another directory that has `bin`, `usr`, `lib`, and `lib64` directories (taken from chroot directory). I created a zip of this directory, uploaded to s3 (as it is more than 50MB), and created a Lambda layer using this zip directory.
Now, after adding this `layer` in the `lambda` function, I am trying to run.
```
execl("/opt/usr/bin/g++48", "/opt/usr/bin/g++48", "-Wall", "/tmp/hello.cpp","-o", "/tmp/hello.o",
"-I/opt/gpp3/usr/include/", (char *) 0)
```
Using the above `g++` is able to find `shared libraries` as well as `header files` but it is not able to find the static library.
```
/usr/bin/ld: cannot find /usr/lib64/libc_nonshared.a
collect2: error: ld returned 1 exit status
```
`libc_nonshared.a` exists inside `/opt/gpp3/usr/lib64/` but it is searching in `/usr/lib64/`.
I tried providing full path in g++ command as `-L/opt/gpp3/usr/lib64/libc_nonshared.a` and
`-L/opt/gpp3/usr/lib64/libc_nonshared` and `-L/opt/gpp3/usr/lib64/`
But none of them works. Any help is deeply appreciated.
貢獻指南
研究方向
先從回報的 execl 呼叫以及 /opt/gpp3 下的 AWS Lambda layer 路徑開始,接著檢查 linker 為什麼搜尋 /usr/lib64 而不是 layer 目錄。重現 g++48 命令,並驗證 libc_nonshared.a 是從 /opt/gpp3/usr/lib64 解析的;當範例編譯在 Lambda 環境中成功時,該 issue 即完成。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- aws, cpp, linux
- 領域
- build-system, cloud
- Issue 類型
- 缺陷
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 活躍度
- 停滯
- 描述清晰度
- 需要釐清
- 新手友好度
- 25/100