linux 当文件或目录以确切的名称存在时,“ld”报告没有这样的文件或目录

56lgkhnf  于 2023-06-05  发布在  Linux
关注(0)|答案(1)|浏览(241)

我有一个相当老派的Makefile,它调用g++在Ubuntu¹上编译我的程序。当我运行make时,它在一些编译发生后打印出以下错误。

/usr/bin/ld: cannot find -l/usr/lib/x86_64-linux-gnu/libX11.so: No such file or directory
collect2: error: ld returned 1 exit status
make: *** [Makefile:188: anura] Error 1

但是,存在一个同名的文件**。

$ ls -l /usr/lib/x86_64-linux-gnu/libX11.so
lrwxrwxrwx 1 root root 15 Apr  3  2022 /usr/lib/x86_64-linux-gnu/libX11.so -> libX11.so.6.4.0

我可以猫它,我得到大致预期的内容。
我已经检查了正在运行的命令,它的构造似乎是正确的。我没有做过像-l-l/usr/lib这样的蠢事。什么的

g++ \
      -O2 -Wall -Werror -Wno-literal-suffix -Wno-sign-compare -I/usr/include/SDL2 -D_REENTRANT -std=c++0x -g -fno-inline-functions -fthreadsafe-statics -Wno-narrowing -Wno-reorder -Wno-unused -Wno-unknown-pragmas -Wno-overloaded-virtual -DBOOST_BIND_GLOBAL_PLACEHOLDERS -Wno-deprecated-declarations -I./vcpkg_installed/x64-linux/include -DUSE_SVG -DUSE_IMGUI -rdynamic -L./vcpkg_installed/x64-linux/lib  -DIMGUI_INCLUDE_IMGUI_USER_INL -MMD -MP \
      ./build/kre/AttributeSet.o ./build/kre/AttributeSetOGL.o ./build/kre/Blend.o ./build/kre/BlendModeScope.o ./build/kre/BlendOGL.o ./build/kre/Blittable.o ./build/kre/CameraObject.o ./build/kre/Canvas.o ./build/kre/CanvasOGL.o ./build/kre/ClipScope.o ./build/kre/ClipScopeOGL.o ./build/kre/Color.o ./build/kre/ColorScope.o ./build/kre/Cursor.o ./build/kre/Depth.o ./build/kre/DisplayDevice.o ./build/kre/DisplayDeviceOGL.o ./build/kre/DisplayDeviceOGLFixed.o ./build/kre/DisplayDeviceSDL.o ./build/kre/EffectsOGL.o ./build/kre/FboOGL.o ./build/kre/Font.o ./build/kre/FontDriver.o ./build/kre/FontFreetype.o ./build/kre/FontSDL.o ./build/kre/FontSTB.o ./build/kre/Frustum.o ./build/kre/Gradients.o ./build/kre/imgui_impl_sdl_gl3.o ./build/kre/LightObject.o ./build/kre/ModelMatrixScope.o ./build/kre/ParticleSystemAffectors.o ./build/kre/ParticleSystem.o ./build/kre/ParticleSystemEmitters.o ./build/kre/ParticleSystemParameters.o ./build/kre/ParticleSystemUI.o ./build/kre/Renderable.o ./build/kre/RenderManager.o ./build/kre/RenderQueue.o ./build/kre/RenderTarget.o ./build/kre/SceneGraph.o ./build/kre/SceneNode.o ./build/kre/SceneObject.o ./build/kre/SceneParameters.o ./build/kre/SceneTree.o ./build/kre/Scissor.o ./build/kre/ScissorOGL.o ./build/kre/Shaders.o ./build/kre/ShadersOGL.o ./build/kre/StencilScope.o ./build/kre/StencilScopeOGL.o ./build/kre/SurfaceBlur.o ./build/kre/Surface.o ./build/kre/SurfaceScale.o ./build/kre/SurfaceSDL.o ./build/kre/TexPack.o ./build/kre/Texture.o ./build/kre/TextureOGL.o ./build/kre/TextureSDL.o ./build/kre/TextureUtils.o ./build/kre/UniformBuffer.o ./build/kre/UniformBufferOGL.o ./build/kre/Util.o ./build/kre/VGraphCairo.o ./build/kre/VGraph.o ./build/kre/VGraphOGL.o ./build/kre/VGraphOGLFixed.o ./build/kre/WindowManager.o ./build/svg/easy_svg.o ./build/svg/svg_attribs.o ./build/svg/svg_container.o ./build/svg/svg_element.o ./build/svg/svg_fwd.o ./build/svg/svg_gradient.o ./build/svg/svg_length.o ./build/svg/svg_paint.o ./build/svg/svg_parse.o ./build/svg/svg_path_parse.o ./build/svg/svg_shapes.o ./build/svg/svg_style.o ./build/svg/svg_transform.o ./build/svg/svg_utils.o ./build/tiled/tiled.o ./build/tiled/tmx_reader.o ./build/hex/hex_helper.o ./build/hex/hex_loader.o ./build/hex/hex_map.o ./build/hex/hex_mask.o ./build/hex/hex_renderable.o ./build/hex/hex_tile.o ./build/hex/tile_rules.o ./build/xhtml/css_lexer.o ./build/xhtml/css_parser.o ./build/xhtml/css_properties.o ./build/xhtml/css_selector.o ./build/xhtml/css_styles.o ./build/xhtml/css_stylesheet.o ./build/xhtml/css_transition.o ./build/xhtml/event_listener.o ./build/xhtml/scrollable.o ./build/xhtml/solid_renderable.o ./build/xhtml/to_roman.o ./build/xhtml/url_handler.o ./build/xhtml/xhtml_absolute_box.o ./build/xhtml/xhtml_background_info.o ./build/xhtml/xhtml_block_box.o ./build/xhtml/xhtml_border_info.o ./build/xhtml/xhtml_box.o ./build/xhtml/xhtml_element.o ./build/xhtml/xhtml_inline_block_box.o ./build/xhtml/xhtml_inline_element_box.o ./build/xhtml/xhtml_layout_engine.o ./build/xhtml/xhtml_line_box.o ./build/xhtml/xhtml_listitem_box.o ./build/xhtml/xhtml_node.o ./build/xhtml/xhtml_parser.o ./build/xhtml/xhtml_render_ctx.o ./build/xhtml/xhtml_root_box.o ./build/xhtml/xhtml_script_interface.o ./build/xhtml/xhtml_style_tree.o ./build/xhtml/xhtml_text_box.o ./build/xhtml/xhtml_text_node.o ./build/xhtml/xslider.o ./build/achievements.o ./build/animation_creator.o ./build/animation_preview_widget.o ./build/animation_widget.o ./build/anura_shader.o ./build/asserts.o ./build/auto_update_window.o ./build/background.o ./build/background_task_pool.o ./build/bar_widget.o ./build/base64.o ./build/blur.o ./build/border_widget.o ./build/breakpad.o ./build/button.o ./build/cairo.o ./build/character_editor_dialog.o ./build/checkbox.o ./build/checksum.o ./build/clipboard.o ./build/code_editor_dialog.o ./build/code_editor_widget.o ./build/collision_utils.o ./build/color_picker.o ./build/ColorTransform.o ./build/compress.o ./build/controls.o ./build/controls_dialog.o ./build/current_generator.o ./build/custom_object_callable.o ./build/custom_object.o ./build/custom_object_dialog.o ./build/custom_object_functions.o ./build/custom_object_type.o ./build/db_client.o ./build/debug_console.o ./build/decimal.o ./build/dialog.o ./build/difficulty.o ./build/distortion.o ./build/drag_widget.o ./build/draw_primitive.o ./build/draw_scene.o ./build/draw_tile.o ./build/dropdown_widget.o ./build/editor.o ./build/editor_dialogs.o ./build/editor_formula_functions.o ./build/editor_layers_dialog.o ./build/editor_level_properties_dialog.o ./build/editor_module_properties_dialog.o ./build/editor_stats_dialog.o ./build/editor_variable_info.o ./build/entity.o ./build/external_text_editor.o ./build/ffl_dom.o ./build/ffl_lib.o ./build/ffl_weak_ptr.o ./build/file_chooser_dialog.o ./build/filesystem-android.o ./build/filesystem.o ./build/formula_callable.o ./build/formula_callable_definition.o ./build/formula_callable_visitor.o ./build/formula_constants.o ./build/formula.o ./build/formula_function.o ./build/formula_function_registry.o ./build/formula_garbage_collector.o ./build/formula_interface.o ./build/formula_internal.o ./build/formula_object.o ./build/formula_profiler.o ./build/formula_test.o ./build/formula_tokenizer.o ./build/formula_variable_storage.o ./build/formula_visualize_widget.o ./build/formula_vm.o ./build/frame.o ./build/framed_gui_element.o ./build/ft_iface.o ./build/game_registry.o ./build/geometry_callable.o ./build/globals.o ./build/graphical_font.o ./build/graphical_font_label.o ./build/grid_widget.o ./build/group_property_editor_dialog.o ./build/gui_section.o ./build/http_client.o ./build/http_server.o ./build/i18n.o ./build/image_widget.o ./build/input.o ./build/intrusive_ptr.o ./build/isochunk.o ./build/isoworld.o ./build/joystick.o ./build/json_parser.o ./build/json_tokenizer.o ./build/key_button.o ./build/label.o ./build/language_dialog.o ./build/LayerBlitInfo.o ./build/layout_widget.o ./build/level.o ./build/level_logic.o ./build/level_object.o ./build/level_runner.o ./build/level_solid_map.o ./build/light.o ./build/loading_screen.o ./build/load_level.o ./build/load_level_nothread.o ./build/logger.o ./build/main.o ./build/md5.o ./build/message_dialog.o ./build/module.o ./build/module_web_server.o ./build/multiplayer.o ./build/multiplayer_server.o ./build/multi_tile_pattern.o ./build/normal_map.o ./build/object_events.o ./build/particle_system.o ./build/particle_system_proxy.o ./build/ParticleSystemWidget.o ./build/pathfinding.o ./build/pause_game_dialog.o ./build/playable_custom_object.o ./build/player_info.o ./build/poly_line_widget.o ./build/poly_map.o ./build/preferences.o ./build/preprocessor.o ./build/preview_tileset_widget.o ./build/progress_bar.o ./build/property_editor_dialog.o ./build/random.o ./build/rectangle_rotator.o ./build/rect_renderable.o ./build/rich_text_label.o ./build/SceneNodeCallable.o ./build/SceneObjectCallable.o ./build/screen_handling.o ./build/scrollable_widget.o ./build/scrollbar_widget.o ./build/segment_editor_dialog.o ./build/settings_dialog.o ./build/shared_memory_pipe.o ./build/simplex_noise.o ./build/simplex_noise_tests.o ./build/skybox.o ./build/slider.o ./build/solid_map.o ./build/sound.o ./build/speech_dialog.o ./build/StackWalker.o ./build/stats.o ./build/stats_server.o ./build/stats_server_main.o ./build/stats_web_server.o ./build/string_utils.o ./build/surface_cache.o ./build/surface_palette.o ./build/surface_utils.o ./build/sys.o ./build/tbs_ai_player.o ./build/tbs_bot.o ./build/tbs_client.o ./build/tbs_functions.o ./build/tbs_game.o ./build/tbs_internal_client.o ./build/tbs_internal_server.o ./build/tbs_ipc_client.o ./build/tbs_matchmaking_server.o ./build/tbs_relay_server.o ./build/tbs_server_base.o ./build/tbs_server.o ./build/tbs_web_server.o ./build/text_editor_widget.o ./build/TextureObject.o ./build/theme_imgui.o ./build/thread.o ./build/tile_map.o ./build/tileset_editor_dialog.o ./build/tooltip.o ./build/translate.o ./build/tree_view_widget.o ./build/unit_test.o ./build/user_voxel_object.o ./build/utility_object_compiler.o ./build/utility_query.o ./build/utility_render_level.o ./build/utils.o ./build/uuid.o ./build/variant_callable.o ./build/variant.o ./build/variant_type_check.o ./build/variant_type.o ./build/variant_utils.o ./build/video_selections.o ./build/VoronoiDiagramGenerator.o ./build/voxel_animation.o ./build/voxel_editor.o ./build/voxel_model.o ./build/voxel_object.o ./build/voxel_object_functions.o ./build/voxel_object_type.o ./build/water.o ./build/water_particle_system.o ./build/weather_particle_system.o ./build/widget.o ./build/widget_editor.o ./build/widget_factory.o ./build/widget_settings_dialog.o ./build/wml_formula_callable.o imgui/imgui.o   imgui/imgui_draw.o   imgui/imgui_widgets.o -o anura \
      -lX11 -lGL -D_REENTRANT -pthread -I/home/ddr/Projects/Anura/vcpkg_installed/x64-linux/lib/pkgconfig/../../include -I/home/ddr/Projects/Anura/vcpkg_installed/x64-linux/lib/pkgconfig/../../include/SDL2 -I/home/ddr/Projects/Anura/vcpkg_installed/x64-linux/lib/pkgconfig/../../include/cairo -I/home/ddr/Projects/Anura/vcpkg_installed/x64-linux/lib/pkgconfig/../../include/lzo -I/home/ddr/Projects/Anura/vcpkg_installed/x64-linux/lib/pkgconfig/../../include -I/home/ddr/Projects/Anura/vcpkg_installed/x64-linux/lib/pkgconfig/../../include/libpng16 -I/home/ddr/Projects/Anura/vcpkg_installed/x64-linux/lib/pkgconfig/../../include -I/home/ddr/Projects/Anura/vcpkg_installed/x64-linux/lib/pkgconfig/../../include/pixman-1 -L/home/ddr/Projects/Anura/vcpkg_installed/x64-linux/lib/pkgconfig/../../lib -lX11 -lGLEW -lGLU -lSDL2_image -lSDL2_ttf -pthread -lSDL2 -lrt -ldbus-1 -l/usr/lib/x86_64-linux-gnu/libXxf86vm.so -l/usr/lib/x86_64-linux-gnu/libXss.so -l/usr/lib/x86_64-linux-gnu/libXrandr.so -l/usr/lib/x86_64-linux-gnu/libXfixes.so -l/usr/lib/x86_64-linux-gnu/libXi.so -l/usr/lib/x86_64-linux-gnu/libXinerama.so -l/usr/lib/x86_64-linux-gnu/libXcursor.so -l/usr/lib/x86_64-linux-gnu/libXext.so -l/usr/lib/x86_64-linux-gnu/libX11.so -lm -Wl,--no-undefined -pthread -lSDL2 -lcairo -lm -ldl -llzo2 -lfontconfig -pthread -lexpat -lm -lfreetype -lbz2 -lpng16 -lm -lz -lbrotlidec-static -lbrotlicommon-static -lpixman-1 -lm -pthread -logg -lvorbis -lvorbisfile -lrt -lstdc++ -lm -L/home/ddr/Projects/Anura/vcpkg_installed/x64-linux/lib/pkgconfig/../../lib -lcairo -lm -ldl -llzo2 -lfontconfig -pthread -lexpat -lm -lfreetype -lbz2 -lpng16 -lm -lz -lbrotlidec-static -lbrotlicommon-static -lpixman-1 -lm -pthread -lboost_regex -lboost_system -lboost_filesystem -lboost_locale -licui18n -licuuc -licudata -lpthread -fthreadsafe-statics

我需要做些什么来解决这个问题,或者进一步诊断它?
¹:KDE neon ,基于Ubuntu。

91zkwejq

91zkwejq1#

存在同名文件**。
但这不是链接器要查找的内容。
如果你想通过一个路径指定一个链接库到它的文件,那么就这样做。在这种情况下不要使用-l。但是,很少这样做,特别是对于系统库。
传统上,-l选项的参数应该是 library 名称,而不是它的 file 名称或路径。例如,-lX11。这依赖于一个惯例,即库的文件名是通过在其库名称前面加上lib并在后面加上.a或其他一些系统特定的扩展名(.so.dylib、* 等 *)来构造的。
或者,使用最新版本的GNU链接器,您可以在库的完整基名前面加上冒号(:),以使链接器在库搜索路径中搜索具有该基名的对象。例如,-l:libX11.so。这也很少使用。
如果所需的库不在默认库搜索路径中,则通常会使用-L选项来添加其目录,而不是通过其完整路径指定库。例如,-L/usr/lib/x86_64-linux-gnu -lX11。但是,我相信/usr/lib/x86_64-linux-gnu在Ubuntu上的默认库搜索路径中,因此您不需要为libX11这样做。
还请注意,在命令行中指定对象和库的顺序是很重要的,因此有时多次指定同一个库是有意义的。但这不寻常。人们通常可以选择一个不重复的对象顺序。而且根本没有理由通过具有彼此不同形式的参数来指定相同的库。

相关问题