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

问题描述 投票:0回答:1

我正在用d语言测试官方tcl / tk样本,但在链接步骤失败了。我在Linux Mint 19 Cinamon 64bit上,我至少安装了

  • libtcl8.6
  • libtk8.6

另外,我使用的是DUB版本1.14.0,建于2019年4月5日

我去了tk绑定页面并按照Linux的步骤进行操作:binding page

  1. 安装tcl / tk 8.6库
  2. 代码示例的用法
...

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

但它既不起作用也不起作用。

ubuntu tcl d tk
1个回答
0
投票

最后我管理了!

我创建了几个软链接:

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成功编译。

© www.soinside.com 2019 - 2024. All rights reserved.