Imagination PowerVR SDK Blog

Problem in linking libPVRLib.a


#1


using namespace pvrtexlib;

int main()
{
   const uint8* const test1 = NULL;
   CPVRTexture myTexture(test1);
   
   
   
    return 0;   
}

when i tried linking this code in linux i got the following linking error,

g++ 1.cpp -lPVRTexLib -static-libstdc++ -L/home/kumar/my_prog -L/usr/lib -m32
g++: unrecognized option -static-libstdc++'<br>/home/kumar/my_prog/libPVRTexLib.a(pvr_utils.o)(.text+0x310e): In functionpvrtexlib::PVRTextureUtilities::getPixelTypeForId(CPVRTString)’:
: undefined reference to std::_Rb_tree_increment(std::_Rb_tree_node_base*)'<br>/home/kumar/my_prog/libPVRTexLib.a(pvr_utils.o)(.text+0x31b6): In functionpvrtexlib::PVRTextureUtilities::getPixelTypeForName(CPVRTString)’:
: undefined reference to std::_Rb_tree_increment(std::_Rb_tree_node_base*)'<br>/home/kumar/my_prog/libPVRTexLib.a(pvr_utils.o)(.text+0x32f3): In functionpvrtexlib::PVRTextureUtilities::~PVRTextureUtilities in-charge deleting’:
: undefined reference to std::_Rb_tree_increment(std::_Rb_tree_node_base*)'<br>/home/kumar/my_prog/libPVRTexLib.a(pvr_utils.o)(.text+0x3493): In functionpvrtexlib::PVRTextureUtilities::~PVRTextureUtilities in-charge’:
: undefined reference to std::_Rb_tree_increment(std::_Rb_tree_node_base*)'<br>/home/kumar/my_prog/libPVRTexLib.a(pvr_utils.o)(.text+0x363b): In functionpvrtexlib::PVRTextureUtilities::~PVRTextureUtilities not-in-charge’:
: undefined reference to std::_Rb_tree_increment(std::_Rb_tree_node_base*)'<br>/home/kumar/my_prog/libPVRTexLib.a(pvr_utils.o)(.gnu.linkonce.t._ZNSt8_Rb_treeIN9pvrtexlib9PixelTypeESt4pairIKS1_PNS0_11PixelFormatEESt10_Select1stIS6_ESt4lessIS1_ESaIS6_EE9_M_insertEPSt18_Rb_tree_node_baseSE_RKS6_+0x44): In functionstd::_Rb_tree<pvrtexlib::PixelType, std::pair<pvrtexlib::PixelType const, pvrtexlib::PixelFormat*>, std::_Select1st<std::pair<pvrtexlib::PixelType const, pvrtexlib::PixelFormat*> >, std::less<pvrtexlib::PixelType>, std::allocator<std::pair<pvrtexlib::PixelType const, pvrtexlib::PixelFormat*> > >::_M_insert(std::_Rb_tree_node_base*, std::_Rb_tree_node_base*, std::pair<pvrtexlib::PixelType const, pvrtexlib::PixelFormat*> const&)’:
: undefined reference to std::_Rb_tree_insert_and_rebalance(bool, std::_Rb_tree_node_base*, std::_Rb_tree_node_base*, std::_Rb_tree_node_base&amp;)'<br>/home/kumar/my_prog/libPVRTexLib.a(pvr_utils.o)(.gnu.linkonce.t._ZNSt8_Rb_treeIN9pvrtexlib9PixelTypeESt4pairIKS1_PNS0_11PixelFormatEESt10_Select1stIS6_ESt4lessIS1_ESaIS6_EE13insert_uniqueERKS6_+0x83): In functionstd::_Rb_tree<pvrtexlib::PixelType, std::pair<pvrtexlib::PixelType const, pvrtexlib::PixelFormat*>, std::_Select1st<std::pair<pvrtexlib::PixelType const, pvrtexlib::PixelFormat*> >, std::less<pvrtexlib::PixelType>, std::allocator<std::pair<pvrtexlib::PixelType const, pvrtexlib::PixelFormat*> > >::insert_unique(std::pair<pvrtexlib::PixelType const, pvrtexlib::PixelFormat*> const&)’:
: undefined reference to std::_Rb_tree_decrement(std::_Rb_tree_node_base*)'<br>/home/kumar/my_prog/libPVRTexLib.a(pvr_utils.o)(.gnu.linkonce.t._ZNSt8_Rb_treeIN9pvrtexlib9PixelTypeESt4pairIKS1_PNS0_11PixelFormatEESt10_Select1stIS6_ESt4lessIS1_ESaIS6_EE13insert_uniqueESt17_Rb_tree_iteratorIS6_ERKS6_+0x29): In functionstd::_Rb_tree<pvrtexlib::PixelType, std::pair<pvrtexlib::PixelType const, pvrtexlib::PixelFormat*>, std::_Select1st<std::pair<pvrtexlib::PixelType const, pvrtexlib::PixelFormat*> >, std::less<pvrtexlib::PixelType>, std::allocator<std::pair<pvrtexlib::PixelType const, pvrtexlib::PixelFormat*> > >::insert_unique(std::_Rb_tree_iterator<std::pair<pvrtexlib::PixelType const, pvrtexlib::PixelFormat*> >, std::pair<pvrtexlib::PixelType const, pvrtexlib::PixelFormat*> const&)’:
: undefined reference to `std::_Rb_tree_decrement(std::_Rb_tree_node_base*)'
collect2: ld returned 1 exit status

Compiler option:
g++ 1.cpp -lPVRTexLib -static-libstdc++ -L/home/kumar/my_prog -L/usr/lib -m32

Rescue me… Cry


#2

I can’t reproduce this fault here - what Linux distro are you building on?





Incidentally, passing a NULL pointer to the CPVRTexture constructor is going to seg fault, as I just discovered. This will be fixed in a new release.


#3

i am using SuSE 9 patch level 3, which means 9.3

every thing are on as is basis, i didnot installed any other extra or add on packages…

thank you for your reply…


#4

its x86_64 version of SuSE 9.3


#5

As I think you have gathered, the PVRTexLib library is 32-bit and I think this is where the problems come from. Sadly, we aren’t doing 64-bit builds at the moment so I can’t really help you on this point. It looks to me like there is a mismatch between the standard libraries on your system and what PVRTexLib expects. So firstly, I would verify that the correct libraries are present, there is a linker path to them and check that the -static-libstdc++ flag is correct to link to these. I’m sorry I can’t be more help.


#6

Hello Gordan,

I tried compiling in SuSE Linux 9.3 x86 szstem, but still i am getting the same error.
[…]$ g++ -m32 1.cpp -L~/no_backup/mywork/libstdcpp/usr/lib/ -L/home/kumar/my_prog/ -lPVRTexLib -Wall -o 1 -v

Reading specs from /usr/lib/gcc-lib/i586-suse-linux/3.3.3/specs
Configured with: …/configure --enable-threads=posix --prefix=/usr --with-local-prefix=/usr/local --infodir=/usr/share/info --mandir=/usr/share/man --enable-languages=c,c++,f77,objc,java,ada --disable-checking --libdir=/usr/lib --enable-libgcj --with-gxx-include-dir=/usr/include/g++ --with-slibdir=/lib --with-system-zlib --enable-shared --enable-cxa_atexit i586-suse-linux
Thread model: posix
gcc version 3.3.3 (SuSE Linux)
 /usr/lib/gcc-lib/i586-suse-linux/3.3.3/cc1plus -quiet -v -D__GNUC
=3 -D__GNUC_MINOR__=3 -D__GNUC_PATCHLEVEL__=3 -D_GNU_SOURCE 1.cpp -D__GNUG__=3 -quiet -dumpbase 1.cpp -m32 -auxbase 1 -Wall -version -o /tmp/ccz3gSln.s
GNU C++ version 3.3.3 (SuSE Linux) (i586-suse-linux)
        compiled by GNU C version 3.3.3 (SuSE Linux).
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
#include “…” search starts here:
#include <…> search starts here:
 /usr/include/g++
 /usr/include/g++/i586-suse-linux
 /usr/include/g++/backward
 /usr/local/include
 /usr/lib/gcc-lib/i586-suse-linux/3.3.3/include
 /usr/i586-suse-linux/include
 /usr/include
End of search list.
 /usr/lib/gcc-lib/i586-suse-linux/3.3.3/…/…/…/…/i586-suse-linux/bin/as -V -Qy -o /tmp/ccix3u1E.o /tmp/ccz3gSln.s
GNU assembler version 2.15.90.0.1.1 (i586-suse-linux) using BFD version 2.15.90.0.1.1 20040303 (SuSE Linux)
 /usr/lib/gcc-lib/i586-suse-linux/3.3.3/collect2 --eh-frame-hdr -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 -o 1 /usr/lib/gcc-lib/i586-suse-linux/3.3.3/…/…/…/crt1.o /usr/lib/gcc-lib/i586-suse-linux/3.3.3/…/…/…/crti.o /usr/lib/gcc-lib/i586-suse-linux/3.3.3/crtbegin.o -L~/no_backup/mywork/libstdcpp/usr/lib/ -L/home/kumar/my_prog/ -L/usr/lib/gcc-lib/i586-suse-linux/3.3.3 -L/usr/lib/gcc-lib/i586-suse-linux/3.3.3/…/…/…/…/i586-suse-linux/lib -L/usr/lib/gcc-lib/i586-suse-linux/3.3.3/…/…/… /tmp/ccix3u1E.o -lPVRTexLib -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/lib/gcc-lib/i586-suse-linux/3.3.3/crtend.o /usr/lib/gcc-lib/i586-suse-linux/3.3.3/…/…/…/crtn.o
/home/kumar/my_prog//libPVRTexLib.a(pvr_utils.o)(.text+0x310e): In function pvrtexlib::PVRTextureUtilities::getPixelTypeForId(CPVRTString)':<br>: undefined reference tostd::_Rb_tree_increment(std::_Rb_tree_node_base*)’
/home/kumar/my_prog//libPVRTexLib.a(pvr_utils.o)(.text+0x31b6): In function pvrtexlib::PVRTextureUtilities::getPixelTypeForName(CPVRTString)':<br>: undefined reference tostd::_Rb_tree_increment(std::_Rb_tree_node_base*)’
/home/kumar/my_prog//libPVRTexLib.a(pvr_utils.o)(.text+0x32f3): In function pvrtexlib::PVRTextureUtilities::~PVRTextureUtilities [in-charge deleting]()':<br>: undefined reference tostd::_Rb_tree_increment(std::_Rb_tree_node_base*)’
/home/kumar/my_prog//libPVRTexLib.a(pvr_utils.o)(.text+0x3493): In function pvrtexlib::PVRTextureUtilities::~PVRTextureUtilities [in-charge]()':<br>: undefined reference tostd::_Rb_tree_increment(std::_Rb_tree_node_base*)’
/home/kumar/my_prog//libPVRTexLib.a(pvr_utils.o)(.text+0x363b): In function pvrtexlib::PVRTextureUtilities::~PVRTextureUtilities [not-in-charge]()':<br>: undefined reference tostd::_Rb_tree_increment(std::_Rb_tree_node_base*)’
/home/kumar/my_prog//libPVRTexLib.a(pvr_utils.o)(.gnu.linkonce.t.ZNSt8_Rb_treeIN9pvrtexlib9PixelTypeESt4pairIKS1_PNS0_11PixelFormatEESt10_Select1stIS6_ESt4lessIS1_ESaIS6_EE9_M_insertEPSt18_Rb_tree_node_baseSE_RKS6+0x44): In function std::_Rb_tree&lt;pvrtexlib::PixelType, std::pair&lt;pvrtexlib::PixelType const, pvrtexlib::PixelFormat*&gt;, std::_Select1st&lt;std::pair&lt;pvrtexlib::PixelType const, pvrtexlib::PixelFormat*&gt; &gt;, std::less&lt;pvrtexlib::PixelType&gt;, std::allocator&lt;std::pair&lt;pvrtexlib::PixelType const, pvrtexlib::PixelFormat*&gt; &gt; &gt;::_M_insert(std::_Rb_tree_node_base*, std::_Rb_tree_node_base*, std::pair&lt;pvrtexlib::PixelType const, pvrtexlib::PixelFormat*&gt; const&amp;)':<br>: undefined reference tostd::_Rb_tree_insert_and_rebalance(bool, std::_Rb_tree_node_base*, std::_Rb_tree_node_base*, std::_Rb_tree_node_base&)’
/home/kumar/my_prog//libPVRTexLib.a(pvr_utils.o)(.gnu.linkonce.t.ZNSt8_Rb_treeIN9pvrtexlib9PixelTypeESt4pairIKS1_PNS0_11PixelFormatEESt10_Select1stIS6_ESt4lessIS1_ESaIS6_EE13insert_uniqueERKS6+0x83): In function std::_Rb_tree&lt;pvrtexlib::PixelType, std::pair&lt;pvrtexlib::PixelType const, pvrtexlib::PixelFormat*&gt;, std::_Select1st&lt;std::pair&lt;pvrtexlib::PixelType const, pvrtexlib::PixelFormat*&gt; &gt;, std::less&lt;pvrtexlib::PixelType&gt;, std::allocator&lt;std::pair&lt;pvrtexlib::PixelType const, pvrtexlib::PixelFormat*&gt; &gt; &gt;::insert_unique(std::pair&lt;pvrtexlib::PixelType const, pvrtexlib::PixelFormat*&gt; const&amp;)':<br>: undefined reference tostd::_Rb_tree_decrement(std::_Rb_tree_node_base*)’
/home/kumar/my_prog//libPVRTexLib.a(pvr_utils.o)(.gnu.linkonce.t.ZNSt8_Rb_treeIN9pvrtexlib9PixelTypeESt4pairIKS1_PNS0_11PixelFormatEESt10_Select1stIS6_ESt4lessIS1_ESaIS6_EE13insert_uniqueESt17_Rb_tree_iteratorIS6_ERKS6+0x29): In function std::_Rb_tree&lt;pvrtexlib::PixelType, std::pair&lt;pvrtexlib::PixelType const, pvrtexlib::PixelFormat*&gt;, std::_Select1st&lt;std::pair&lt;pvrtexlib::PixelType const, pvrtexlib::PixelFormat*&gt; &gt;, std::less&lt;pvrtexlib::PixelType&gt;, std::allocator&lt;std::pair&lt;pvrtexlib::PixelType const, pvrtexlib::PixelFormat*&gt; &gt; &gt;::insert_unique(std::_Rb_tree_iterator&lt;std::pair&lt;pvrtexlib::PixelType const, pvrtexlib::PixelFormat*&gt; &gt;, std::pair&lt;pvrtexlib::PixelType const, pvrtexlib::PixelFormat*&gt; const&amp;)':<br>: undefined reference tostd::_Rb_tree_decrement(std::_Rb_tree_node_base*)'
collect2: ld returned 1 exit status

Kindly help me reagrding the same.



#7

Trying the same scenario on a 64bit Debian system. I am trying to link the libPVRTexLib.a while building a .so. If you have any input/ideas, or any plans on providing a 64bit version of the library, I would very much appreciate anything you could share with us.





thank you.


#8


I was able to compile things properly in SuSE10.2.

Thank you…

-Harish



#9

Harish:


Just to confirm/clarify: you are talking about a 64bit SuSE system right? Did you add any special support libraries or tweak the system / make process in other way to make it work?





Thank you!


#10


No, i used SuSe 10.2 version and its default gcc(4.1.2) and libs.
Previously i was using SuSe 9.4 and also 9.3, in both those systems there where no help because of gcc and lib versions(gcc 3.3.3).

-Harish


#11

hmm so basically you are saying that upgrading to gcc4.1.2 let you link to the library on a 64bit suse system? That’s very encouraging! Thank you very much! (I will confirm the gcc version on my box.)


#12

Hi,

Also we have to upgrade libstdc++ to 4.1.2. in my system things are by default, so i didn’t faced any problem in the new SuSe version with 64bit support.

the problem started from libstdc++ library in SuSe 9 series… :frowning:

-Harish


#13

Harish!





I see! Thank you very much! I will see how far your input can get me, but this is very valuable information indeed!





Thank you.