openexr-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Openexr-devel] Link Error when using "half"


From: Delio Vicini
Subject: [Openexr-devel] Link Error when using "half"
Date: Wed, 25 Feb 2015 11:10:37 +0100
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0

Hi,

I am new to using OpenEXR and tried to get it to build for Windows x64 with Visual Studio 2013. I managed to compile it using the source from the homepage (or the sidefx branch from github: https://github.com/sideeffects/openexr, both give the same error in the end). I tried using the generated lib/dll/include files in my project, but end up with a linker error when using the "half" data type.

Some part of the OpenEXR library seems to work, I can successfully read out filesize etc. and I guess the content of the file is loaded into memory. But I can't parse the data, because when casting "half" to float I get a linker error. My code is as follows (more or less copied from PBRT framework for now). If I comment out the three lines where the data is actually read, the code compiles and can successfully print out the image size (see the printf statement). The exact linker error message is:

1>main.obj : error LNK2001: unresolved external symbol "private: static union half::uif const * const half::_toFloat" (address@hidden@@address@hidden@B)
1>..\..\bin\Release\x64\OpenEXRExample.exe : fatal error LNK1120: 1 unresolved externals

I assume that maybe my OpenEXR build has some issues, because I included all the libs/headers (including Half.lib etc.) as usual into my project. Does maybe someone have working Open EXR 64bit lib and dll files for Visual Studio 2013? Or any other ideas what I am doing wrong?

Thanks for your help!

Cheers,
Delio


Code:
// EXR Function Definitions
Halide::Image<float> ReadImageEXR(const string &nameint *widthint *height)
{
	try {
		InputFile file(name.c_str());
		Box2i dw = file.header().dataWindow();
		*width = dw.max.x - dw.min.x + 1;
		*height = dw.max.y - dw.min.y + 1;


		half *rgb = new half[3 * *width * *height];

		FrameBuffer frameBuffer;
		frameBuffer.insert("R"Slice(HALF, (char *)rgb, 3 * sizeof(half), *width * 3 * sizeof(half), 1, 1, 0.0));
		frameBuffer.insert("G"Slice(HALF, (char *)rgb + sizeof(half), 3 * sizeof(half), *width * 3 * sizeof(half), 1, 1, 0.0));
		frameBuffer.insert("B"Slice(HALF, (char *)rgb + 2 * sizeof(half),	3 * sizeof(half), *width * 3 * sizeof(half), 1, 1, 0.0));

		file.setFrameBuffer(frameBuffer);
		file.readPixels(dw.min.y, dw.max.y);

		
		Halide::Image<float> im = Halide::Image<float>(*width, *height, 3);
		float *ptr = (float*) im.data();

		for (int i = 0; i < *width * *height; ++i) {
			ptr[3 * i] = rgb[3 * i]; // <- these lines are the ones causing the build error.
			ptr[3 * i + 1] = rgb[3 * i + 1];
			ptr[3 * i + 2] = rgb[3 * i + 2];
		}
		delete[] rgb;
		printf("Read EXR image %s (%d x %d)\n"name.c_str(), *width, *height);
		im.set_host_dirty();
		return im;
		//return Halide::Image<float>();catch (const std::exception &e) {
		printf("Unable to read image file \"%s\": %s"name.c_str(),
			e.what());
		return Halide::Image<float>();
	}
}


reply via email to

[Prev in Thread] Current Thread [Next in Thread]