【问题标题】:Dyld Library not loaded: Reason: Image not found未加载 Dyld 库:原因:找不到图像
【发布时间】:2015-01-22 17:34:15
【问题描述】:

我知道以前有人问过这方面的问题,但我无法使用他们的任何解决方案来解决我的问题。我正在尝试将 Mac 上的 DISLIN 绘图库与 Xcode 一起使用。 (操作系统:优胜美地,Xcode 版本:6.1.1)。

我目前只是尝试运行一个非常简单的测试程序:

#include <stdio.h>
#include <iostream> // Required by DISLIN!
#include "dislin.h" // Required by DISLIN! Includes the
// plotting package
using namespace std;
int main(int argc, char *argv[])
{
    int numberOfPoints = 2;
    float x[2] = {0, 1};
    float y[2] = {0, 2};

    cout << x << y << endl ; 
    qplot(x, y, numberOfPoints);
}

我在尝试运行时遇到的错误是:

dyld: Library not loaded: /usr/local/lib/libdiscpp.10.dylib
  Referenced from: /Users/user/Library/Developer/Xcode/DerivedData/phys239_a2-blbdrjqdqxewuwfvvdxelytbfmzs/Build/Products/Debug/phys239_a2
  Reason: image not found
Program ended with exit code: 9

程序编译得很好,但它不会运行。我已经使用来自 dislin 网站 (dislin.de) 的软件包和通过 homebrew 的 openmotif 安装了 Dislin。我的项目与 dislin 和 openmotif 库(分别位于 /usr/local/dislin/ 和 /usr/local/Cellar/openmotif/2.3.4/lib )链接。

有人有这方面的经验吗?或者,之前有没有人能够让 dislin 与 Xcode 一起工作?

【问题讨论】:

    标签: c++ xcode macos plot


    【解决方案1】:

    所以,整个事情的重点是让 dislin 与 Xcode 一起运行,看起来我终于取得了一些坚实的进展,因为我可以制作一个实际的情节。希望没有新的惊喜。

    为了实现这一点,这就是我所做的。

    • 从 dislin.de 下载 Dislin(dislin-10.5.darwin.intel.64.tar.gz,在下载部分)

    • 确保您安装了最新的 X11。这就是我得到它的地方。 (http://xquartz.macosforge.org/landing/)

    • 使用自制软件,我安装了 openmotif。这是 dislin 所要求的。我使用了以下命令:

    brew install https://gist.githubusercontent.com/steakknife/60a39a32ae84e12238a2/raw/openmotif.rb

    我在这里找到的:https://gist.github.com/steakknife/60a39a32ae84e12238a2

    • 然后我将以下行添加到 ./bash_profile

      export DISLIN=/usr/local/dislin DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:/usr/local/dislin:/usr/local/Cellar/openmotif/2.3.4/lib/:/opt/X11/lib PATH=$PATH:$DISLIN/bin

    我知道整个 DYLD_LIBRARY_PATH 可能不是最好的,老实说,我什至不知道它在我的安装中是否真的很重要,但它目前正在工作,我不会尝试弄乱它.

    • 安装 dislin。切换到您下载它的文件夹并运行命令./INSTALL

    • 现在打开 Xcode 并启动一个新的控制台应用程序。您需要确保可以正确链接这些库。在“构建设置”中,在标题搜索路径中添加了/usr/local/dislin/real64(有两个“dislin.h”文件。如果我不使用此文件夹中的那个,我看到的结果就是垃圾。)库搜索路径我添加了 '/usr/local/dislin/liband/usr/local/Cellar/openmotif/2.3.4/lib`

    • 在“构建阶段”中,从上面的两个库文件夹中添加库。

    然后我运行了以下程序:

    #include <iostream>
    #include <dislin.h>
    
    double f(double aX)
    {
        return aX * aX ; // Function to be plotted
    }
    
    int main()
    {
        double x[11], y[11] ;
        double del = 0.1 ; 
        for( int i = 0 ; i < 11 ; i++)
        {
            x[i] = i * del ; 
            y[i] = f(x[i]) ; 
        }
        metafl("PDF") ; 
        disini() ;
        name( "X-Axis", "x" ) ;
        name( "Y-axis", "y" ) ; 
        qplsca(x, y, 11) ; 
    }
    

    它产生了这个输出:

    这就是我所在的地方。希望这可以在某个时候帮助某人。

    【讨论】:

      猜你喜欢
      • 2013-12-25
      • 2012-03-20
      • 2013-07-16
      • 1970-01-01
      • 2020-05-12
      • 2020-01-28
      • 2010-11-30
      • 1970-01-01
      • 2018-03-26
      相关资源
      最近更新 更多