LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   lib3ds undefined reference (https://www.linuxquestions.org/questions/linux-software-2/lib3ds-undefined-reference-4175421587/)

opul 08-11-2012 12:37 PM

lib3ds undefined reference
 
Hi

I want to compile a program PTAMM that, among other things, also needs lib3ds. After I had build those libraries and started to make the program I got this error;

Model3ds.cc:(.text+0x502): undefined reference to `lib3ds_mesh_calculate_vertex_normals'
Model3ds.o: In function `PTAMM::Model3DS::_Load()':
Model3ds.cc:(.text+0xeb6): undefined reference to `lib3ds_file_open'
collect2: ld returned 1 exit status
make: *** [PTAMM] Error 1

The header for this function is lib3ds.h and is in /usr/local.
During the configure of lib3ds it showed it missed g77 and xlf but I guess it then went for f77 as shown below;

checking how to run the C++ preprocessor... g++ -E
checking for g77... no
checking for xlf... no
checking for f77... f77
checking whether we are using the GNU Fortran 77 compiler... yes
checking whether f77 accepts -g... yes

If that's the problem then I wonder how to get g77 and xlf.
Some other forums spoke about the gcc-4 and higher could be the problem. But there wasn't really a solution given. I did install gcc-3.4 though, but it resides along side gcc-4 (de-installing gcc via synaptic manager seems dangerous), so I guess it doesn't change a whole lot.

What would be the best way to go about this?

knudfl 08-12-2012 05:21 AM

Quote:

checking for f77... f77
Means : Found a ///bin/f77 ( /usr/bin/f77 ? ).
g77 is a link to f77. Or a copy of f77.
And besides that : There's no fortran code in lib3ds. It's all c.
It's just a default configure file :
Will look for a fortran77 compiler also when there are no fortran files in the program.


Not all the libraries work well on all OS.
And you cannot use all versions of the libraries.
( A "latest version" may fail.)
Example that compiles OK on CentOS 6.3 64bits :
TooN-2.0 lib3ds-20080909 libcvd-20100511 gvars3-20120724 PTAM.

Which OS are you using ? Name, <version>, <architecture> please.

.

opul 08-12-2012 08:58 AM

I'm using Ubuntu 10.10 on, I guess, an i386 architecture (32 bit intel)

So the mentioning of no g77 and xlf shouldn't be a problem? It just switches compilers or something?

I've now tried both versions of lib3ds I could find, with first of lib3ds-20080909 and then lib3ds-1.3.0. But still to no avail.

414N 08-12-2012 09:23 AM

Quote:

Originally Posted by opul (Post 4751803)
Code:

Model3ds.cc:(.text+0x502): undefined reference to `lib3ds_mesh_calculate_vertex_normals'
Model3ds.o: In function `PTAMM::Model3DS::_Load()':
Model3ds.cc:(.text+0xeb6): undefined reference to `lib3ds_file_open'
collect2: ld returned 1 exit status
make: *** [PTAMM] Error 1


Those are linker errors: the linker cannot find references to the listed symbols (lib3ds_mesh_calculate_vertex_normals and
lib3ds_file_open) inside the libraries specified during the build and so bails out, aborting the build.
Have you properly installed lib3ds prior the PTAMM build? If so, run ldconfig first to update shared library information and check the library presence with
Code:

ldconfig -p | grep lib3ds

knudfl 08-12-2012 10:02 AM

Ubuntu 10.10 :

How about : sudo apt-get install lib3ds-dev

It is a patched version of lib3ds-1.3.0 :
With the 980 kB patch, lib3ds_1.3.0-5.diff
http://packages.ubuntu.com/natty/lib3ds-dev


.

opul 08-12-2012 03:02 PM

Thanks for the pointers, I tried ldconfig -p | grep lib3ds. this gives;

Code:

opie@ubuntu:~/workspace/PTAMM$ ldconfig -p | grep lib3ds
        lib3ds-2.so.0 (libc6) => /usr/local/lib/lib3ds-2.so.0
        lib3ds-1.so.3 (libc6) => /usr/local/lib/lib3ds-1.so.3
        lib3ds-1.so.3 (libc6) => /usr/lib/lib3ds-1.so.3
        lib3ds-1.so (libc6) => /usr/lib/lib3ds-1.so

So i guess this is linked. header files reside in /usr/include/lib3ds

Also tried the dev update and a re-install via synaptic, but that didn't help either.

There also is a test program I compiled and run, ubuntu-3dstest, that put out the right numbers;
Code:

Expecting: 0.065576; Value returned by lib3ds: 0.065576
If the values do not match try compiling lib3ds with the -O0 flag, or with a version of g++ prior to 4.0

So that should be ok too.

I saw somewhere that lib3ds was incompatible with gcc-4 optimization feature causing vertex data problems, so setting in the makefile CFLAGS to -O0 would help, but it didn't :(

414N 08-13-2012 02:06 AM

Quote:

Originally Posted by opul (Post 4752547)
Thanks for the pointers, I tried ldconfig -p | grep lib3ds. this gives;

Code:

opie@ubuntu:~/workspace/PTAMM$ ldconfig -p | grep lib3ds
        lib3ds-2.so.0 (libc6) => /usr/local/lib/lib3ds-2.so.0
        lib3ds-1.so.3 (libc6) => /usr/local/lib/lib3ds-1.so.3
        lib3ds-1.so.3 (libc6) => /usr/lib/lib3ds-1.so.3
        lib3ds-1.so (libc6) => /usr/lib/lib3ds-1.so

So i guess this is linked. header files reside in /usr/include/lib3ds

Why there are so many lib3ds? Have you manually compiled and installed it, other than installing lib3ds from the repository? Maybe PTAMM is picking up the one in /usr/lib (presumably, the one from the repo) instead of the one in /usr/local. Try looking for PTAMM build configuration flags to specify the location of lib3ds manually.

knudfl 08-13-2012 04:08 AM

PTAMM compiles OK on a 32bits reference OS,
e.g. CentOS 6.3 - 32 and Ubuntu 10.04 - 32.

And : The Ubuntu lib3ds packages did not work, sorry.
Please remove the two packages.

Lib3ds files :
Code:

ls /usr/lib/lib3ds*
/usr/lib/lib3ds-2.so.0      /usr/lib/lib3ds.a  /usr/lib/lib3ds.so
/usr/lib/lib3ds-2.so.0.0.0  /usr/lib/lib3ds.la

I.e. I'd suggest to configure TooN, lib3ds, libcvd, gvars3 with :
./configure --prefix=/usr/

Links http://www.robots.ox.ac.uk/~bob/rese...rch_ptamm.html
http://www.robots.ox.ac.uk/~bob/software/index.html
http://www.robots.ox.ac.uk/~bob/soft...amm/manual.pdf

.

knudfl 08-13-2012 08:40 AM

Ubuntu 10.10 - 32 : 1) sudo apt-get install libxmu-dev \
libdc1394-22-dev libreadline6-dev liblapack-dev libcv-dev libfltk1.1-dev \
libgl1-mesa-dev libglu1-mesa-dev libtiff4-dev libpng12-dev libjpeg62-dev

2) TooN-2.0, lib3ds-20080909, libcvd-20100511, gvars3-20120724 :
./configure --prefix=/usr

3) cd PTAM/ && make :
The binaries "CameraCalibrator" and "PTAM" are created.

.

opul 08-14-2012 01:34 AM

The problem was a different link required for lib3ds, the .so files lie both in /usr/lib and in /usr/local/lib but the last ones don't seemed to work so well.

I changed in the make file to:
LINKFLAGS = -L /usr/lib/ -l3ds -L /usr/local/lib/ -lcvd -lGVars3

The link to lib3ds had to go to the front so it would look there first.

After a make clean it worked :)


All times are GMT -5. The time now is 06:47 PM.