【问题标题】:Using libdc1394 in XCode/Mac OS 10.9 gives linker errors - Undefined symbols for architecture x86_64在 XCode/Mac OS 10.9 中使用 libdc1394 会导致链接器错误 - 架构 x86_64 的未定义符号
【发布时间】:2014-10-28 16:01:18
【问题描述】:

我正准备在 Mac OS 10.9/XCode5 上使用 libdc1394 进行相机捕捉,但我遇到了 Apple Mach-O 链接器错误。我正在解决似乎对 libdc1394 和 XCode 很好的 instructions 的工作,并且成功地找到了 libdc1394.dylib,包括 ,并进入了 hello world,这应该意味着一切都已正确连接。

我是 XCode 开发的新手,所以如果可能的话,请在你的答案中详细说明!我知道这可能与构建的目标有关。


下一步是构建一个简单的示例 (grab_color_image.c),但我收到大量链接器错误,从 void cleanup_and_exit(dc1394camera_t *camera) 中的任何内容开始,我将其注释掉:

void cleanup_and_exit(dc1394camera_t *camera)
{
//    dc1394_video_set_transmission(camera, DC1394_OFF);
//    dc1394_capture_stop(camera);
//    dc1394_camera_free(camera);
//    exit(1);
}

例如,取消注释上面的第一行给出: *架构 x86_64 的未定义符号: “_dc1394_video_set_transmission”,引用自:cleanup_and_exit(__dc1394_camera**) in main.o ld:未找到架构 x86_64 clang 的符号:错误:链接器命令失败,退出代码为 1(使用 -v 查看调用)


下面我尝试在程序中进一步移动,将上面的内容注释掉......

下面的程序在d = dc1394_new (); 处给出了类似的错误: 架构 x86_64 的未定义符号: “_dc1394_new”,引用自: main.o 中的 _main ld:未找到架构 x86_64 的符号 clang:错误:链接器命令失败,退出代码为 1(使用 -v 查看调用)

#include <iostream>
#include <dc1394/dc1394.h>
#include <stdio.h>
#include <stdint.h>
#include <dc1394/dc1394.h>
#include <stdlib.h>
#include <inttypes.h>

#ifndef _WIN32
#include <unistd.h>
#endif

#define IMAGE_FILE_NAME "image.ppm"

/*-----------------------------------------------------------------------
 *  Releases the cameras and exits
 *-----------------------------------------------------------------------*/
void cleanup_and_exit(dc1394camera_t *camera)
{
//    dc1394_video_set_transmission(camera, DC1394_OFF);
//    dc1394_capture_stop(camera);
//    dc1394_camera_free(camera);
//    exit(1);
}

int main(int argc, const char * argv[])
{
    FILE* imagefile;
    dc1394camera_t *camera;
    unsigned int width, height;
    dc1394video_frame_t *frame=NULL;
    //dc1394featureset_t features;
    dc1394_t * d;
    dc1394camera_list_t * list;
    dc1394error_t err;

    d = dc1394_new ();    // <-- THIS gives a linker error, the above stuff is fine
//    if (!d)
//        return 1;
//    err=dc1394_camera_enumerate (d, &list);
//    DC1394_ERR_RTN(err,"Failed to enumerate cameras");


    // insert code here...
    std::cout << "Hello, World!\n";
    return 0;
}

正如我之前提到的,我对 XCode 开发完全陌生,并且怀疑它可能与“构建目标”有关,但这并不完全明显。这是一些基本信息的快照(抱歉有点模糊):

【问题讨论】:

    标签: c++ xcode macos libdc1394


    【解决方案1】:

    我需要单击 libdc1394.dylib 的目标成员资格复选框。

    单击 XCode 左侧的 libdc1394.dylib 会在右侧显示此内容。我需要添加目标成员。虽然在指令的初始部分 #include 有效,但后来因为 dylib 库没有链接到项目,因此没有为链接器定义符号。 (或类似的东西......)

    【讨论】:

      猜你喜欢
      • 2013-12-19
      • 2021-10-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-02-07
      • 2013-04-11
      • 2013-06-10
      • 1970-01-01
      相关资源
      最近更新 更多