I am attempting to write an Objective-c++ program in Xcode but I am having issues with linking the Exiv2 external library. Here is what I have done so far.
EXIV2:
- I have built exiv2 library from source code and the appropriate files seem to show up in /usr/local/lib and /usr/local/include .
- In the lib directory I have libexiv2.a, libexiv2.dylib, and
libexiv2.la files.
My Project:
- I have copied the libexiv2.a file to the root folder of my project folder and I have imported it as a library within Xcode.
- The code that is failing is actually an objective-c unit test case that I have setup.
- In the project info window the following values have been set
* Other Linker Flag: <no value defined>
* Header Search Paths: /usr/local/include/exiv2 and /usr/local/include
* User Header Search Paths: /usr/local/include/exiv2
* Library Search Path: /usr/local/lib
- If I right click on a ExifData declaration in the unit test, using Jump to Definition, I am able to open the exif.hpp file. This leads me to believe that maybe the exiv2 library is included correctly.
Files (Unit Test):
TestExiv2.h
----------------------------
#import <SenTestingKit/SenTestingKit.h>
@interface TestExiv2 : SenTestCase {
}
- (void) testExiv2;
@end
TestExiv2.mm
----------------------------
#import "TestExiv2.h"
#include <exiv2/exif.hpp>
#include <exiv2/image.hpp>
#include <iostream>
#include <iomanip>
#include <cassert>
@implementation TestExiv2
- (void) testExiv2
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
//load the picture from the filesyste,
NSURL *URL = "" alloc] initFileURLWithPath: @"photo.jpg"];
NSString *photoPath = [URL absoluteString];
STAssertNotNil(URL, @"URL is null. Could not load picture file");
Exiv2::ExifData exifData;
exifData["Exif.Image.Model"] = "Test 1";
[pool release];
}
@end
When I build, I receive the following errors:
"Exiv2::ExifData::ExifData()", referenced from:
-[TestExiv2 testExiv2] in TestExiv2.o
"Exiv2::Exifdatum::operator=(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)", referenced from:
-[TestExiv2 testExiv2] in TestExiv2.o
"Exiv2::ExifData::operator[](std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)", referenced from:
-[TestExiv2 testExiv2] in TestExiv2.o
"Exiv2::ExifData::~ExifData()", referenced from:
-[TestExiv2 testExiv2] in TestExiv2.o
-[TestExiv2 testExiv2] in TestExiv2.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
This is the first time that I have attempted to use Objective-c++ and also the first time that I have tried to use an external library. Does anyone have any suggestions as to how I can fix these errors? Is this a linking problem? Thanks in advance.
Casey