Intel® Integrated Performance Primitives
Deliberate problems developing high-performance vision, signal, security, and storage applications.

Unable to link code under linux, please help

avenk
Beginner
447 Views
Hello, I'm a first time user of IPP, please bear with me.
I'm trying to compile some code that uses the warpaffine transform, but when I link it it complains that the function couldn't be found. I've tried and setting the right LD_LIBRARY_PATH, and even including each of the libraries (.a) file explicitly on the command line, but to no avail. I've also edited my /etc/ld.so.conf to point to the shared dynamic library. What am I doing wrong? The include files show that my function does exist in the ippi libary.
Any help would be greatly appreciated and acknowledged in my code :-)
Thanks...
Here is what I get:
g++ -o warp -O3 -I../includes `pkg-config --cflags opencv` warp.cc rotate.cpp `pkg-config --libs opencv`
/tmp/cctK9Ema.o(.text+0x476): In function `iplWarpAffine(_IplImage*, _IplImage*, double const (*) [3], int)':
: undefined reference to `ippiWarpAffine_8u_C3R'
/tmp/cctK9Ema.o(.text+0x5e6): In function `rotateImage(_IplImage*, _IplImage*, float)':
: undefined reference to `ippiWarpAffine_8u_C3R'

Message Edited by avenk on 08-21-2005 10:24 AM

0 Kudos
7 Replies
Vladimir_Dudnik
Employee
447 Views
Hi,
I see no IPP libraryes in your command line, so how did you specify to linker that you want to link with some IPP libraries?
Regards,
Vladimir
0 Kudos
avenk
Beginner
447 Views
> I see no IPP libraryes in your command line, so how did
> you specify tolinker that you want to link with some IPP libraries?
Thanks, that is one of the problems. I just can't figure out which
library Ishould link in. Since my function is
"ippiWarpAffine_8u_C3R", I tried the following:
82 {zeta} tests grep -l ippiWarpAffine_8u_C3R
/opt/intel/ipp41/ia32_itanium/lib/*.a
/opt/intel/ipp41/ia32_itanium/lib/libippiemerged.a
/opt/intel/ipp41/ia32_itanium/lib/libippii7.a
/opt/intel/ipp41/ia32_itanium/lib/libippimerged.a
And subsequently tried linking each of the above static libraries
in turn using the .a file directly on the g++ command line.I also
tried to link using LDFLAGS = -lippimerged, -lippii7, etc. but in
each case I get the message that either the library itself is not
to be found, or the function is unknown.
Here is my /etc/ld.so.conf, and I can confirm that I ran ldconfig as
root:
144 {zeta}tests: cat /etc/ld.so.conf
/usr/kerberos/lib
/usr/X11R6/lib
/usr/lib/sane
/usr/lib/qt-3.1/lib
/usr/lib/mysql
/usr/lib/qt2/lib
/usr/local/lib
/opt/intel/ipp41/ia32_itanium/sharedlib
0 Kudos
Vladimir_Dudnik
Employee
447 Views
Hi,
first of all, I recommend you to take a look on IPP technical information which is available at the link below
Namely, article Linking with Intel IPP could be helpful.
If you noticed, IPP v4.1 contains libraries for IA64 and for IA32 arhitectures in the same folder. Of course, you need to link only with libs for one particular architecture, not with both.
So, for IA32 there is many different processors in the family, and IPPcontains special optimization for them, for example, we call A6 - code dedicated for Intel Pentium III (support up to SSE instruction set), W7 - code for Intel Pentium 4 (support up to SSE2 instruction set) and T7 code for Intel Pentium 4 with support up to SSE3 instruction set. For your convenience, we have combined static libraries which contains all of these and run-time detector of actual processor to dispatch particulr optimized code. These combined libraries we call IPP merged libraries. And static detector and dispatcher is in IPP emerged libraries. So, for IA32 it is the best choice to link these libraries, in that case your application will automatically use the best optimization on all supported IA32 platforms. From the other hand, in IA64 there is only one processor in family, it is Intel Itanium 2 (at least for now). So, there is no need in combined libraries and we deliver just casul static libraries. Note, we tag Itanium specific code as I7.
Regards,
Vladimir
0 Kudos
avenk
Beginner
447 Views
Vladimir, thanks much, I believe I am getting somewhere, as the output below shows, but not quite there yet. I will continue to investigate, but if you have any suggestions, I would appreciate. As per the documentation, I tried the command line below and it enters the library, but now produces a number of undefined function errors. These look like core functions to me. Should the order be different? All I'm trying to do is compile a test stub for rotating an image by 45 degrees. The code for this is at the very bottom of this message.
avenk

export PKG_CONFIG_PATH=/usr/local/packages; g++ -o warp -g

-I/opt/intel/ipp41/ia32_itanium/include

`pkg-config --cflags opencv` warp.cc rotate.cpp

`pkg-config --libs opencv`

-L/opt/intel/ipp41/ia32_itanium/lib

-lippiemerged -lippimerged -lippcore


/opt/intel/ipp41/ia32_itanium/lib/libippimerged.a(piwarpa_split2.o)(.text+0x51b): In function `px_ownpi_WarpAffine':
: undefined reference to `px_ippsFree'
/opt/intel/ipp41/ia32_itanium/lib/libippimerged.a(piwarpa_split2.o)(.text+0x2e12): In function `a6_ownpi_WarpAffine':
: undefined reference to `a6_ippsFree'
/opt/intel/ipp41/ia32_itanium/lib/libippimerged.a(piwarpa_split2.o)(.text+0x2ee8): In function `a6_ownpi_WarpAffine':
: undefined reference to `a6_ippsFree'
/opt/intel/ipp41/ia32_itanium/lib/libippimerged.a(piwarpa_split2.o)(.text+0x2f07): In function `a6_ownpi_WarpAffine':
: undefined reference to `a6_ippsMalloc_8u'
/opt/intel/ipp41/ia32_itanium/lib/libippimerged.a(piwarpa_split2.o)(.text+0x3242): In function `w7_ownpi_WarpAffine':
: undefined reference to `w7_ippsFree'
/opt/intel/ipp41/ia32_itanium/lib/libippimerged.a(piwarpa_split2.o)(.text+0x3321): In function `w7_ownpi_WarpAffine':
: undefined reference to `w7_ippsFree'
/opt/intel/ipp41/ia32_itanium/lib/libippimerged.a(piwarpa_split2.o)(.text+0x3346): In function `w7_ownpi_WarpAffine':
: undefined reference to `w7_ippsMalloc_8u'

#include "cv.h"
#include "highgui.h"
#include "math.h"
#include "ippcore.h"
#include "ipp.h"
void rotateImage(IplImage *src, IplImage *dst, float theta);
int main( int argc, char** argv )
{
IplImage* src;
/* the first command line parameter must be image file name */
ippStaticInitBest();
if( argc==2 && (src = cvLoadImage(argv[1], -1))!=0)
{
IplImage* dst = cvCloneImage( src );
int delta = 1;
int angle = 0;
cvNamedWindow( "src", 1 );
cvShowImage( "src", src );
rotateImage(src, dst, 45);
cvNamedWindow( "dst", 1 );
cvShowImage( "dst", dst );
cvWaitKey(0);
}
}
// from rotate.cpp
void iplWarpAffine(IplImage *src, IplImage *dst, const double coeffs[2][3], int interpolation)
{
Ipp8u *pSrc = (Ipp8u*)(void*)(src->imageData);
Ipp8u *pDst = (Ipp8u*)(void*)(src->imageData);
IppiSize srcSize;
srcSize.width = src->width;
srcSize.height = src->height;
IppiRect srcRoi, dstRoi;
// ownCalcRoiSize(src, &roi);
srcRoi.x = 0;
srcRoi.y = 0;
srcRoi.width = src->width;
srcRoi.height = src->height;
// ownCalcRoiSize(dst, &dstRoiSize);
dstRoi.x = 0;
dstRoi.y = 0;
dstRoi.widt h = dst->width;
dstRoi.height = dst->height;
ippiWarpAffine_8u_C3R(pSrc, srcSize, src->widthStep, srcRoi,
pDst, dst->widthStep, dstRoi, coeffs, interpolation);
}
void rotateImage(IplImage *img, IplImage *out, float theta)
// angle theta is ccwise in degrees
{
double c = cos(theta * 3.1415 / 180.0), s = sin(theta * 3.1415 / 180.0);
double x = ((double) img->width) / 2.0, y = ((double) img->height) / 2.0;
double coeffs[2][3];
coeffs[0][0] = c; coeffs[0][1] = s; coeffs[0][2] = x - x * c - y * s;
coeffs[1][0] = -s; coeffs[1][1] = c; coeffs[1][2] = y + x * s - y * c;
iplWarpAffine(img, out, coeffs, 1);
}
0 Kudos
Vladimir_Dudnik
Employee
447 Views
You are right, in Linux environment the order of libraries is important in linker command line. I recommend you to download any of IPP samples for Linux to see on their Makefiles and may be to use them as a scratch.
Regards,
Vladimir
0 Kudos
avenk
Beginner
447 Views
Vladimir
Thanks much. I downloaded the ipp-JPEG samples as per your suggestion and took a look at the Makefile and it became quite clear what the order of the libraries shouldbe. Just to help out anyone else who might be in the same situation: This is the sequence of steps needed to compile your code under linux:
From my Makefile:
IPPROOT = /opt/intel/ipp41/ia32_itanium
INCLUDES = -I$(IPPROOT)/include
CFLAGS = $(INCLUDES)
LDFLAGS = -L$(IPPROOT)/sharedlib -L$(IPPROOT)/sharedlib/linux32
-lippi -lippcore -lguide
(Note that the libraries you need above may be different, but the important thing is to have sharedlib/linux32 also in your lib search path since this is not mentioned anywhere that I can see plainly in the documentation).
The compilation step is:
$(CC) -o warp $(CFLAGS) warp.cc rotate.cpp $(LDFLAGS)
IMPORTANT:
You must edit /etc/ld.so.conf as root and make sure it includes:
/opt/intel/....../sharedlib
/opt/intel/....../sharedlib/linux32
and then run the command "ldconfig" as root. This will ensure that the runtime environment will find the dynamic .so libraries that you linked in.
Now that I can compile and link, on to the fun part -- My image rotation doesn't work. I wonder if it's possible to rotate an image using opencv and ipp routines. There doesn't seem to be one. My own Affinewarp clearly has a bug and I'm looking into it. But any pointers on library functions that I could use instead of reinventing the wheel would be greatly appreciated.
Thanks.
&
0 Kudos
Vladimir_Dudnik
Employee
447 Views
Ok, just one note, it is not mandatory to modify ld.so.conf file as a root user. You can just export LD_LIBRARY_PATH variable for your session.
So, now you need to take a look on IPP Image sample, unfortunately this sample is available only for Windows, but you can look at it to understand how to call ippiRotate function. The sample name is Image-Tiling, you can find it in "w_ipp-sample-image_p_4[1].1.004.zip" archive.
Regards,
Vladimir
0 Kudos
Reply