View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0002321 | Slicer4 | Core: Building (CMake, Superbuild) | public | 2012-07-14 15:16 | 2012-10-22 09:09 |
Reporter | pohl | Assigned To | sankhesh | ||
Priority | normal | Severity | minor | Reproducibility | have not tried |
Status | closed | Resolution | fixed | ||
Platform | Linux | OS | Ubuntu 64 bit | OS Version | 12.04 |
Product Version | |||||
Target Version | Slicer 4.3.0 | Fixed in Version | Slicer 4.2.0 | ||
Summary | 0002321: Fix gcc 4.6.x link error related to libvtkPythonCore.so.5.10.0 - undefined reference to `Py*' | ||||
Description | when compiling Slicer from scratch I get the following message: [ 55%] Building CXX object Modules/Loadable/Data/Logic/CMakeFiles/vtkSlicerDataModuleLogicPython.dir/vtkSlicerDataModuleLogicPythonInit.cxx.o | ||||
Tags | No tags attached. | ||||
2012-07-14 18:01
|
blub.log (989,024 bytes) |
uploaded complete log file |
|
After investigating it resumes an test executable fails to link. (qSlicerDataModuleWidgetsCxxTests) Compiling using: make -j4 -k should build all targets possible ignoring error and will allow you to work and fix bugs related to EMSegment. We will investigate further on our side. |
|
it still does not compile without error [ 59%] Built target qSlicerDataModuleWidgetsPythonQt ... |
|
That is expected. Using "-k" allow to push the compilation to the end without stopping because of the error related to the "test executable". You can know run Slicer and build targets specific to EMSegment. This should allow you to work and fix bug related to EMSegment. As mentioned, we are investigating the error. |
|
COMP: Update VTK tag to use a Slicer VTK fork based on v.5.10.0 Please, after updating your Slicer checkout and rebuilding, let me know if the link problem is still present. |
|
yes it is |
|
Just to make sure, could you confirm that you did a build from the top level directory ? |
|
yes I build from the superbuild directory |
|
Issue seems to be specific to newer version of gcc, an email have been sent to the kitware developer internal list to obtain feedback: // ------------------------------------------- I am facing a link error that I can't manage to track down. I would appreciate your input. VTK version: v5.10.0 + 2 custom commit. See https://github.com/Slicer/VTK/commits/slicer-4.1-v5.10.0 The command reported below gives me the following error: <SUPERBUILD>/VTK-build/bin/libvtkPythonCore.so.5.10.0: undefined reference to The error does NOT appear when building on Ubuntu 10.04 LTS / g++ (Ubuntu 4.4.3-4ubuntu5.1) 4.4.3 but appears when building on Ubuntu 12.04 LTS / g++ (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3 Command: Note: to facilitate the reading, I changed '/home/crmullin/Projects/Slicer4-SuperBuild-Debug' into '<SUPERBUILD>' and also changed spaces into newlines. /usr/bin/c++ -o Thanks for your help, |
|
Bill answer: You should find out where this symbol is supposed to be: Go to a system that works, and run nm on all the libraries that slicer links to. Pipe that to nm and find PyType_IsSubtype. Then make sure that library is being linked on the machine where it does not work. I would guess that this symbol is supposed to be part of python itself. Perhaps the python is built with some option off? |
|
Jc reply: // ---------------------------- To answer the question of Bill: Looking at the code used to build vtkPythonCore, I found the following: Underlinking on purpose. The following library will not compilewith LDFLAGS=-Wl,--no-undefined by design:On some UNIX platforms the python library is static and thereforeshould not be linked into the shared library. Instead the symbolsare exported from the python executable so that they can be used byshared libraries that are linked or loaded. On Windows and OSX wewant to link to the python libray to resolve its symbolsimmediately.IF(WIN32 OR APPLE) Then, looking at how the "vtkpython" executable is linked, I found that it is linked against python using the following: TARGET_LINK_LIBRARIES(vtkpython ${VTKPYTHON_LINK_LIBS}) where VTK_PYTHON_LIBRARIES point to the python library and VTKPYTHON_LINK_LIBS is set to the complete list of VTK libraries. See http://vtk.org/gitweb?p=VTK.git;a=blob;f=Wrapping/Python/CMakeLists.txt;h=d59ef4c5b2d40e9c5a8e1bf74c9571a7549584bc;hb=9e66eb8fde3edee8382d2fd8700cfbc61ea019cb#l198 Two message statements added into the Wrapping/Python/CMakeLists.txt print the following: VTKPYTHON_LINK_LIBS:/home/jchris/Projects/Slicer4-Superbuild-Debug/python-build/lib/libpython2.6.so;vtksys;vtkCommon;vtkFiltering;vtkIO;vtkGraphics;vtkImaging;/usr/lib/libutil.so;vtkRendering;vtkVolumeRendering;vtkHybrid;vtkWidgets;vtkParallel;vtkCharts;vtkGeovis;vtkInfovis;vtkViews VTK_PYTHON_LIBRARIES:/home/jchris/Projects/Slicer4-Superbuild-Debug/python-build/lib/libpython2.6.so What is interesting is that to build the main application "SlicerApp-real", I don't have to use LINK_INTERFACE_LIBRARIES f, it's probably related to the fact all the required dependencies end up being added to the link command. I guess I will have to specify the missing dependency so that qSlicerDataModuleWidgetsCxxTests can be linked properly. What do you all think ? Am I missing misunderstanding something ? Blaming the file, David Gobbi added these lines ... will also ask him his feedback. |
|
From David: Hi J-C, Any executable that uses python should include ${VTK_PYTHON_LIBRARIES} For python modules, linking to just vtkPythonCore will often be enough |
|
Topic pushed on https://github.com/jcfr/Slicer/compare/2321-fix-python-link-error-gcc-46 |
|
I can confirm this bug on clean Ubuntu build (git treeish: a1dda866aee9a05e9b53ff841f942ad330153323). JC, can you push the fix to the main Slicer repo? |
|
Thanks. Jc is out for the next few weeks, I'll look into the topic shortly. |
|
The current branch fix doesn't solve the issue on Ubuntu Oneric with gcc 4.6.1. |
|
Is there a way to reproduce the error with the Volumes module ? May be trying to move in that direction will give some hints ? |
|
Newer gcc versions are stricter about both library order and explicit linking. http://stackoverflow.com/questions/7826448/linking-libraries-with-gcc-order-of-arguments google "link order gcc 4.6 undefined reference site:stackoverflow.com" for dozens of similar problems. I tried some manual variations of the library order in the g++ call to build this test, with no success yet. Hopefully this gives a clue where to look. |
|
Also in link 3 above, it suggests a workaround is to install package "binutils-gold", which provides a new and purportedly faster version of ld from google. installing this did resolve the issue for me - and hopefully will speed up builds as well. |
|
Reminder sent to: sankhesh Hi Sankhesh, Could you confirm that installing "binutils-gold" solve the problem for you ? If it does, make sure to update the prerequisies associated the build instruction on the wiki. Thanks |
|
Thank you inorton for the tips in solving this issue. JC, I will check it with binutils-gold. However, I don't think this is a solution. The gold linker is a faster replacement for the GNU linker(default linker). I mean, if the order of libraries and source files is the issue, it is better to fix that. I am working on Slicer-4.2 tutorial issues and will get to this one as soon as I am done with that. |
|
I agree this is not the optimum fix but if by installing gold, it works. I think it's okay for now. I would suggest to discuss the issue with CMake folks. |
|
Can you please disable this test until a correct solution is found? This test does not justify a broken build on newer linux distros. gcc 4.6 has been main-line for over a year now for two of the important platforms (ubuntu 11.10+, fedora 15+) and users reasonably expect Slicer to compile out-of-the-box with default tools from build-essentials. |
|
Okay, finally with some awesome help from Bill Hoffman we could figure out what was the root cause of this problem. Turns out, the shared library libvtkPythonCore.so uses python symbols but is not linked to libpython.so https://github.com/Kitware/VTK/blob/v5.10.0/Wrapping/Python/CMakeLists.txt#L50 . Moreover, the test in question - qSlicerDataModuleWidgetsCxxTest does not reference any python symbols directly. This makes the linker "not link" the executable to libpython. However, since libvtkPythonCore depends on libpython without a direct link between the two, we have to suffer with this bug. :-( In essence, if there is a shared library "A" that depends on a shared library "B" but is not linked directly to it and an executable "C" depends only on shared library "A", linker fails to link to library "B" and cannot resolve symbols in "A". Now, you would expect the linker to resolve the dependency up the toolchain and link the two shared libraries together. This would have made it much easier. But, Ubuntu package maintainers decided to add a linker flag "--as-needed"(http://linux.die.net/man/1/ld) to the default gcc toolchain starting Ubuntu 12.04. To fix this problem, we have two options,
As an aside, I will talk to VTK folks to check if there is a reason behind not linking libvtkPythonCore with libPython. Any suggestions/ideas, please feel free to pass them on. |
|
Why does this only happen for qSlicerDataModuleWidgetsCxxTest? We have many tests and other code that does not reference python symbols, why is this different? Playing with linker flags to resolve this seems like a bad idea. This is at least a meta-bug, possibly twice removed. |
|
This happens only for qSlicerDataModuleWidgetsCxxTest because that might be the oddball referencing symbols from libvtkPythonCore.so but not from libpython.so. That is why the linker is not bringing in the shared library libpython.so To verify, this I added referenced a python symbol in the test and it all compiled fine. I didn't quite understand what you mean by a meta-bug? |
|
Pushed the topic with the said changes. |
|
Fixed in r21158 (http://viewvc.slicer.org/viewvc.cgi/Slicer4?view=revision&revision=21158) |
|
On my mac build I get this error now when running cmake: CMake Warning at CMake/SlicerLinkerAsNeededFlagCheck.cmake:53 (message): |
|
see note from Steve |
|
Its fixed in r21167 (http://viewvc.slicer.org/viewvc.cgi/Slicer4?view=revision&revision=21167). The check should not be done on Mac as it follows a different linking algorithm. Secondly, there is no --as-needed flag for the linker on Mac. Kindly test it and close this issue. |
|
additional comments by sankhesh clarified issue |
|
Date Modified | Username | Field | Change |
---|---|---|---|
2012-07-14 15:16 | pohl | New Issue | |
2012-07-14 15:16 | pohl | Status | new => assigned |
2012-07-14 15:16 | pohl | Assigned To | => jcfr |
2012-07-14 18:01 | pohl | File Added: blub.log | |
2012-07-14 18:01 | pohl | Note Added: 0005141 | |
2012-07-16 10:34 | jcfr | Note Added: 0005144 | |
2012-07-16 10:37 | pohl | Note Added: 0005145 | |
2012-07-16 11:08 | jcfr | Note Added: 0005149 | |
2012-07-16 11:09 | jcfr | Note Edited: 0005149 | |
2012-07-16 12:43 | jcfr | Description Updated | |
2012-07-16 12:43 | jcfr | Note Edited: 0005145 | |
2012-07-16 13:03 | jcfr | Note Added: 0005151 | |
2012-07-16 13:03 | jcfr | Status | assigned => feedback |
2012-07-16 13:33 | pohl | Note Added: 0005154 | |
2012-07-16 13:45 | jcfr | Note Added: 0005155 | |
2012-07-16 13:46 | pohl | Note Added: 0005156 | |
2012-07-16 13:57 | jcfr | Note Added: 0005157 | |
2012-07-16 13:57 | jcfr | Note Edited: 0005157 | |
2012-07-16 16:08 | jcfr | Note Added: 0005158 | |
2012-07-16 16:09 | jcfr | Note Added: 0005159 | |
2012-07-17 06:04 | pieper | Relationship added | related to 0002323 |
2012-07-18 16:38 | jcfr | Note Added: 0005192 | |
2012-07-18 16:38 | jcfr | Note Added: 0005193 | |
2012-07-27 10:53 | jcfr | Summary | Cannot compile slicer trunk => Fix gcc 4.6.x link error related to libvtkPythonCore.so.5.10.0 - undefined reference to `Py*' |
2012-07-27 10:53 | jcfr | Assigned To | jcfr => crmullin |
2012-07-27 10:53 | jcfr | Target Version | => Slicer 4.2.0 - October 1st 2012 |
2012-07-27 10:55 | jcfr | Status | feedback => assigned |
2012-08-02 11:53 | dmwelch | Note Added: 0005493 | |
2012-08-02 11:56 | crmullin | Note Added: 0005494 | |
2012-08-06 08:07 | dmwelch | Note Added: 0005506 | |
2012-08-20 12:35 | jcfr | Target Version | Slicer 4.2.0 - Feature freeze Sept 1st 2012 => Slicer 4.2.5 |
2012-08-21 09:40 | jcfr | Target Version | Slicer 4.2.5 => Slicer 4.3.0 |
2012-08-29 12:32 | jcfr | Assigned To | crmullin => jcfr |
2012-08-29 12:34 | jcfr | Assigned To | jcfr => sankhesh |
2012-09-24 07:18 | jcfr | Note Added: 0006182 | |
2012-09-29 20:02 | inorton | Note Added: 0006284 | |
2012-09-29 20:05 | inorton | Note Added: 0006285 | |
2012-10-01 08:02 | jcfr | Note Added: 0006292 | |
2012-10-01 08:29 | sankhesh | Note Added: 0006293 | |
2012-10-01 09:28 | jcfr | Note Added: 0006296 | |
2012-10-02 11:18 | inorton | Note Added: 0006336 | |
2012-10-05 13:17 | sankhesh | Note Added: 0006403 | |
2012-10-05 13:18 | sankhesh | Note Edited: 0006403 | |
2012-10-05 14:08 | inorton | Note Added: 0006404 | |
2012-10-06 12:03 | sankhesh | Note Added: 0006425 | |
2012-10-10 14:04 | sankhesh | Note Added: 0006493 | |
2012-10-11 08:26 | sankhesh | Note Added: 0006498 | |
2012-10-11 08:26 | sankhesh | Status | assigned => resolved |
2012-10-11 08:26 | sankhesh | Fixed in Version | => Slicer 4.2.0 - coming release |
2012-10-11 08:26 | sankhesh | Resolution | open => fixed |
2012-10-12 10:14 | pieper | Note Added: 0006517 | |
2012-10-16 11:10 | pohl | Note Added: 0006573 | |
2012-10-16 11:10 | pohl | Status | resolved => feedback |
2012-10-16 11:10 | pohl | Resolution | fixed => reopened |
2012-10-16 11:15 | sankhesh | Note Added: 0006574 | |
2012-10-16 11:16 | sankhesh | Note Edited: 0006574 | |
2012-10-16 11:25 | sankhesh | Note Edited: 0006574 | |
2012-10-22 09:09 | pohl | Note Added: 0006674 | |
2012-10-22 09:09 | pohl | Status | feedback => closed |
2012-10-22 09:09 | pohl | Resolution | reopened => fixed |