Here is my compiler version if that helps to.

g++ --version

g++ (Homebrew GCC 9.2.0_3) 9.2.0

Copyright (C) 2019 Free Software Foundation, Inc.

This is free software; see the source for copying conditions.  There is NO

warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

On Sat, Jan 4, 2020 at 6:19 PM Robert Kern <rjker...@gmail.com> wrote:

> Hello, I'm trying to write a few simple functions to help me write out
> images. The problem I'm running into though is that I'm getting the
> following error when trying to compile a basic program using it.
>
> Undefined symbols for architecture x86_64:
>>
>>   "OpenImageIO_v2_1::ImageOutput::create(std::__cxx11::basic_string<char,
>> std::char_traits<char>, std::allocator<char> > const&,
>> std::__cxx11::basic_string<char, std::char_traits<char>,
>> std::allocator<char> > const&)", referenced from:
>>
>>       writeOIIOImage(char const*, Image&, float, float) in
>> libvol.a(OIIOFiles.o)
>>
>>       writeDeepImage(std::map<std::__cxx11::basic_string<char,
>> std::char_traits<char>, std::allocator<char> >, Image*,
>> std::less<std::__cxx11::basic_string<char, std::char_traits<char>,
>> std::allocator<char> > >,
>> std::allocator<std::pair<std::__cxx11::basic_string<char,
>> std::char_traits<char>, std::allocator<char> > const, Image*> > >&, char
>> const*) in libvol.a(OIIOFiles.o)
>>
>> ld: symbol(s) not found for architecture x86_64
>>
>
> I'm working on macOS 10.15.2 and I installed oiio via homebrew. I tried
> installing it from the bottle and when that didn't work I tried
> reinstalling it having homebrew build it from the source on my machine.
> Here is the compile command I'm using.
>
> g++ -Wall -std=c++11 -g -fPIC -fopenmp -O2 -msse3 -mfpmath=sse
>> -D__REVISION__= exec/BasicSphereTest.C -I./include/
>> -I/usr/local/opt/openimageio/include -I/usr/include/python2.6
>> -I/usr/local/lib/python2.6/config  -I/opt/local/include
>> -I/usr/local/opt/ilmbase/include -L./lib -lvol
>> /usr/local/opt/openimageio/lib/libOpenImageIO.dylib -ldl  -o
>> bin/BasicSphereTest
>
>
>  And here is how I'm using ImageOutput::create in writeOIIOImage
>
> #include "OIIOFiles.h"
>
>
> #include <iostream>
>
> #include <cmath>
>
> #include <OpenImageIO/imageio.h>
>
> #include <list>
>
> #include <ctime>
>
>
> #include <sys/types.h>
>
> #include <sys/stat.h>
>
> #include <unistd.h>
>
>
> using namespace std;
>
> OIIO_NAMESPACE_USING
>
>
>
> *float* imagePlaneValue( *float* v, *float* dG, *float* dB )
>
> {
>
>    *if*( v == 0.0 ){ *return* 0.0; }
>
>    *return* pow(v, dG) * dB;
>
> }
>
>
>
> *void* writeOIIOImage( *const* string fname, Image& img, *float*
> displayBrightness, *float* displayGamma  )
>
> {
>
>    *float** imagedata = new *float*[ img.Width()* img.Height() * 3 ];
>
>    // fill image with the contents of img
>
>
>    *long* index = 0;
>
>    *for*( *int* j=0;j<img.Height();j++ )
>
>    {
>
>       *for*( *int* i=0;i<img.Width();i++ )
>
>       {
>
>          vector<*float*> pix = img.pixel(i,img.Height() - j - 1);
>
>      *for*( size_t c=0;c<3;c++ )
>
>          {
>
>             pix[c] = imagePlaneValue( pix[c], displayGamma,
> displayBrightness );
>
>         imagedata[index++] = pix[c];
>
>          }
>
>       }
>
>    }
>
>    *auto* out = ImageOutput::create (fname);
>
>    *if*( !out )
>
>    {
>
>       cout << "Not able to write an image to file " << fname << endl;
>
>    }
>
>    *else*
>
>    {
>
>       ImageSpec spec (img.Width(), img.Height(), 3, TypeDesc::HALF);
>
>       spec.attribute("user", "ash");
>
>       spec.attribute("writer", "OIIOFiles" );
>
>       out->open (fname, spec);
>
>       out->write_image (TypeDesc::FLOAT, imagedata);
>
>       out->close ();
>
>    }
>
>    delete[] imagedata;
>
>
>    cout <<"Image "<<fname<<" written."<<endl;
>
> }
>
>
>
>
> *void* writeDeepImage(map<string, Image *> &images, *const* *char*
> *filename)
>
> {
>
>     *auto* out = ImageOutput::create(filename);
>
>     *if* (!out)
>
>     {
>
>         cout << "Not able to write images to file ";
>
>         cout << filename << endl;
>
>         *return*;
>
>     }
>
>
>     *if* (strcmp(out->format_name(), "openexr") != 0)
>
>     {
>
>         cout << "DeepImage format should be OpenEXR" << endl;
>
>         cout << "Format provided: ";
>
>         cout << out->format_name() << endl;
>
>         *return*;
>
>     }
>
>
>     *int* num_channels = images.size();
>
>     map<string, Image *>::iterator it;
>
>     *int* width = images.begin()->second->Width();
>
>     *int* height = images.begin()->second->Height();
>
>     ImageSpec spec(width, height, num_channels, TypeDesc::HALF);
>
>     *float* *imagedata = new *float*[width * height * num_channels];
>
>     *long* *long* index = 0;
>
>     spec.channelnames.clear();
>
>     *int* cur_channel = 0;
>
>     *for* (it = images.begin(); it != images.end(); it++)
>
>     {
>
>         index = 0;
>
>         string fname = it->first;
>
>         Image *img = it->second;
>
>         spec.channelnames.push_back(fname);
>
>         *for* (*int* j = 0; j < height; ++j)
>
>         {
>
>             *for* (*int* i = 0; i < width; ++i)
>
>             {
>
>                 vector<*float*> pix = img->pixel(i, height - j - 1);
>
>                 /* Last two arguments should be displayGamma
>
>                    and displayBrightness.  Ask about adding
>
>                    in optional map of filename to gamma and
>
>                    filename to brightness for unique values.
>
>                 */
>
>                 pix[0] = imagePlaneValue(pix[0], 1.0, 1.0);
>
>                 *long* *long* ind = num_channels * index;
>
>                 ind += cur_channel;
>
>                 imagedata[ind] = pix[0];
>
>                 index++;
>
>             }
>
>         }
>
>         cur_channel += 1;
>
>     } // loop over images
>
>     spec.attribute("user", "ash");
>
>     spec.attribute("writer", "OIIOFiles");
>
>     out->open(filename, spec, ImageOutput::Create);
>
>     out->write_image(TypeDesc::FLOAT, imagedata);
>
>     out->close();
>
>
>
>     delete imagedata;
>
> }
>
>
> Any tips as to what I might be doing wrong would be greatly appreciated.
> Let me know if there is any more information I can provide that would be
> useful.
>
> Thanks in advance,
> Robert "Justin" Kern
>
_______________________________________________
Oiio-dev mailing list
Oiio-dev@lists.openimageio.org
http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org

Reply via email to