gpt4 book ai didi

ubuntu - 为什么链接器找不到 tcl/tk?

转载 作者:行者123 更新时间:2023-12-04 19:11:04 26 4
gpt4 key购买 nike

我正在测试一个官方 tcl/tk sample 在 d语言 ,但在链接步骤失败。我在 Linux Mint 19 Cinamon 64 位 ,我至少已经安装了

  • libtcl8.6
  • libtk8.6

  • 另外,我正在使用 配音版本 1.14.0 , 建于 2019 年 4 月 5 日

    我去了 tk 绑定(bind)页面并按照 Linux 的步骤操作: binding page :
  • tck/tk 8.6 库的安装
  • 代码示例的用法
  • ...

    class Application : TkdApplication // Extend TkdApplication.
    {
    private void exitCommand(CommandArgs args) // Create a callback.
    {
    this.exit(); // Exit the application.
    }

    override protected void initInterface() // Initialise user interface.
    {
    auto frame = new Frame(2, ReliefStyle.groove) // Create a frame.
    .pack(10); // Place the frame.

    auto label = new Label(frame, "Hello World!") // Create a label.
    .pack(10); // Place the label.

    auto exitButton = new Button(frame, "Exit") // Create a button.
    .setCommand(&this.exitCommand) // Use the callback.
    .pack(10); // Place the button.
    }
    }

    ...

    编译输出

    $ dub
    Performing "debug" build using /usr/bin/dmd for x86_64.
    x11 1.0.21: target for configuration "tcltk-import" is up to date.
    tcltk 8.6.5: target for configuration "library" is up to date.
    tkd 1.1.10: target for configuration "library" is up to date.
    hello-user ~master: building configuration "application"...
    Linking...
    /usr/bin/ld : ne peut trouver -ltcl
    /usr/bin/ld : ne peut trouver -ltk
    collect2: error: ld returned 1 exit status
    Error: linker exited with status 1
    /usr/bin/dmd failed with exit code 1.


    'ne peut trouver' 的意思是“ 找不到 ”。

    这是我的 dub.json
    {
    "authors": [
    "laurent bernabe"
    ],
    "copyright": "Copyleft 2019, Laurent Bernabe",
    "description": "Simple user greeting",
    "license": "MIT",
    "name": "hello-user",
    "dependencies": {
    "tkd": "~>1.1.10"
    },
    "postGenerateCommands-windows-x86": [
    "copy $TCLTK_PACKAGE_DIR\\dist\\x86\\tcl86t.dll build\\tcl86t.dll /y",
    "copy $TCLTK_PACKAGE_DIR\\dist\\x86\\tk86t.dll build\\tk86t.dll /y",
    "xcopy $TCLTK_PACKAGE_DIR\\dist\\library build\\library /i /e /y"
    ],
    "postGenerateCommands-windows-x86_64": [
    "copy $TCLTK_PACKAGE_DIR\\dist\\x86_64\\tcl86t.dll build\\tcl86t.dll /y",
    "copy $TCLTK_PACKAGE_DIR\\dist\\x86_64\\tk86t.dll build\\tk86t.dll /y",
    "xcopy $TCLTK_PACKAGE_DIR\\dist\\library build\\library /i /e /y"
    ]
    }

    同时,我刚刚发现 libtcl8.6.a 和 libtk8.6.a 都在/usr/lib/x86_64-linux-gnu 下。我试过设置

    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/x86_64-linux-gnu

    但它也没有工作。

    最佳答案

    最后我成功了!

    我创建了几个软链接(soft link):

    sudo ln -s /usr/lib/x86_64-linux-gnu/libtcl8.6.a /usr/lib/libtcl.a
    sudo ln -s /usr/lib/x86_64-linux-gnu/libtk8.6.a /usr/lib/libtk.a
    sudo ln -s /usr/lib/x86_64-linux-gnu/libtcl8.6.so /usr/lib/libtcl.so
    sudo ln -s /usr/lib/x86_64-linux-gnu/libtk8.6.so /usr/lib/libtk.so

    这样运行 dub编译成功。

    关于ubuntu - 为什么链接器找不到 tcl/tk?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55715458/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com