My advisor is always right. So I have decided to take a look at Im lib, from Tecgraf.
As a learner by example, I first tried to compile and run the examples provided with Im lib, but most of their examples came written in lua and I need to write my code in C (or C++). Fortunately there were 6 examples written in C++:
glut_capture.c im_copy.cpp im_info.cpp im_view.c iupglview.c proc_fourier.cpp
But, I wans't use glut (discarted glut_capture.c and iupglview.c)
So I've choosen im_view.c to try to compile, and the torture has started. There wans't any doc, readme or anything which tells something on how to compile the examples. The only clue was the comments written on the source header:
/*
IM 3 sample that shows an image. Needs "im.lib", "iup.lib", "cd.lib" and "cdiup.lib". Usage: im_view Example: im_view test.tif Click on image to open another file.
*/
Well, I had discovered that I was needing three more libs from Tecgraf to compile this example. So let's get them. With all these four libs I did put them all at /usr/local/tec/include and /usr/local/tec/lib, changed my /etc/ld.so.conf to add /usr/local/tec/lib and had runned the ldconfig command. But now, which GCC parameters I should use?
Issuing a gcc -I/usr/local/tec/include/ -L/usr/local/tec/lib im_view.c
was always resulting on error. Taking a look at imlib dependencies with ldd
# ldd libim.so
linux-gate.so.1 => (0xb7f27000)
libm.so.6 => not found
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0xb7dc9000)
libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0xb7c79000) /lib/ld-linux.so.2 (0xb7f28000)
I have discovered that my system was missing the libm.so.6. After googling a little I have figured out that libm is the motif library. With a apt-cache search libmotif:
apt-cache search libmotif
libmotif-dev - Open Motif - development files
libmotif3 - Open Motif - shared libraries
Ubuntu has a package for libmotif3. Installing it the ldd on libim.so din'd show bronken dependencies anymore:
# ldd libim.so
linux-gate.so.1 => (0xb7f27000)
libm.so.6 => /lib/tls/i686/cmov/libm.so.6 (0xb7dd4000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0xb7dc9000)
libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0xb7c79000) /lib/ld-linux.so.2 (0xb7f28000)
And adding the -l flag to the gcc, I got this output:
gcc -I/usr/local/tec/include/ -L/usr/local/tec/lib im_view.c -liup -lim -lcd
/tmp/ccKdeRAP.o: In function `CreateDialog': im_view.c:(.text+0x634): undefined reference to `cdContextIup'
/usr/local/tec/lib/libim.so: undefined reference to `operator new[](unsigned int)'
/usr/local/tec/lib/libim.so: undefined reference to `operator delete[](void*)'
/usr/local/tec/lib/libim.so: undefined reference to `operator delete(void*)'
/usr/local/tec/lib/libim.so: undefined reference to `__cxa_pure_virtual'
/usr/local/tec/lib/libim.so: undefined reference to `__gxx_personality_v0'
/usr/local/tec/lib/libim.so: undefined reference to `vtable for __cxxabiv1::__vmi_class_type_info'
/usr/local/tec/lib/libim.so: undefined reference to `vtable for __cxxabiv1::__class_type_info'
/usr/local/tec/lib/libim.so: undefined reference to `operator new(unsigned int)'
/usr/local/tec/lib/libim.so: undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
collect2: ld returned 1 exit status
Very strange, as im_view.c was suposed to be a C program, not C++. Well the libs must have C++ operations, so let's compile with g++.
g++ -I/usr/local/tec/include/ -L/usr/local/tec/lib im_view.c -liup -lim -lcd
/tmp/cc01yIbF.o: In function `CreateDialog()':
im_view.c:(.text+0xd8): undefined reference to `cdContextIup' collect2: ld returned 1 exit status
But there still one missing reference. Obviously I had missed -lcdiup, but:
g++ -I/usr/local/tec/include/ -L/usr/local/tec/lib im_view.c -liup -lim -lcd -lcdiup
/usr/bin/ld: cannot find -lcdiup collect2: ld returned 1 exit status
So what's up.
Fortunately, the project has an on-line history log
http://www.tecgraf.puc-rio.br/cd/en/history.html
And looking at the history, I found this peace of information:
So, it wasn't -lcdiup, in stead it was -liupcd. I finally had my g++ command line:
g++ -I/usr/local/tec/include/ -L/usr/local/tec/lib im_view.c -liup -lim -lcd -liupcd
And here is a screenshot of my im_view running:
Im lib looks very promising. Now that I have runned my first example, I hope to learn it soon.
As a learner by example, I first tried to compile and run the examples provided with Im lib, but most of their examples came written in lua and I need to write my code in C (or C++). Fortunately there were 6 examples written in C++:
glut_capture.c im_copy.cpp im_info.cpp im_view.c iupglview.c proc_fourier.cpp
But, I wans't use glut (discarted glut_capture.c and iupglview.c)
So I've choosen im_view.c to try to compile, and the torture has started. There wans't any doc, readme or anything which tells something on how to compile the examples. The only clue was the comments written on the source header:
/*
IM 3 sample that shows an image. Needs "im.lib", "iup.lib", "cd.lib" and "cdiup.lib". Usage: im_view
*/
Well, I had discovered that I was needing three more libs from Tecgraf to compile this example. So let's get them. With all these four libs I did put them all at /usr/local/tec/include and /usr/local/tec/lib, changed my /etc/ld.so.conf to add /usr/local/tec/lib and had runned the ldconfig command. But now, which GCC parameters I should use?
Issuing a gcc -I/usr/local/tec/include/ -L/usr/local/tec/lib im_view.c
was always resulting on error. Taking a look at imlib dependencies with ldd
# ldd libim.so
linux-gate.so.1 => (0xb7f27000)
libm.so.6 => not found
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0xb7dc9000)
libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0xb7c79000) /lib/ld-linux.so.2 (0xb7f28000)
I have discovered that my system was missing the libm.so.6. After googling a little I have figured out that libm is the motif library. With a apt-cache search libmotif:
apt-cache search libmotif
libmotif-dev - Open Motif - development files
libmotif3 - Open Motif - shared libraries
Ubuntu has a package for libmotif3. Installing it the ldd on libim.so din'd show bronken dependencies anymore:
# ldd libim.so
linux-gate.so.1 => (0xb7f27000)
libm.so.6 => /lib/tls/i686/cmov/libm.so.6 (0xb7dd4000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0xb7dc9000)
libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0xb7c79000) /lib/ld-linux.so.2 (0xb7f28000)
And adding the -l flag to the gcc, I got this output:
gcc -I/usr/local/tec/include/ -L/usr/local/tec/lib im_view.c -liup -lim -lcd
/tmp/ccKdeRAP.o: In function `CreateDialog': im_view.c:(.text+0x634): undefined reference to `cdContextIup'
/usr/local/tec/lib/libim.so: undefined reference to `operator new[](unsigned int)'
/usr/local/tec/lib/libim.so: undefined reference to `operator delete[](void*)'
/usr/local/tec/lib/libim.so: undefined reference to `operator delete(void*)'
/usr/local/tec/lib/libim.so: undefined reference to `__cxa_pure_virtual'
/usr/local/tec/lib/libim.so: undefined reference to `__gxx_personality_v0'
/usr/local/tec/lib/libim.so: undefined reference to `vtable for __cxxabiv1::__vmi_class_type_info'
/usr/local/tec/lib/libim.so: undefined reference to `vtable for __cxxabiv1::__class_type_info'
/usr/local/tec/lib/libim.so: undefined reference to `operator new(unsigned int)'
/usr/local/tec/lib/libim.so: undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
collect2: ld returned 1 exit status
Very strange, as im_view.c was suposed to be a C program, not C++. Well the libs must have C++ operations, so let's compile with g++.
g++ -I/usr/local/tec/include/ -L/usr/local/tec/lib im_view.c -liup -lim -lcd
/tmp/cc01yIbF.o: In function `CreateDialog()':
im_view.c:(.text+0xd8): undefined reference to `cdContextIup' collect2: ld returned 1 exit status
But there still one missing reference. Obviously I had missed -lcdiup, but:
g++ -I/usr/local/tec/include/ -L/usr/local/tec/lib im_view.c -liup -lim -lcd -lcdiup
/usr/bin/ld: cannot find -lcdiup collect2: ld returned 1 exit status
So what's up.
Fortunately, the project has an on-line history log
http://www.tecgraf.puc-rio.br/cd/en/history.html
And looking at the history, I found this peace of information:
Changed: IMPORTANT - the "cdiup" and "cdluaiup" libraries moved from CD to IUP under the name "iupcd" and "iupluacd". But headers and documentation remains on the CD package. Function names were NOT changed. This change eliminates a cross-dependency that IUP and CD had, now only IUP depends on CD.
So, it wasn't -lcdiup, in stead it was -liupcd. I finally had my g++ command line:
g++ -I/usr/local/tec/include/ -L/usr/local/tec/lib im_view.c -liup -lim -lcd -liupcd
And here is a screenshot of my im_view running:
Im lib looks very promising. Now that I have runned my first example, I hope to learn it soon.
Comments
Post a Comment