I am gearing up to use libdc1394 for camera capture on Mac OS 10.9/XCode5 and I am running into Apple Mach-O Linker Errors. I am working off of what seemed to be good instructions for libdc1394 and XCode, and was successful in locating libdc1394.dylib, including , and getting to hello world, which should mean everything is properly connected.
I am new to XCode Development so please be detailed in your answer if possible! I understand that this may have something to do with the targeting of the build.
The next step was to build a simple example (grab_color_image.c), but I am getting a ton of linker errors, starting with anything in void cleanup_and_exit(dc1394camera_t *camera)
, which I commented out:
void cleanup_and_exit(dc1394camera_t *camera)
{
// dc1394_video_set_transmission(camera, DC1394_OFF);
// dc1394_capture_stop(camera);
// dc1394_camera_free(camera);
// exit(1);
}
For example, uncommenting the first line above gives: *Undefined symbols for architecture x86_64: "_dc1394_video_set_transmission", referenced from: cleanup_and_exit(__dc1394_camera**) in main.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)
Below I tried to move further in the program, leaving the stuff above commented out ...
The program below gives a similar error at d = dc1394_new ();
: Undefined symbols for architecture x86_64:
"_dc1394_new", referenced from:
_main in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
#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;
}
As I mentioned before, I am altogether new to XCode development, and suspect it may have something to do with the "build target", but it's not totally obvious. Here is a snapshot of some basic info (sorry it is a bit blurry):
I needed to click the checkbox on target membership for libdc1394.dylib.
Clicking libdc1394.dylib on the left side of XCode brings up this on the right side. I needed to add target membership. Although in the initial part of the instructions #include worked, it didn't later because the dylib library wasn't linked to the project, and thus the symbols weren't defined for the linker. (or something like that ...)