undefined reference to symbol 'glNormal3d' when building tests

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

undefined reference to symbol 'glNormal3d' when building tests

chrysn
hello openscad developers,

i'm running into the following error when building the test suite on
ubuntu:

/usr/bin/ld: libtests-core.a(polyset.cc.o): undefined reference to symbol 'glNormal3d'
/usr/bin/ld: note: 'glNormal3d' is defined in DSO /usr/lib/gcc/x86_64-linux-gnu/4.6.1/../../../x86_64-linux-gnu/libGL.so so try adding it to the linker command line
/usr/lib/gcc/x86_64-linux-gnu/4.6.1/../../../x86_64-linux-gnu/libGL.so: could not read symbols: Invalid operation

i traced the command run down to

/usr/bin/c++  -fno-strict-aliasing -DEIGEN_DONT_ALIGN -O2 -g
CMakeFiles/csgtermtest.dir/csgtermtest.cc.o
CMakeFiles/csgtermtest.dir/tmp/openscad-build/openscad-2011.12/src/CSGTermEvaluator.cc.o
-o csgtermtest -rdynamic libtests-common.a libtests-nocgal.a -lQtOpenGL
-lQtGui -lQtCore -lGLU -lGL -lSM -lICE -lX11 -lXext -lboost_thread-mt
-lboost_program_options-mt libtests-common.a libtests-core.a

and found out that it can be fixed by appending
/usr/lib/x86_64-linux-gnu/libGL.so to the command line arguments; the
whole situation seems to be what is described on [1].

unfortunately, i don't see through the whole build system, which is
cmake, which builds several make files which call each other, and calls
cmake inside them again. is there some top level switch to cmake i can
append to make it include libGL.so where required? the cmake invocation
i'm using right now is

cmake -DGLEW_LIBRARY=`pkg-config --variable libdir glew`/libGLEW.so .

the described behavior occurs on ubuntu oneiric; it doesn't occur on
debian unstable. (the c++ invocation on debian is roughly the same, but
doesn't show the behavior described in [1].)


in other news, as don bright already pointed out, the whole OGL_helper.h
license issue should be resolved now due to the CGAL4 release. i'm
currently waiting for a debian developer to finally review and include
the current openscad package into debian; the ubuntu packages will
follow once they are accepted and the libGL issue is resolved. i'll let
you know when there are actual results.


regards
chrysn

[1] http://fedoraproject.org/wiki/UnderstandingDSOLinkChange

--
To use raw power is to make yourself infinitely vulnerable to greater powers.
  -- Bene Gesserit axiom

signature.asc (836 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: undefined reference to symbol 'glNormal3d' when building tests

donbright
Hi Chrysn

Thanks for the bug report. I have seen some similar problems on
another 64 bit machine. My first step would be to copy/paste that C++
line and add the gcc debug flag that spits out all of it's linker
info. Diagnoses can also be performed with "strace -f".

The fix might be adding a line to CMAKE adding a library path, or
maybe running pkg-config inside of cmake (there is a cmake module that
does this), or maybe even detecting x86_64 + ubuntu 11 and adding a
specialized lib search path.

Are there any free places to get an ubuntu oneirc shell account on an
x86_64 machine? If so I could fix this tonight probably.

-DB

On Fri, Feb 17, 2012 at 11:18 AM, chrysn <[hidden email]> wrote:

> hello openscad developers,
>
> i'm running into the following error when building the test suite on
> ubuntu:
>
> /usr/bin/ld: libtests-core.a(polyset.cc.o): undefined reference to symbol 'glNormal3d'
> /usr/bin/ld: note: 'glNormal3d' is defined in DSO /usr/lib/gcc/x86_64-linux-gnu/4.6.1/../../../x86_64-linux-gnu/libGL.so so try adding it to the linker command line
> /usr/lib/gcc/x86_64-linux-gnu/4.6.1/../../../x86_64-linux-gnu/libGL.so: could not read symbols: Invalid operation
>
> i traced the command run down to
>
> /usr/bin/c++  -fno-strict-aliasing -DEIGEN_DONT_ALIGN -O2 -g
> CMakeFiles/csgtermtest.dir/csgtermtest.cc.o
> CMakeFiles/csgtermtest.dir/tmp/openscad-build/openscad-2011.12/src/CSGTermEvaluator.cc.o
> -o csgtermtest -rdynamic libtests-common.a libtests-nocgal.a -lQtOpenGL
> -lQtGui -lQtCore -lGLU -lGL -lSM -lICE -lX11 -lXext -lboost_thread-mt
> -lboost_program_options-mt libtests-common.a libtests-core.a
>
> and found out that it can be fixed by appending
> /usr/lib/x86_64-linux-gnu/libGL.so to the command line arguments; the
> whole situation seems to be what is described on [1].
>
> unfortunately, i don't see through the whole build system, which is
> cmake, which builds several make files which call each other, and calls
> cmake inside them again. is there some top level switch to cmake i can
> append to make it include libGL.so where required? the cmake invocation
> i'm using right now is
>
> cmake -DGLEW_LIBRARY=`pkg-config --variable libdir glew`/libGLEW.so .
>
> the described behavior occurs on ubuntu oneiric; it doesn't occur on
> debian unstable. (the c++ invocation on debian is roughly the same, but
> doesn't show the behavior described in [1].)
>
>
> in other news, as don bright already pointed out, the whole OGL_helper.h
> license issue should be resolved now due to the CGAL4 release. i'm
> currently waiting for a debian developer to finally review and include
> the current openscad package into debian; the ubuntu packages will
> follow once they are accepted and the libGL issue is resolved. i'll let
> you know when there are actual results.
>
>
> regards
> chrysn
>
> [1] http://fedoraproject.org/wiki/UnderstandingDSOLinkChange
>
> --
> To use raw power is to make yourself infinitely vulnerable to greater powers.
>  -- Bene Gesserit axiom
>
> _______________________________________________
> OpenSCAD mailing list
> [hidden email]
> http://rocklinux.net/mailman/listinfo/openscad
>

Reply | Threaded
Open this post in threaded view
|

Re: undefined reference to symbol 'glNormal3d' when building tests

kintel
Administrator
In reply to this post by chrysn
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Feb 17, 2012, at 18:18 PM, chrysn wrote:

> /usr/bin/ld: libtests-core.a(polyset.cc.o): undefined reference to symbol 'glNormal3d'
>
[...]
> /usr/bin/c++  -fno-strict-aliasing -DEIGEN_DONT_ALIGN -O2 -g
> CMakeFiles/csgtermtest.dir/csgtermtest.cc.o
> CMakeFiles/csgtermtest.dir/tmp/openscad-build/openscad-2011.12/src/CSGTermEvaluator.cc.o
> -o csgtermtest -rdynamic libtests-common.a libtests-nocgal.a -lQtOpenGL
> -lQtGui -lQtCore -lGLU -lGL -lSM -lICE -lX11 -lXext -lboost_thread-mt
> -lboost_program_options-mt libtests-common.a libtests-core.a
>
This looks like a classic problem with the order of linked libraries.
Put -lGL at the end and it should work.

FYI: On my oneiric VM, the cmd-line looks like this:

/usr/bin/c++    -fno-strict-aliasing -DEIGEN_DONT_ALIGN -O2 -g    CMakeFiles/csgtermtest.dir/csgtermtest.cc.o CMakeFiles/csgtermtest.dir/home/kintel/code/OpenSCAD/openscad/src/CSGTermEvaluator.cc.o  -o csgtermtest -rdynamic libtests-nocgal.a -lQtCore -lGLU -lGL -lSM -lICE -lX11 -lXext -lboost_thread-mt -lboost_program_options-mt -lboost_filesystem-mt -lboost_system-mt -lboost_regex-mt libtests-common.a libtests-core.a -lGLU -lGL -lSM -lICE -lX11 -lXext

I'm not sure why this is different though - we explicitly added ${OPENGL_LIBRARY} to the end of the cmake link line. Perhaps this variable is empty on your environment? Anyway, I think the solution lies somewhere in the vicinity of the target_link_libraries() statements in CMakeLists.txt.

If you can show this to me sometime, we can look into it on the failing machine.

 -Marius

-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org

iEYEARECAAYFAk8/vaoACgkQF4TaqdSZNKQsnQCfRihBm8nAg6luZug0S23f3l5q
8/AAn3Y2WndtpUIVuS4UaDBoRMYpvfnw
=CFUd
-----END PGP SIGNATURE-----

Reply | Threaded
Open this post in threaded view
|

Re: undefined reference to symbol 'glNormal3d' when building tests

kintel
Administrator
In reply to this post by chrysn
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Feb 17, 2012, at 18:18 PM, chrysn wrote:
>
> cmake -DGLEW_LIBRARY=`pkg-config --variable libdir glew`/libGLEW.so .
>
I just pushed a fix to the cmake build system to correctly find glew using pkg-config if you don't manually specify a location.

 -Marius

-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org

iEYEARECAAYFAk8/z5kACgkQF4TaqdSZNKS4KgCcCc0lfzO8DJ/bF+LeKtPhoBgl
npcAn3tTTXftsO21NwgCpV/rCnbYb8xi
=x5Dw
-----END PGP SIGNATURE-----

Reply | Threaded
Open this post in threaded view
|

Re: undefined reference to symbol 'glNormal3d' when building tests

chrysn
In reply to this post by kintel
On Sat, Feb 18, 2012 at 04:03:05PM +0100, Marius Kintel wrote:
> This looks like a classic problem with the order of linked libraries.
> Put -lGL at the end and it should work.

indeed it does work. to be precise: in the line

/usr/bin/c++  -fno-strict-aliasing -DEIGEN_DONT_ALIGN -O2 -g
CMakeFiles/csgtermtest.dir/csgtermtest.cc.o
CMakeFiles/csgtermtest.dir/tmp/openscad-build/openscad-2011.12/src/CSGTermEvaluator.cc.o
-o csgtermtest -rdynamic libtests-common.a libtests-nocgal.a -lQtOpenGL
-lQtGui -lQtCore -lGLU -lGL -lSM -lICE -lX11 -lXext -lboost_thread-mt
-lboost_program_options-mt libtests-common.a libtests-core.a

i have to insert it at the very end, between libtests-common.a and
libtests-core.a is not sufficient.

re-ordering the target_link_libraries line in CMakeLists.txt to put
OPENGL_LIBRARY to the end is not sufficient either, as the .a files
still come last.

i've traced the sequence back to CMakeFiles/csgtermtest.dir/build.make's
csgtermtest: block, but that seems to be generated from
target_link_libraries again.

> FYI: On my oneiric VM, the cmd-line looks like this:
> [...]
>
> I'm not sure why this is different though - we explicitly added
> ${OPENGL_LIBRARY} to the end of the cmake link line. Perhaps this
> variable is empty on your environment? Anyway, I think the solution
> lies somewhere in the vicinity of the target_link_libraries()
> statements in CMakeLists.txt.

i am working off the 2011.12 release, could that explain the difference?

thanks
chrysn

--
To use raw power is to make yourself infinitely vulnerable to greater powers.
  -- Bene Gesserit axiom

signature.asc (836 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: undefined reference to symbol 'glNormal3d' when building tests

kintel
Administrator
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Feb 18, 2012, at 20:04 PM, chrysn wrote:
>>
>> I'm not sure why this is different though - we explicitly added
>> ${OPENGL_LIBRARY} to the end of the cmake link line. Perhaps this
>> variable is empty on your environment? Anyway, I think the solution
>> lies somewhere in the vicinity of the target_link_libraries()
>> statements in CMakeLists.txt.
>
> i am working off the 2011.12 release, could that explain the difference?
>
I don't believe this has changed much since then.
It's tricky to fiddle with these things - I guess the best way would be to create a minimal example in cmake and see if it can be fixed in an easy way. It might very well be necessary with some cmake trickery.

 -Marius
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org

iEYEARECAAYFAk8//oIACgkQF4TaqdSZNKRzHwCg4XV5hyEPCVgmECulYCJ2MkHc
VNIAnArCmBYDCLA51MSD9W+cPrA9McSw
=XipK
-----END PGP SIGNATURE-----

Reply | Threaded
Open this post in threaded view
|

Re: undefined reference to symbol 'glNormal3d' when building tests

donbright
i don't know if this might help, but here are some example link lines
from 2 test machines. Im using git HEAD, with
"OPENSCAD_LIBRARIES=$HOME cmake"

--------------- start example 1
donb@gcc1-power7:~/src/openscad/tests/build$ uname -a
Linux gcc1-power7.osuosl.org 3.1.0-0.rc9.git0.2.fc16.kh.ppc64 #1 SMP
Wed Oct 12 22:41:01 UTC 2011 ppc64 ppc64 ppc64 GNU/Linux
donb@gcc1-power7:~/src/openscad/tests/build$ cmake --version
cmake version 2.8.5
donb@gcc1-power7:~$ gcc --version
gcc (GCC) 4.6.2 20111027 (Red Hat 4.6.2-1)
Copyright (C) 2011 Free Software Foundation, Inc.
donb@gcc1-power7:~$ make --version
GNU Make 3.82
Built for powerpc64-koji-linux-gnu
donb@gcc1-power7:~/src/openscad/tests/build$  make VERBOSE=1

...

Linking CXX executable csgtermtest
/usr/bin/cmake -E cmake_link_script
CMakeFiles/csgtermtest.dir/link.txt --verbose=1
/usr/bin/c++    -fno-strict-aliasing -DEIGEN_DONT_ALIGN -O2 -g
CMakeFiles/csgtermtest.dir/csgtermtest.cc.o
CMakeFiles/csgtermtest.dir/home/donb/src/openscad/src/CSGTermEvaluator.cc.o
 -o csgtermtest -rdynamic libtests-nocgal.a -lQtCore -lGLU -lGL -lSM
-lICE -lX11 -lXext -lboost_thread-mt -lboost_program_options-mt
-lboost_filesystem-mt -lboost_system-mt -lboost_regex-mt
libtests-common.a libtests-core.a -lGLU -lGL -lSM -lICE -lX11 -lXext


--------------- end example 1
--------------- example 2

donb@gcc45:~/src/openscad/tests/b$ uname -a
Linux gcc45 2.6.32-5-686 #1 SMP Mon Oct 3 04:15:24 UTC 2011 i686 GNU/Linux
donb@gcc45:~/src/openscad/tests/b$ cmake --version
cmake version 2.8.2
donb@gcc45:~$ make --version
GNU Make 3.81
donb@gcc45:~/src/openscad/tests/b$ gcc --version
gcc (Debian 4.4.5-8) 4.4.5

make VERBOSE=1

...

Linking CXX executable csgtermtest
/usr/bin/cmake -E cmake_link_script
CMakeFiles/csgtermtest.dir/link.txt --verbose=1
/usr/bin/c++    -fno-strict-aliasing -DEIGEN_DONT_ALIGN -O2 -g
CMakeFiles/csgtermtest.dir/csgtermtest.cc.o
CMakeFiles/csgtermtest.dir/home/donb/src/openscad/src/CSGTermEvaluator.cc.o
 -o csgtermtest -rdynamic libtests-nocgal.a -lQtCore -lGLU -lGL -lSM
-lICE -lX11 -lXext /home/donb/lib/libboost_thread.so
/home/donb/lib/libboost_program_options.so
/home/donb/lib/libboost_filesystem.so
/home/donb/lib/libboost_system.so /home/donb/lib/libboost_regex.so
libtests-common.a libtests-core.a -lGLU -lGL -lSM -lICE -lX11 -lXext
-Wl,-rpath,/home/donb/lib

-------------- end example 2

On Sat, Feb 18, 2012 at 1:39 PM, Marius Kintel <[hidden email]> wrote:
>>> I'm not sure why this is different though - we explicitly added
>>> ${OPENGL_LIBRARY} to the end of the cmake link line. Perhaps this
>>> variable is empty on your environment?

OpenSCAD's CMakeLists.txt is using find_package(OpenGL REQUIRED) so it
should, in theory, throw an error at 'cmake' time if it cannot find
any libGL.so, if i am remembering correctly how cmake works. it might
be a bug in cmake's FindOpenGL.cmake that only shows up on ubuntu 11
x86_64?

-DB

Reply | Threaded
Open this post in threaded view
|

patch for the "undefined reference to symbol 'glNormal3d'" problem

chrysn
In reply to this post by chrysn
i've talked with Dakon on the freenode #cmake channel, and he provided a
solution to the sequence of linker arguments problem:

add a line

target_link_libraries(tests-core ${OPENGL_LIBRARY})

before the

target_link_libraries(tests-common tests-core)

line. this makes the problem go away even on ubuntu systems.

(for reference, the ubuntu system added -Wl,--as-needed, which caused
the differences)

when reviewing the CMakeList.txt, he suggested that it could be enhanced
at several places, eg to use REQUIRED on the imagemagick search and
FindGLEW.cmake instead of checking for its results. the #cmake channel
seems rather active and helpful, and they have a mailing list too.

as a consequence, ubuntu packages are currently waiting for their slots
on the launchpad servers to be built.

regards
chrysn

--
To use raw power is to make yourself infinitely vulnerable to greater powers.
  -- Bene Gesserit axiom

signature.asc (836 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: patch for the "undefined reference to symbol 'glNormal3d'" problem

donbright
That is really awesome! Looking forward to it!

The reason for not using REQUIRED in Imagemagick is because the
default error messages when cmake dies after REQUIRED can be hard to
understand. By printing out "Imagemagick program 'convert' cannot be
found" it makes it very clear to the user what the problem is and what
needs to be done to solve it.

-DB

On Tue, Feb 21, 2012 at 4:24 PM, chrysn <[hidden email]> wrote:

> i've talked with Dakon on the freenode #cmake channel, and he provided a
> solution to the sequence of linker arguments problem:
>
> add a line
>
> target_link_libraries(tests-core ${OPENGL_LIBRARY})
>
> before the
>
> target_link_libraries(tests-common tests-core)
>
> line. this makes the problem go away even on ubuntu systems.
>
> (for reference, the ubuntu system added -Wl,--as-needed, which caused
> the differences)
>
> when reviewing the CMakeList.txt, he suggested that it could be enhanced
> at several places, eg to use REQUIRED on the imagemagick search and
> FindGLEW.cmake instead of checking for its results. the #cmake channel
> seems rather active and helpful, and they have a mailing list too.
>
> as a consequence, ubuntu packages are currently waiting for their slots
> on the launchpad servers to be built.
>
> regards
> chrysn
>
> --
> To use raw power is to make yourself infinitely vulnerable to greater powers.
>  -- Bene Gesserit axiom
>
> _______________________________________________
> OpenSCAD mailing list
> [hidden email]
> http://rocklinux.net/mailman/listinfo/openscad
>

Reply | Threaded
Open this post in threaded view
|

Re: patch for the "undefined reference to symbol 'glNormal3d'" problem

kintel
Administrator
In reply to this post by chrysn
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Feb 21, 2012, at 23:24 PM, chrysn wrote:

> add a line
>
> target_link_libraries(tests-core ${OPENGL_LIBRARY})
>
> before the
>
> target_link_libraries(tests-common tests-core)
>
The first line is already before the second line.
Perhaps I misunderstood. Could you send a patch against master with the version as it works for you?

 Marius

-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org

iEYEARECAAYFAk9E6kQACgkQF4TaqdSZNKQlJQCdE/BHPfOYoIZxyyEZIZJBWH7E
r3wAn3jpPSU9hw0dA8YQybTdRDu7v6dQ
=LpPH
-----END PGP SIGNATURE-----

Reply | Threaded
Open this post in threaded view
|

Re: patch for the "undefined reference to symbol 'glNormal3d'" problem

chrysn
> The first line is already before the second line.
> Perhaps I misunderstood. Could you send a patch against master with the version as it works for you?

it was fixed in don bright's 3d686118b, which didn't make it to the last
release, so this only affects <=2011.12 -- i think this issue can be
regarded as closed unless you want to keep maintenance branches of
releases.

i'll just keep the patch around in the debian packages until the next
release.

thanks
chrysn

--
To use raw power is to make yourself infinitely vulnerable to greater powers.
  -- Bene Gesserit axiom

signature.asc (836 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: patch for the "undefined reference to symbol 'glNormal3d'" problem

donbright
sorry i didn't realize this sooner...  i got confused about which
branch i was discussing.

DB

On Wed, Feb 22, 2012 at 8:28 AM, chrysn <[hidden email]> wrote:
>> The first line is already before the second line.
>> Perhaps I misunderstood. Could you send a patch against master with the version as it works for you?
>
> it was fixed in don bright's 3d686118b, which didn't make it to the last