linking errors for stitch project (recompile with -fPIC)

152 views
Skip to first unread message

Michal Novotný

unread,
Mar 20, 2016, 3:30:31 PM3/20/16
to hugin and other free panoramic software
Hello, I am getting the following error when compiling Hugin 2016 (the just released version) on Fedora 23:

Scanning dependencies of target hugin_stitch_project
[ 52%] Building CXX object src/hugin1/stitch_project/CMakeFiles/hugin_stitch_project.dir/hugin_stitch_project.cpp.o
[ 52%] Linking CXX executable hugin_stitch_project
/usr/bin/ld: CMakeFiles/hugin_stitch_project.dir/hugin_stitch_project.cpp.o: relocation R_X86_64_32 against `_ZN14RunStitchFrame13sm_eventTableE' can not be used when making a shared object; recompile with -fPIC
CMakeFiles/hugin_stitch_project.dir/hugin_stitch_project.cpp.o: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
src/hugin1/stitch_project/CMakeFiles/hugin_stitch_project.dir/build.make:142: recipe for target 'src/hugin1/stitch_project/hugin_stitch_project' failed
make[2]: *** [src/hugin1/stitch_project/hugin_stitch_project] Error 1
CMakeFiles/Makefile2:1628: recipe for target 'src/hugin1/stitch_project/CMakeFiles/hugin_stitch_project.dir/all' failed
make[1]: *** [src/hugin1/stitch_project/CMakeFiles/hugin_stitch_project.dir/all] Error 2
Makefile:149: recipe for target 'all' failed
make: *** [all] Error 2

I tried adding -fPIC flag manually info mybuild/src/hugin1/stitch_project /CMakeFiles/hugin_stitch_project.dir/flags.make, which helped for the stitch project but it failed immediatelly after for:

[ 53%] Linking CXX executable icpfind

And then for:

[ 54%] Linking CXX executable hugin_executor

Then another three about missing -fPIC errors for :

[ 74%] Linking CXX executable hugin

[ 77%] Linking CXX executable PTBatcherGUI

[ 78%] Linking CXX executable calibrate_lens_gui

Finally after modifying flags.make for all these projects, the build succeeded. I feel a bit silly for manually modifying all these flags.make files, for sure there is a better way (i guess by modifying CMakeLists.txt). But why are these projects missing -fPIC when it is, in fact, needed?

Thank you
clime

P.S.: I'll provide more info about installed libs if needed.

T. Modes

unread,
Mar 21, 2016, 12:55:18 PM3/21/16
to hugin and other free panoramic software


Am Sonntag, 20. März 2016 20:30:31 UTC+1 schrieb Michal Novotný:
Hello, I am getting the following error when compiling Hugin 2016 (the just released version) on Fedora 23:

RC2 has been built successful on Fedora (see https://groups.google.com/d/msg/hugin-ptx/CptOyr5xCVA/9haTBsDmBwAJ ) (The released version is identical to rc2.)

So the error is specific to your system. So you have to search for changes to your system.
* Which compiler exactly?
* Which wxWidgets version? How has wxWidgets built (with which options?)
* How have you configured Hugin (full cmake command)?

Michal Novotný

unread,
Mar 21, 2016, 6:23:53 PM3/21/16
to hugin and other free panoramic software
1) clime@den ~ $ g++ --version
g++ (GCC) 5.3.1 20151207 (Red Hat 5.3.1-2)

2) sudo dnf info wxGTK-devel
Name        : wxGTK-devel
Arch        : x86_64
Epoch       : 0
Version     : 2.8.12
Release     : 19.fc23

From wxGTK.spec (package: wxGTK-2.8.12-19.fc23.src.rpm):

export GDK_USE_XFT=1

# this code dereferences type-punned pointers like there's no tomorrow.
CFLAGS="$RPM_OPT_FLAGS -fno-strict-aliasing"
CXXFLAGS="$RPM_OPT_FLAGS -fno-strict-aliasing"

# --disable-optimise prevents our $RPM_OPT_FLAGS being overridden
# (see OPTIMISE in configure).
%configure \
  --with-opengl \
  --with-sdl \
  --with-gnomeprint \
  --enable-shared \
  --enable-soname \
  --disable-optimise \
  --enable-debug_info \
  --enable-intl \
  --enable-unicode \
  --enable-no_deps \
  --disable-rpath \
  --enable-geometry \
  --enable-graphics_ctx \
  --enable-sound \
  --enable-mediactrl \
  --enable-display \
  --enable-timer \
  --enable-compat24 \
  --disable-catch_segvs

make %{?_smp_mflags}
make %{?_smp_mflags} -C contrib/src/stc
make %{?_smp_mflags} -C contrib/src/ogl
make %{?_smp_mflags} -C contrib/src/gizmos
make %{?_smp_mflags} -C contrib/src/svg

3) I just did mkdir mybuild; cd mybuild; cmake ..


I'll try to compile on another system with Fedora23. Maybe that will tell us more.

Thank you

Michal Novotný

unread,
Mar 21, 2016, 6:42:53 PM3/21/16
to hugin and other free panoramic software
I also discovered this when running assistant (not sure if relevant, probly not):

Warning: Mismatch between the program and library build versions detected.
The library used 2.8 (no debug,Unicode,compiler with C++ ABI 1008,wx containers,compatible with 2.4,compatible with 2.6),
and your program used 2.8 (no debug,Unicode,compiler with C++ ABI 1009,wx containers,compatible with 2.4,compatible with 2.6).

clime

T. Modes

unread,
Mar 22, 2016, 4:00:27 PM3/22/16
to hugin and other free panoramic software


Am Montag, 21. März 2016 23:42:53 UTC+1 schrieb Michal Novotný:
I also discovered this when running assistant (not sure if relevant, probly not):

Warning: Mismatch between the program and library build versions detected.
The library used 2.8 (no debug,Unicode,compiler with C++ ABI 1008,wx containers,compatible with 2.4,compatible with 2.6),
and your program used 2.8 (no debug,Unicode,compiler with C++ ABI 1009,wx containers,compatible with 2.4,compatible with 2.6).

This needs to fixed on Fedoras side. see https://bugzilla.redhat.com/show_bug.cgi?id=1318841

Otherwise rebuild wxWidgets 2.8.12 for your own could help.
Or upgrade to wxWidgets 3.0 and try to compile with it.

PS: wxWidgets 2.8.12 was released 5!! years ago. wxWidgets 3.0 was released 2.5 years ago.

clime

unread,
Mar 23, 2016, 3:52:28 AM3/23/16
to hugi...@googlegroups.com
I have run the compilation on another fresh F23 with the same result -FPIC is missing for some crucial projects. I followed this guide: http://wiki.panotools.org/Hugin_Compiling_Fedora
(3 more packages are needed for compilation now in 2016: vigra-devel, libcms2-devel, sqlite-devel. I wanted to edit it on wiki but I didn't have permissions for that.)

As very quick and dirty hack I modified src/hugin1/CMakeLists.txt by adding: SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")  (sry for that)

I'll try to find out more as to why the flag is not generated for some projects. Rebuilding wxWidgets didn't fix the compilation issue but I need to have a look if the message in the assistant window has at least disappeared.

clime

--
A list of frequently asked questions is available at: http://wiki.panotools.org/Hugin_FAQ
---
You received this message because you are subscribed to a topic in the Google Groups "hugin and other free panoramic software" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/hugin-ptx/cbPR2c-6Ocw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to hugin-ptx+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/hugin-ptx/b3842854-d258-4c80-b70c-5ee65a89237c%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

clime

unread,
Mar 23, 2016, 4:19:59 AM3/23/16
to hugi...@googlegroups.com
Actually rebuilding wxWidgets (2.8.12) caused the compilation to crash on lots of "undefined reference to " errors (output attached, probly I did something wrong when building/installing wxWidgets).

I also added output of cmake ..

I'll also have look at the successful build in COPR. Hopefully, I will figure this out. Sorry for complications.
cmake-out.txt
err-out.txt

T. Modes

unread,
Mar 23, 2016, 1:58:01 PM3/23/16
to hugin and other free panoramic software


Am Mittwoch, 23. März 2016 09:19:59 UTC+1 schrieb Michal Novotný:
Actually rebuilding wxWidgets (2.8.12) caused the compilation to crash on lots of "undefined reference to " errors (output attached, probly I did something wrong when building/installing wxWidgets).

Maybe there is a conflict with the installed wxWidgets and your own compilation.

Maybe some advanced Fedora or Unix user can comment on this.

clime

unread,
Mar 23, 2016, 6:54:29 PM3/23/16
to hugi...@googlegroups.com
The reason why the build in COPR build succeeded was because srpms are build with special CXXFLAGS on Fedora as defined in /usr/lib/rpm/redhat/macros, one of them being: -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1
The content of the file is following: + %{!r:%{!fpie:%{!fPIE:%{!fpic:%{!fPIC:%{!fno-pic:-fPIE}}}}}}. So where there is not fPIC, fPIE flag is added. Together, this produces a valid result (no mixing of position-dependend and independent code).

So if you want to compile the 2016 version on Fedora23 successfully, you need to do: export CXXFLAGS='-specs=/usr/lib/rpm/redhat/redhat-hardened-cc1' before make (or you can also just use the precompiled COPR version from https://copr.fedorainfracloud.org/coprs/bpostle/panorama/). Btw. the 2015 version does have the same issue on F23 but I remember compiling it successfully on my old F21 system (before I upgraded to F23).

clime

--
A list of frequently asked questions is available at: http://wiki.panotools.org/Hugin_FAQ
---
You received this message because you are subscribed to a topic in the Google Groups "hugin and other free panoramic software" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/hugin-ptx/cbPR2c-6Ocw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to hugin-ptx+...@googlegroups.com.

Bruno Postle

unread,
Mar 24, 2016, 6:02:18 AM3/24/16
to hugi...@googlegroups.com


On 23 March 2016 23:54:24 CET, clime wrote:
> So where there is not fPIC, fPIE flag is
> added. Together, this produces a valid
> result (no mixing of position-dependend
> and independent code).

If Hugin really needs -fPIC if it is linking to PIC libraries, would it be possible for cmake to detect this situation and adjust the flags appropriately?

[I have been away and just catching up, new Hugin, enblend and vigra releases all in one week!]

--
Bruno

T. Modes

unread,
Mar 25, 2016, 4:19:24 AM3/25/16
to hugin and other free panoramic software


Am Donnerstag, 24. März 2016 11:02:18 UTC+1 schrieb Bruno Postle:

If Hugin really needs -fPIC if it is linking to PIC libraries, would it be possible for cmake to detect this situation and adjust the flags appropriately?

Hugin compiles here fine with wxWidgets 3.0 on Fedora 23 (in a virtual machine) without additional parameters.
CMake picks already the compile flags for wxWidgets from wx-config/wx-config-3.0 (unix style in FindwxWidgets.cmake).
If wxWidgets really needs -fPIC, wx-config should report this and then this is used from CMake.

Reply all
Reply to author
Forward
0 new messages