链接问题,即使nm在库中显示符号,也找不到符号 [英] linking problem, can't find symbol even though nm shows symbol in library

查看:150
本文介绍了链接问题,即使nm在库中显示符号,也找不到符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将应用程序链接到lflutter_linux_glfw. nm工具显示它具有glad_glTexImage2D:

I'm linking an app against lflutter_linux_glfw. nm tools shows it has glad_glTexImage2D:

nm libflutter_linux_glfw.so | grep glTexImage2D
00000000034e87a0 b glad_glTexImage2D
00000000034e87a8 b glad_glTexImage2DMultisample

所以我在flutter_video_renderer.o之前加入了lflutter_linux_glfw.so,我明白了:

So I included lflutter_linux_glfw.so before flutter_video_renderer.o, and I get this:

clang version 6.0.0-1ubuntu2 (tags/RELEASE_600/final)                   
Target: x86_64-pc-linux-gnu                                             
Thread model: posix                                                     
InstalledDir: /usr/bin                                                  
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/7.4.0
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7       
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.4.0   
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8       
Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/7.4.0   
Candidate multilib: .;@m64                                              
Selected multilib: .;@m64                                               
 "/usr/bin/ld" -z relro --hash-style=gnu --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o /home/dev/orwell/orwell_flutter/linux/../build/linux/debug/flutter_desktop_example
 /usr/bin/../lib/gcc/x86_64-linux-gnu/7.4.0/../../../x86_64-linux-gnu/crt1.o /usr/bin/../lib/gcc/x86_64-linux-gnu/7.4.0/../../../x86_64-linux-gnu/crti.o /usr/bin/../lib/gcc/x86_64-linux-gnu/7.4.0/crtbegin.o
 -L/home/dev/orwell/orwell_flutter/linux/../build/linux/debug/lib -L/usr/bin/../lib/gcc/x86_64-linux-gnu/7.4.0 -L/usr/bin/../lib/gcc/x86_64-linux-gnu/7.4.0/../../../x86_64-linux-gnu -L/lib/x86_64-linux-gnu
 -L/lib/../lib64 -L/usr/lib/x86_64-linux-gnu -L/usr/bin/../lib/gcc/x86_64-linux-gnu/7.4.0/../../.. -L/usr/lib/llvm-6.0/bin/../lib -L/lib -L/usr/lib -lflutter_linux_glfw
 /home/dev/orwell/orwell_flutter/linux/../build/linux/obj/main.o /home/dev/orwell/orwell_flutter/linux/../build/linux/obj/flutter/generated_plugin_registrant.o
 /home/dev/orwell/orwell_flutter/linux/../build/linux/obj//home/dev/orwell/orwell_flutter/linux/flutter/ephemeral/cpp_client_wrapper_glfw/flutter_window_controller.o
 /home/dev/orwell/orwell_flutter/linux/../build/linux/obj//home/dev/orwell/orwell_flutter/linux/flutter/ephemeral/cpp_client_wrapper_glfw/plugin_registrar.o
 /home/dev/orwell/orwell_flutter/linux/../build/linux/obj//home/dev/orwell/orwell_flutter/linux/flutter/ephemeral/cpp_client_wrapper_glfw/engine_method_result.o
 /home/dev/orwell/orwell_flutter/linux/../build/linux/obj//home/dev/orwell/orwell_flutter/linux/flutter/ephemeral/cpp_client_wrapper_glfw/standard_codec.o
 /home/dev/orwell/orwell_flutter/linux/../build/linux/obj//home/dev/orwell/orwell_flutter/common/src/flutter_video_renderer.o
 /home/dev/orwell/orwell_flutter/linux/../build/linux/obj//home/dev/orwell/orwell_flutter/common/src/flutter_texture_video_renderer.o
 /home/dev/orwell/orwell_flutter/linux/../build/linux/obj//home/dev/orwell/orwell_flutter/common/src/flutter_orwell_plugin.o "-rpath=\$ORIGIN/lib" -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc
 /usr/bin/../lib/gcc/x86_64-linux-gnu/7.4.0/crtend.o /usr/bin/../lib/gcc/x86_64-linux-gnu/7.4.0/../../../x86_64-linux-gnu/crtn.o
/home/dev/orwell/orwell_flutter/linux/../build/linux/obj//home/dev/orwell/orwell_flutter/common/src/flutter_texture_video_renderer.o: In function
`flutter_orwell_plugin::FlutterTextureVideoRenderer::renderToTexture(unsigned long, unsigned long, unsigned int)':
flutter_texture_video_renderer.cc:(.text+0x1b6): undefined reference to `glad_glTexImage2D'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [/home/dev/orwell/orwell_flutter/linux/../build/linux/debug/flutter_desktop_example] Error 1

换句话说,它抱怨没有引用glad_glTexImage2D,即使它确实存在于 flutter_linux_glfw.so.我还尝试在flutter_texture_video_renderer.o之后添加flutter_linux_glfw.so,但出现相同的错误

In other words, it complains there's no reference to glad_glTexImage2D even though it it indeed in flutter_linux_glfw.so. I also tried adding flutter_linux_glfw.so after the flutter_texture_video_renderer.o but I get the same error

推荐答案

nm libflutter_linux_glfw.so | grep glTexImage2D 00000000034e87a0 b glad_glTexImage2D 00000000034e87a8 b glad_glTexImage2DMultisample

nm libflutter_linux_glfw.so | grep glTexImage2D 00000000034e87a0 b glad_glTexImage2D 00000000034e87a8 b glad_glTexImage2DMultisample

这些符号在库中是 local (不是从库中导出的).

These symbols are local to the library (not exported from it).

您可以通过以下方式查看导出的符号列表:

You can see the list of exported symbols with:

nm -D libflutter_linux_glfw.so

您会发现其中未列出glad_glTexImage2D.

P.S.

我在flutter_video_renderer.o之前包含了lflutter_linux_glfw.so

I included lflutter_linux_glfw.so before flutter_video_renderer.o

这是您应该做的相反顺序:库应该关注引用它们的对象(尽管这对于共享库并不重要) ).

This is the opposite order of what you are supposed to do: libraries should follow the objects that refer to them (though this doesn't really matter for shared libraries).

这篇关于链接问题,即使nm在库中显示符号,也找不到符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆