链接问题,即使nm在库中显示符号,也找不到符号

时间:2019-10-10 21:15:30

标签: flutter compiler-errors compilation linker ld

我正在将应用程序与lflutter_linux_glfw关联。 nm工具显示它具有glad_glTexImage2D

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

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

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_linux_glfw.so之后添加flutter_texture_video_renderer.o,但收到相同的错误

1 个答案:

答案 0 :(得分:1)

  

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

这些符号对于库是 local (不是从库中导出的)。

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

nm -D libflutter_linux_glfw.so

您会发现其中没有列出glad_glTexImage2D

P.S。

  

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

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