Subject: | Installation and compilation problems for QtCore4, Ubuntu 16.10, Perl version 5.24.1 |
I tried to Install QtCore4 on Ubuntu 16.10, perl version 5.24.1:
sudo apt-get install cmake
sudo apt-get install qt4-designer libqtgui4-perl
cpan -g QtCore4
bunzip2 Qt4-0.99.0.tar.bz2
tar xvf Qt4-0.99.0.tar
cd Qt4-0.99.0
perl Makefile.PL
make VERBOSE=1
Now make reports several problems. First error message is about implicitly
deleted virtual destructors, see:
http://stackoverflow.com/q/43191675/2173773
It seems like these errors come from generated .cpp files
(smokegen). I think I managed to fix these errors in the generated files by
manually adding virtual destructors to
smokeqt/qtdbus/x_1.cpp:1595
smokeqt/qtgui/x_3.cpp:4024
smokeqt/qtgui/x_13.cpp:3572
smokeqt/qthelp/x_1.cpp:873
but obviously it would be much better to fix these error at the core
(i.e. not fixing generated files, but the generator (smokegen ??)) or
add some compiler option to ignore the missing destructors??
After fixing the four generated files, the next compile error (from
cmake) occured in qtcore/src/util.cpp:2234:
/home/hakon/Qt4-0.99.0/qtcore/src/util.cpp: In function ‘void
XS_AUTOLOAD(CV*)’: /home/hakon/Qt4-0.99.0/qtcore/src/util.cpp:2234:59:
error: cannot convert ‘bool’ to ‘void*’ in initialization
static smokeperl_object nothis = { 0, 0, 0, false };
This was "fixed" by changing "false" to 0 in the last item of structure
initializer.
After fixing the problem in qtcore/src/util.cpp, the next error
reported from cmake occured when trying to link QtCore4.so:
/usr/bin/c++ -fPIC -fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong \
-I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O3 -DNDEBUG \
-shared -Wl,-soname,QtCore4.so -o ../../blib/arch/auto/QtCore4/QtCore4.so \
CMakeFiles/perlqtcore4.dir/binding.cpp.o \
CMakeFiles/perlqtcore4.dir/handlers.cpp.o \
CMakeFiles/perlqtcore4.dir/marshall_types.cpp.o \
CMakeFiles/perlqtcore4.dir/util.cpp.o \
CMakeFiles/perlqtcore4.dir/QtCore4.c.o \
-lQtCore -lQtGui -lQtNetwork \
/home/hakon/perlbrew/perls/perl-5.24.1/lib/5.24.1/x86_64-linux/CORE/libperl.a \
../../smokeqt/qtgui/libsmokeqtgui.so.3.0.0 \
../../smokeqt/qtnetwork/libsmokeqtnetwork.so.3.0.0 \
-lpthread -lnsl -ldl -lm -lcrypt -lutil -lc -lQtGui -lQtNetwork \
../../smokeqt/qtcore/libsmokeqtcore.so.3.0.0 -lQtCore \
../../smokegen/bin/libsmokebase.so.3.0.0 \
-Wl,-rpath,/home/hakon/Qt4-0.99.0/smokeqt/qtgui:/home/hakon/Qt4-0.99.0/smokeqt/qtnetwork:/home/hakon/Qt4-0.99.0/smokeqt/qtcore:/home/hakon/Qt4-0.99.0/smokegen/bin:
/usr/bin/ld: /home/hakon/perlbrew/perls/perl-5.24.1/lib/5.24.1/x86_64-linux/CORE/libperl.a(toke.o):
relocation R_X86_64_PC32 against symbol `PL_curcop' can not be used when making
a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
Apparently toke.o in libperl.a was compiled with -fPIC in earlier Perl
releases, but for my perl ( version 5.24.1 ) toke.o was not compiled
with -fPIC. (I installed my perl using perlbrew). This error was "fixed"
by installing a new perl with ccflags=-fPIC
perlbrew install perl-5.24.1 --as perl-5.24.1-PIC -Accflags=-fPIC
See also:
http://stackoverflow.com/q/43203477/2173773
But linker error should probably be more correctly fixed by manually
compiling "toke.c" with -fPIC (i.e. we should check if the files in libperl.a has been
compiled with -fPIC (which they are not for newer versions of Perl)
and if not, recompile them with -fPIC)??
Now the make (cmake) finally completed successfully, and I could run
make install
and then I created a simple test program (p.pl):
use strict;
use warnings;
use QtCore4;
use QtGui4;
my $app = Qt::Application(\@ARGV);
my $button = Qt::PushButton( 'Hello, World!', undef);
$button->show();
exit $app->exec();
however several errors still occured when trying to run this program. First:
Can't use 'defined(@array)' (Maybe you should just omit the defined()?) at /home/hakon/perlbrew/perls/perl-5.24.1-PIC/lib/site_perl/5.24.1/x86_64-linux/QtCore4.pm line 1420.
Compilation failed in require at ./p.pl line 3.
See also:
http://stackoverflow.com/q/43190485/2173773
The defined(@array) has been deprecated for a long time, and for
recent perls ( > 5.22 ) the deprecation warning has become fatal. See also
http://stackoverflow.com/q/41980796/2173773
this error was fixed by changing the following lines (starting at line 1420 in QtCore.pm):
@{$classinfos} = () if !defined @{$classinfos};
@{$signals} = () if !defined @{$signals};
@{$slots} = () if !defined @{$slots};
to
$classinfos ||= [];
$signals ||= [];
$slots ||= [];
After fixing the defined(@array) error, the next error occured in
QtGui4.pm, line 25:
"SvREFCNT_inc" is not exported by the Devel::Peek module
Can't continue after import errors at /home/hakon/perlbrew/perls/perl-5.24.1-PIC/lib/site_perl/5.24.1/x86_64-linux/QtGui4.pm line 25.
BEGIN failed--compilation aborted at /home/hakon/perlbrew/perls/perl-5.24.1-PIC/lib/site_perl/5.24.1/x86_64-linux/QtGui4.pm line 25.
Compilation failed in require at ./p.pl line 4.
BEGIN failed--compilation aborted at ./p.pl line 4.
This appears to be a bug in Devel::Peek. It used to export SvREFCNT_inc, and the docs still claims it does, but it doesn't anymore.
You can work around this by replacing:
use Devel::Peek qw( SvREFCNT_inc );
with
use Devel::Peek qw( );
BEGIN { *SvREFCNT_inc = \&Devel::Peek::SvREFCNT_inc; }
at QtGui4.pm line 25.
After fixing the export error from Devel::Peek, the test program runs
and shows the "Hello world" window :)
However it still issues some warnings:
Subroutine Qt::GlobalSpace::_UTOLOAD redefined at /home/hakon/perlbrew/perls/perl-5.24.1-PIC/lib/site_perl/5.24.1/x86_64-linux/QtCore4.pm line 1305.
Subroutine Qt::GlobalSpace::_UTOLOAD redefined at /home/hakon/perlbrew/perls/perl-5.24.1-PIC/lib/site_perl/5.24.1/x86_64-linux/QtCore4.pm line 1305.
Subroutine Qt::Widget::_UTOLOAD redefined at /home/hakon/perlbrew/perls/perl-5.24.1-PIC/lib/site_perl/5.24.1/x86_64-linux/QtCore4.pm line 1305.
Subroutine Qt::Widget::_UTOLOAD redefined at /home/hakon/perlbrew/perls/perl-5.24.1-PIC/lib/site_perl/5.24.1/x86_64-linux/QtCore4.pm line 1305.
I have not looked into these warnings yet..
Hope this bug report can help bring QtCore4 up-to-date and a useful Perl module in the future.
- Håkon Hægland