可执行文件在与库静态链接后不运行
在我的Makefile中,我尝试了与我在计算机中拥有的另一个项目中的库构建代码静态链接。我有此说明:
game: Input.o Image.o Renderer.o Surface.o Main.o
g++ -g -L ${sdl_library} -L ${lib_netpbm_library} -o release/game2d build/Input.o build/Image.o build/Renderer.o build/Surface.o build/Main.o -l:libnetpbm.a -l:libSDL2.a -l:libSDL2main.a -lGL -lGLEW -lm
它构建没有错误或警告。但是,当我尝试运行生成的可执行文件时,我会收到此错误:
./game2d: error while loading shared libraries: libnetpbm.a: cannot open shared object file: No such file or directory
我在这里缺少什么?
In my Makefile, I have tried build a code static linking with a library from another project I have in my computer. I have this instruction:
game: Input.o Image.o Renderer.o Surface.o Main.o
g++ -g -L ${sdl_library} -L ${lib_netpbm_library} -o release/game2d build/Input.o build/Image.o build/Renderer.o build/Surface.o build/Main.o -l:libnetpbm.a -l:libSDL2.a -l:libSDL2main.a -lGL -lGLEW -lm
It builds with no error or warning. But when I try run the generated executable, I got this error:
./game2d: error while loading shared libraries: libnetpbm.a: cannot open shared object file: No such file or directory
What I am missing here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
实际上,问题在于我构建图书馆的方式。我从中更改了makefile:
对此:
The issue was in fact in the way I was building the library. I change the Makefile from this:
to that: