Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't install under Windows 7: std::bad_alloc #25

Closed
tsieger opened this issue Jul 8, 2014 · 22 comments
Closed

Can't install under Windows 7: std::bad_alloc #25

tsieger opened this issue Jul 8, 2014 · 22 comments

Comments

@tsieger
Copy link

tsieger commented Jul 8, 2014

Following https://github.com/ggobi/cranvas/wiki/Installation-under-windows-32-bit,
qtbase build terminates with:

[ 65%] Generating smokedata.cpp, x_1.cpp, x_2.cpp, x_3.cpp, x_4.cpp, x_5.cpp, x_
6.cpp, x_7.cpp, x_8.cpp, x_9.cpp, x_10.cpp, x_11.cpp, x_12.cpp, x_13.cpp, x_14.c
pp, x_15.cpp, x_16.cpp, x_17.cpp, x_18.cpp, x_19.cpp, x_20.cpp
terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc

version info:

R version 3.1.0 (2014-04-10)
Platform: i386-w64-mingw32/i386 (32-bit)
cmake 2.8.11
Qt opensource 4.8.6
RTools 3.1 (gcc 4.6.3)

build log:

C:\src>R CMD INSTALL --build qtbase
* installing to library 'C:/Program Files/R/R-3.1.0/library'
* installing *source* package 'qtbase' ...
** libs
  running 'src/Makefile.win' ...
cygwin warning:
  MS-DOS style path detected: C:/PROGRA~1/R/R-31~1.0/bin/R
  Preferred POSIX equivalent is: /cygdrive/c/PROGRA~1/R/R-31~1.0/bin/R
  CYGWIN environment variable option "nodosfilewarning" turns off this warning.
  Consult the user's guide for more details about POSIX paths:
    http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
mkdir -p ../kdebindings-build;
cd ../kdebindings-build; \
"/cygdrive/C/Program Files/CMake 2.8/bin/cmake.exe" ../kdebindings -G "Unix Make
files" -DQT_QMAKE_EXECUTABLE="C:\Qt\4.8.6\bin\qmake.exe" -DCMAKE_RC_COMPILER="C:
/Rtools/gcc-4.6.3/bin/windres.exe" -DR_LIBRARIES="-LC:/PROGRA~1/R/R-31~1.0/bin//
i386 -lR" -DR_CXX="g++" -DCMAKE_CXX_FLAGS="-m32 " -DCMAKE_SHARED_LINKER_FLAGS="-
m32   -shared" \
      -DCMAKE_INSTALL_PREFIX=../inst/local \
      -DCMAKE_EXE_LINKER_FLAGS="-m32  " \
      -DCMAKE_MODULE_LINKER_FLAGS="-m32  "; \
LD_LIBRARY_PATH=../../generator/bin make install
-- The C compiler identification is GNU 4.6.3
-- The CXX compiler identification is GNU 4.6.3
-- Check for working C compiler: C:/Rtools/gcc-4.6.3/bin/gcc.exe
-- Check for working C compiler: C:/Rtools/gcc-4.6.3/bin/gcc.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working CXX compiler: C:/Rtools/gcc-4.6.3/bin/g++.exe
-- Check for working CXX compiler: C:/Rtools/gcc-4.6.3/bin/g++.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - failed
-- Looking for Q_WS_X11
-- Looking for Q_WS_X11 - not found
-- Looking for Q_WS_WIN
-- Looking for Q_WS_WIN - found
-- Looking for Q_WS_QWS
-- Looking for Q_WS_QWS - not found
-- Looking for Q_WS_MAC
-- Looking for Q_WS_MAC - not found
-- Found Qt4: C:/Qt/4.8.6/bin/qmake.exe (found suitable version "4.8.6", minimum
 required is "4.0.0")
-- Found Qt4: C:/Qt/4.8.6/bin/qmake.exe (found suitable version "4.8.6", minimum
 required is "4.0.0")
-- Found OpenGL: opengl32
-- Found Perl: C:/Strawberry/perl/bin/perl.exe (found version "5.12.3")
-- Checking how Qt was built...
-- Threshold is set to 10
-- QT_NO_DEBUG *Undefined*
-- QT_NO_ACCESSIBILITY [Defined]
-- QT_NO_BUTTONGROUP *Undefined*
-- QT_NO_COLORDIALOG *Undefined*
-- QT_NO_DATETIMEEDIT *Undefined*
-- QT_NO_DIALOG *Undefined*
-- QT_NO_ERRORMESSAGE *Undefined*
-- QT_NO_FILEDIALOG *Undefined*
-- QT_NO_FONTDIALOG *Undefined*
-- QT_NO_GROUPBOX *Undefined*
-- QT_NO_LCDNUMBER *Undefined*
-- QT_NO_LINEEDIT *Undefined*
-- QT_NO_LISTVIEW *Undefined*
-- QT_NO_MAINWINDOW *Undefined*
-- QT_NO_MENUBAR *Undefined*
-- QT_NO_MESSAGEBOX *Undefined*
-- QT_NO_PRINTDIALOG *Undefined*
-- QT_NO_PROGRESSBAR *Undefined*
-- QT_NO_PROGRESSDIALOG *Undefined*
-- QT_NO_PUSHBUTTON *Undefined*
-- QT_NO_RADIOBUTTON *Undefined*
-- QT_NO_SCROLLBAR *Undefined*
-- QT_NO_SLIDER *Undefined*
-- QT_NO_STYLE_PLASTIQUE *Undefined*
-- QT_NO_STYLE_WINDOWSXP *Undefined*
-- QT_NO_STYLE_WINDOWS *Undefined*
-- QT_NO_STYLE_MAC [Defined]
-- QT_NO_STYLE_CLEANLOOKS *Undefined*
-- QT_NO_TABLEVIEW *Undefined*
-- QT_NO_TEXTBROWSER *Undefined*
-- QT_NO_TEXTEDIT *Undefined*
-- QT_NO_TOOLBUTTON *Undefined*
-- QT_DLL [Defined]
-- QT_NO_DEBUG [Defined]
-- QT_OPENGL_LIB [Defined]
-- QT_DECLARATIVE_LIB [Defined]
-- QT_SCRIPT_LIB [Defined]
-- QT_SVG_LIB [Defined]
-- QT_HELP_LIB [Defined]
-- QT_WEBKIT_LIB [Defined]
-- QT_MULTIMEDIA_LIB [Defined]
-- QT_XMLPATTERNS_LIB [Defined]
-- QT_GUI_LIB [Defined]
-- QT_TEST_LIB [Defined]
-- QT_DBUS_LIB [Defined]
-- QT_XML_LIB [Defined]
-- QT_SQL_LIB [Defined]
-- QT_NETWORK_LIB [Defined]
-- QT_CORE_LIB [Defined]
-- Build Smoke... yes - Qt
-- Configuring done
-- Generating done
CMake Warning:
  Manually-specified variables were not used by the project:

    R_LIBRARIES


-- Build files have been written to: C:/src/qtbase/kdebindings-build
Scanning dependencies of target cppparser
[  1%] Building CXX object generator/parser/CMakeFiles/cppparser.dir/ast.cpp.obj

[  3%] Building CXX object generator/parser/CMakeFiles/cppparser.dir/default_vis
itor.cpp.obj
[  4%] Building CXX object generator/parser/CMakeFiles/cppparser.dir/memorypool.
cpp.obj
[  6%] Building CXX object generator/parser/CMakeFiles/cppparser.dir/visitor.cpp
.obj
[  8%] Building CXX object generator/parser/CMakeFiles/cppparser.dir/control.cpp
.obj
[  9%] Building CXX object generator/parser/CMakeFiles/cppparser.dir/lexer.cpp.o
bj
[ 11%] Building CXX object generator/parser/CMakeFiles/cppparser.dir/parser.cpp.
obj
[ 13%] Building CXX object generator/parser/CMakeFiles/cppparser.dir/listnode.cp
p.obj
[ 14%] Building CXX object generator/parser/CMakeFiles/cppparser.dir/tokens.cpp.
obj
[ 16%] Building CXX object generator/parser/CMakeFiles/cppparser.dir/dumptree.cp
p.obj
[ 18%] Building CXX object generator/parser/CMakeFiles/cppparser.dir/parsesessio
n.cpp.obj
C:/src/qtbase/kdebindings/generator/parser/parsesession.cpp: In destructor 'Pars
eSession::~ParseSession()':
C:/src/qtbase/kdebindings/generator/parser/parsesession.cpp:42:10: warning: poss
ible problem detected in invocation of delete operator: [enabled by default]
C:/src/qtbase/kdebindings/generator/parser/parsesession.cpp:42:10: warning: inva
lid use of incomplete type 'struct rpp::MacroBlock' [enabled by default]
C:/src/qtbase/kdebindings/generator/parser/parsesession.h:43:23: warning: forwar
d declaration of 'struct rpp::MacroBlock' [enabled by default]
C:/src/qtbase/kdebindings/generator/parser/parsesession.cpp:42:10: note: neither
 the destructor nor the class-specific operator delete will be called, even if t
hey are declared when the class is defined
[ 19%] Building CXX object generator/parser/CMakeFiles/cppparser.dir/commentpars
er.cpp.obj
[ 21%] Building CXX object generator/parser/CMakeFiles/cppparser.dir/commentform
atter.cpp.obj
[ 22%] Building CXX object generator/parser/CMakeFiles/cppparser.dir/codegenerat
or.cpp.obj
[ 24%] Building CXX object generator/parser/CMakeFiles/cppparser.dir/indexedstri
ng.cpp.obj
[ 26%] Building CXX object generator/parser/CMakeFiles/cppparser.dir/stringhelpe
rs.cpp.obj
[ 27%] Building CXX object generator/parser/CMakeFiles/cppparser.dir/rpp/pp-stre
am.cpp.obj
[ 29%] Building CXX object generator/parser/CMakeFiles/cppparser.dir/rpp/pp-macr
o-expander.cpp.obj
[ 31%] Building CXX object generator/parser/CMakeFiles/cppparser.dir/rpp/pp-scan
ner.cpp.obj
[ 32%] Building CXX object generator/parser/CMakeFiles/cppparser.dir/rpp/pp-macr
o.cpp.obj
[ 34%] Building CXX object generator/parser/CMakeFiles/cppparser.dir/rpp/pp-engi
ne.cpp.obj
[ 36%] Building CXX object generator/parser/CMakeFiles/cppparser.dir/rpp/pp-inte
rnal.cpp.obj
[ 37%] Building CXX object generator/parser/CMakeFiles/cppparser.dir/rpp/pp-envi
ronment.cpp.obj
[ 39%] Building CXX object generator/parser/CMakeFiles/cppparser.dir/rpp/pp-loca
tion.cpp.obj
[ 40%] Building CXX object generator/parser/CMakeFiles/cppparser.dir/rpp/preproc
essor.cpp.obj
[ 42%] Building CXX object generator/parser/CMakeFiles/cppparser.dir/rpp/chartoo
ls.cpp.obj
Linking CXX shared library ../bin/libcppparser.dll
Creating library file: ../bin/libcppparser.dll.a
[ 42%] Built target cppparser
Scanning dependencies of target smokegen
[ 44%] Building CXX object generator/CMakeFiles/smokegen.dir/main.cpp.obj
In file included from C:/src/qtbase/kdebindings/generator/parser/parsesession.h:
30:0,
                 from C:/src/qtbase/kdebindings/generator/main.cpp:31:
C:/src/qtbase/kdebindings/generator/parser/indexedstring.h:142:30: warning: inli
ne function 'uint qHash(const IndexedString&)' declared as  dllimport: attribute
 ignored [-Wattributes]
[ 45%] Building CXX object generator/CMakeFiles/smokegen.dir/generatorenvironmen
t.cpp.obj
In file included from C:/src/qtbase/kdebindings/generator/parser/rpp/pp-environm
ent.h:31:0,
                 from C:/src/qtbase/kdebindings/generator/generatorenvironment.h
:22,
                 from C:/src/qtbase/kdebindings/generator/generatorenvironment.c
pp:19:
C:/src/qtbase/kdebindings/generator/parser/rpp/../indexedstring.h:142:30: warnin
g: inline function 'uint qHash(const IndexedString&)' declared as  dllimport: at
tribute ignored [-Wattributes]
[ 47%] Building CXX object generator/CMakeFiles/smokegen.dir/generatorvisitor.cp
p.obj
In file included from C:/src/qtbase/kdebindings/generator/parser/parsesession.h:
30:0,
                 from C:/src/qtbase/kdebindings/generator/generatorvisitor.h:26,

                 from C:/src/qtbase/kdebindings/generator/generatorvisitor.cpp:2
4:
C:/src/qtbase/kdebindings/generator/parser/indexedstring.h:142:30: warning: inli
ne function 'uint qHash(const IndexedString&)' declared as  dllimport: attribute
 ignored [-Wattributes]
[ 49%] Building CXX object generator/CMakeFiles/smokegen.dir/generatorpreprocess
or.cpp.obj
In file included from C:/src/qtbase/kdebindings/generator/parser/rpp/pp-macro.h:
28:0,
                 from C:/src/qtbase/kdebindings/generator/parser/rpp/pp-engine.h
:33,
                 from C:/src/qtbase/kdebindings/generator/generatorpreprocessor.
h:30,
                 from C:/src/qtbase/kdebindings/generator/generatorpreprocessor.
cpp:19:
C:/src/qtbase/kdebindings/generator/parser/rpp/../indexedstring.h:142:30: warnin
g: inline function 'uint qHash(const IndexedString&)' declared as  dllimport: at
tribute ignored [-Wattributes]
[ 50%] Building CXX object generator/CMakeFiles/smokegen.dir/options.cpp.obj
[ 52%] Building CXX object generator/CMakeFiles/smokegen.dir/type_compiler.cpp.o
bj
In file included from C:/src/qtbase/kdebindings/generator/parser/parsesession.h:
30:0,
                 from C:/src/qtbase/kdebindings/generator/generatorvisitor.h:26,

                 from C:/src/qtbase/kdebindings/generator/type_compiler.cpp:22:
C:/src/qtbase/kdebindings/generator/parser/indexedstring.h:142:30: warning: inli
ne function 'uint qHash(const IndexedString&)' declared as  dllimport: attribute
 ignored [-Wattributes]
[ 54%] Building CXX object generator/CMakeFiles/smokegen.dir/name_compiler.cpp.o
bj
In file included from C:/src/qtbase/kdebindings/generator/parser/lexer.h:27:0,
                 from C:/src/qtbase/kdebindings/generator/name_compiler.cpp:23:
C:/src/qtbase/kdebindings/generator/parser/indexedstring.h:142:30: warning: inli
ne function 'uint qHash(const IndexedString&)' declared as  dllimport: attribute
 ignored [-Wattributes]
[ 55%] Building CXX object generator/CMakeFiles/smokegen.dir/type.cpp.obj
Linking CXX executable bin/smokegen.exe
Creating library file: bin/libsmokegen.dll.a
[ 55%] Built target smokegen
Scanning dependencies of target generator_smoke
[ 57%] Building CXX object generator/generators/smoke/CMakeFiles/generator_smoke
.dir/generator_smoke.cpp.obj
[ 59%] Building CXX object generator/generators/smoke/CMakeFiles/generator_smoke
.dir/writeClasses.cpp.obj
[ 60%] Building CXX object generator/generators/smoke/CMakeFiles/generator_smoke
.dir/writeSmokeDataFile.cpp.obj
[ 62%] Building CXX object generator/generators/smoke/CMakeFiles/generator_smoke
.dir/helpers.cpp.obj
Linking CXX shared module ../../bin/generator_smoke.dll
[ 62%] Built target generator_smoke
Scanning dependencies of target generator_dump
[ 63%] Building CXX object generator/generators/dump/CMakeFiles/generator_dump.d
ir/generator_dump.cpp.obj
Linking CXX shared module ../../bin/generator_dump.dll
[ 63%] Built target generator_dump
[ 65%] Generating smokedata.cpp, x_1.cpp, x_2.cpp, x_3.cpp, x_4.cpp, x_5.cpp, x_
6.cpp, x_7.cpp, x_8.cpp, x_9.cpp, x_10.cpp, x_11.cpp, x_12.cpp, x_13.cpp, x_14.c
pp, x_15.cpp, x_16.cpp, x_17.cpp, x_18.cpp, x_19.cpp, x_20.cpp
terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
make[3]: *** [smoke/qt/smokedata.cpp] Error 3
make[2]: *** [smoke/qt/CMakeFiles/smokeqt.dir/all] Error 2
make[1]: *** [all] Error 2
make: *** [all] Error 2
Warning: running command 'make --no-print-directory -f "Makefile.win"' had statu
s 2
ERROR: compilation failed for package 'qtbase'
* removing 'C:/Program Files/R/R-3.1.0/library/qtbase'

BTW note the warning:

qtbase/kdebindings/generator/parser/parsesession.cpp: In destructor 'ParseSession::~ParseSession()':
qtbase/kdebindings/generator/parser/parsesession.cpp:42:10: warning: possible problem detected in invocation of delete operator: [enabled by default]
qtbase/kdebindings/generator/parser/parsesession.cpp:42:10: warning: invalid use of incomplete type 'struct rpp::MacroBlock' [enabled by default]
qtbase/kdebindings/generator/parser/parsesession.h:43:23: warning: forward declaration of 'struct rpp::MacroBlock' [enabled by default]
qtbase/kdebindings/generator/parser/parsesession.cpp:42:10: note: neither the destructor nor the class-specific operator delete will be called, 
    even if they are declared when the class is defined

This seems it can be fixed by #include "rpp/pp-environment.h" instead of the forward declaration of namespace rpp { class MacroBlock; class LocationTable; } in qtbase/kdebindings/generator/parser/parsesession.h. However, it is marginal, as it does not solve the "std::bad_alloc" problem.

@lawremi
Copy link
Member

lawremi commented Jul 9, 2014

I'm pretty sure this is the same hang-up that everyone else has encountered
when trying to build on Windows. Still have not managed to figure out what
is happening.

On Tue, Jul 8, 2014 at 6:58 AM, Tomas Sieger notifications@github.com
wrote:

Following
https://github.com/ggobi/cranvas/wiki/Installation-under-windows-32-bit,
qtbase build terminates with:

[ 65%] Generating smokedata.cpp, x_1.cpp, x_2.cpp, x_3.cpp, x_4.cpp, x_5.cpp, x_
6.cpp, x_7.cpp, x_8.cpp, x_9.cpp, x_10.cpp, x_11.cpp, x_12.cpp, x_13.cpp, x_14.c
pp, x_15.cpp, x_16.cpp, x_17.cpp, x_18.cpp, x_19.cpp, x_20.cpp
terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc

version info:

R version 3.1.0 (2014-04-10)
Platform: i386-w64-mingw32/i386 (32-bit)
cmake 2.8.11
Qt opensource 4.8.6
RTools 3.1 (gcc 4.6.3)

build log:

C:\src>R CMD INSTALL --build qtbase

  • installing to library 'C:/Program Files/R/R-3.1.0/library'

  • installing source package 'qtbase' ...
    ** libs
    running 'src/Makefile.win' ...
    cygwin warning:
    MS-DOS style path detected: C:/PROGRA1/R/R-311.0/bin/R
    Preferred POSIX equivalent is: /cygdrive/c/PROGRA1/R/R-311.0/bin/R
    CYGWIN environment variable option "nodosfilewarning" turns off this warning.
    Consult the user's guide for more details about POSIX paths:
    http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
    mkdir -p ../kdebindings-build;
    cd ../kdebindings-build;
    "/cygdrive/C/Program Files/CMake 2.8/bin/cmake.exe" ../kdebindings -G "Unix Make
    files" -DQT_QMAKE_EXECUTABLE="C:\Qt\4.8.6\bin\qmake.exe" -DCMAKE_RC_COMPILER="C:
    /Rtools/gcc-4.6.3/bin/windres.exe" -DR_LIBRARIES="-LC:/PROGRA1/R/R-311.0/bin//
    i386 -lR" -DR_CXX="g++" -DCMAKE_CXX_FLAGS="-m32 " -DCMAKE_SHARED_LINKER_FLAGS="-
    m32 -shared"
    -DCMAKE_INSTALL_PREFIX=../inst/local
    -DCMAKE_EXE_LINKER_FLAGS="-m32 "
    -DCMAKE_MODULE_LINKER_FLAGS="-m32 ";
    LD_LIBRARY_PATH=../../generator/bin make install
    -- The C compiler identification is GNU 4.6.3
    -- The CXX compiler identification is GNU 4.6.3
    -- Check for working C compiler: C:/Rtools/gcc-4.6.3/bin/gcc.exe
    -- Check for working C compiler: C:/Rtools/gcc-4.6.3/bin/gcc.exe -- works
    -- Detecting C compiler ABI info
    -- Detecting C compiler ABI info - failed
    -- Check for working CXX compiler: C:/Rtools/gcc-4.6.3/bin/g++.exe
    -- Check for working CXX compiler: C:/Rtools/gcc-4.6.3/bin/g++.exe -- works
    -- Detecting CXX compiler ABI info
    -- Detecting CXX compiler ABI info - failed
    -- Looking for Q_WS_X11
    -- Looking for Q_WS_X11 - not found
    -- Looking for Q_WS_WIN
    -- Looking for Q_WS_WIN - found
    -- Looking for Q_WS_QWS
    -- Looking for Q_WS_QWS - not found
    -- Looking for Q_WS_MAC
    -- Looking for Q_WS_MAC - not found
    -- Found Qt4: C:/Qt/4.8.6/bin/qmake.exe (found suitable version "4.8.6", minimum
    required is "4.0.0")
    -- Found Qt4: C:/Qt/4.8.6/bin/qmake.exe (found suitable version "4.8.6", minimum
    required is "4.0.0")
    -- Found OpenGL: opengl32
    -- Found Perl: C:/Strawberry/perl/bin/perl.exe (found version "5.12.3")
    -- Checking how Qt was built...
    -- Threshold is set to 10
    -- QT_NO_DEBUG Undefined
    -- QT_NO_ACCESSIBILITY [Defined]
    -- QT_NO_BUTTONGROUP Undefined
    -- QT_NO_COLORDIALOG Undefined
    -- QT_NO_DATETIMEEDIT Undefined
    -- QT_NO_DIALOG Undefined
    -- QT_NO_ERRORMESSAGE Undefined
    -- QT_NO_FILEDIALOG Undefined
    -- QT_NO_FONTDIALOG Undefined
    -- QT_NO_GROUPBOX Undefined
    -- QT_NO_LCDNUMBER Undefined
    -- QT_NO_LINEEDIT Undefined
    -- QT_NO_LISTVIEW Undefined
    -- QT_NO_MAINWINDOW Undefined
    -- QT_NO_MENUBAR Undefined
    -- QT_NO_MESSAGEBOX Undefined
    -- QT_NO_PRINTDIALOG Undefined
    -- QT_NO_PROGRESSBAR Undefined
    -- QT_NO_PROGRESSDIALOG Undefined
    -- QT_NO_PUSHBUTTON Undefined
    -- QT_NO_RADIOBUTTON Undefined
    -- QT_NO_SCROLLBAR Undefined
    -- QT_NO_SLIDER Undefined
    -- QT_NO_STYLE_PLASTIQUE Undefined
    -- QT_NO_STYLE_WINDOWSXP Undefined
    -- QT_NO_STYLE_WINDOWS Undefined
    -- QT_NO_STYLE_MAC [Defined]
    -- QT_NO_STYLE_CLEANLOOKS Undefined
    -- QT_NO_TABLEVIEW Undefined
    -- QT_NO_TEXTBROWSER Undefined
    -- QT_NO_TEXTEDIT Undefined
    -- QT_NO_TOOLBUTTON Undefined
    -- QT_DLL [Defined]
    -- QT_NO_DEBUG [Defined]
    -- QT_OPENGL_LIB [Defined]
    -- QT_DECLARATIVE_LIB [Defined]
    -- QT_SCRIPT_LIB [Defined]
    -- QT_SVG_LIB [Defined]
    -- QT_HELP_LIB [Defined]
    -- QT_WEBKIT_LIB [Defined]
    -- QT_MULTIMEDIA_LIB [Defined]
    -- QT_XMLPATTERNS_LIB [Defined]
    -- QT_GUI_LIB [Defined]
    -- QT_TEST_LIB [Defined]
    -- QT_DBUS_LIB [Defined]
    -- QT_XML_LIB [Defined]
    -- QT_SQL_LIB [Defined]
    -- QT_NETWORK_LIB [Defined]
    -- QT_CORE_LIB [Defined]
    -- Build Smoke... yes - Qt
    -- Configuring done
    -- Generating done
    CMake Warning:
    Manually-specified variables were not used by the project:

    R_LIBRARIES

-- Build files have been written to: C:/src/qtbase/kdebindings-build
Scanning dependencies of target cppparser
[ 1%] Building CXX object generator/parser/CMakeFiles/cppparser.dir/ast.cpp.obj

[ 3%] Building CXX object generator/parser/CMakeFiles/cppparser.dir/default_vis
itor.cpp.obj
[ 4%] Building CXX object generator/parser/CMakeFiles/cppparser.dir/memorypool.
cpp.obj
[ 6%] Building CXX object generator/parser/CMakeFiles/cppparser.dir/visitor.cpp
.obj
[ 8%] Building CXX object generator/parser/CMakeFiles/cppparser.dir/control.cpp
.obj
[ 9%] Building CXX object generator/parser/CMakeFiles/cppparser.dir/lexer.cpp.o
bj
[ 11%] Building CXX object generator/parser/CMakeFiles/cppparser.dir/parser.cpp.
obj
[ 13%] Building CXX object generator/parser/CMakeFiles/cppparser.dir/listnode.cp
p.obj
[ 14%] Building CXX object generator/parser/CMakeFiles/cppparser.dir/tokens.cpp.
obj
[ 16%] Building CXX object generator/parser/CMakeFiles/cppparser.dir/dumptree.cp
p.obj
[ 18%] Building CXX object generator/parser/CMakeFiles/cppparser.dir/parsesessio
n.cpp.obj
C:/src/qtbase/kdebindings/generator/parser/parsesession.cpp: In destructor 'Pars
eSession::~ParseSession()':
C:/src/qtbase/kdebindings/generator/parser/parsesession.cpp:42:10: warning: poss
ible problem detected in invocation of delete operator: [enabled by default]
C:/src/qtbase/kdebindings/generator/parser/parsesession.cpp:42:10: warning: inva
lid use of incomplete type 'struct rpp::MacroBlock' [enabled by default]
C:/src/qtbase/kdebindings/generator/parser/parsesession.h:43:23: warning: forwar
d declaration of 'struct rpp::MacroBlock' [enabled by default]
C:/src/qtbase/kdebindings/generator/parser/parsesession.cpp:42:10: note: neither
the destructor nor the class-specific operator delete will be called, even if t
hey are declared when the class is defined
[ 19%] Building CXX object generator/parser/CMakeFiles/cppparser.dir/commentpars
er.cpp.obj
[ 21%] Building CXX object generator/parser/CMakeFiles/cppparser.dir/commentform
atter.cpp.obj
[ 22%] Building CXX object generator/parser/CMakeFiles/cppparser.dir/codegenerat
or.cpp.obj
[ 24%] Building CXX object generator/parser/CMakeFiles/cppparser.dir/indexedstri
ng.cpp.obj
[ 26%] Building CXX object generator/parser/CMakeFiles/cppparser.dir/stringhelpe
rs.cpp.obj
[ 27%] Building CXX object generator/parser/CMakeFiles/cppparser.dir/rpp/pp-stre
am.cpp.obj
[ 29%] Building CXX object generator/parser/CMakeFiles/cppparser.dir/rpp/pp-macr
o-expander.cpp.obj
[ 31%] Building CXX object generator/parser/CMakeFiles/cppparser.dir/rpp/pp-scan
ner.cpp.obj
[ 32%] Building CXX object generator/parser/CMakeFiles/cppparser.dir/rpp/pp-macr
o.cpp.obj
[ 34%] Building CXX object generator/parser/CMakeFiles/cppparser.dir/rpp/pp-engi
ne.cpp.obj
[ 36%] Building CXX object generator/parser/CMakeFiles/cppparser.dir/rpp/pp-inte
rnal.cpp.obj
[ 37%] Building CXX object generator/parser/CMakeFiles/cppparser.dir/rpp/pp-envi
ronment.cpp.obj
[ 39%] Building CXX object generator/parser/CMakeFiles/cppparser.dir/rpp/pp-loca
tion.cpp.obj
[ 40%] Building CXX object generator/parser/CMakeFiles/cppparser.dir/rpp/preproc
essor.cpp.obj
[ 42%] Building CXX object generator/parser/CMakeFiles/cppparser.dir/rpp/chartoo
ls.cpp.obj
Linking CXX shared library ../bin/libcppparser.dll
Creating library file: ../bin/libcppparser.dll.a
[ 42%] Built target cppparser
Scanning dependencies of target smokegen
[ 44%] Building CXX object generator/CMakeFiles/smokegen.dir/main.cpp.obj
In file included from C:/src/qtbase/kdebindings/generator/parser/parsesession.h:
30:0,
from C:/src/qtbase/kdebindings/generator/main.cpp:31:
C:/src/qtbase/kdebindings/generator/parser/indexedstring.h:142:30: warning: inli
ne function 'uint qHash(const IndexedString&)' declared as dllimport: attribute
ignored [-Wattributes]
[ 45%] Building CXX object generator/CMakeFiles/smokegen.dir/generatorenvironmen
t.cpp.obj
In file included from C:/src/qtbase/kdebindings/generator/parser/rpp/pp-environm
ent.h:31:0,
from C:/src/qtbase/kdebindings/generator/generatorenvironment.h
:22,
from C:/src/qtbase/kdebindings/generator/generatorenvironment.c
pp:19:
C:/src/qtbase/kdebindings/generator/parser/rpp/../indexedstring.h:142:30: warnin
g: inline function 'uint qHash(const IndexedString&)' declared as dllimport: at
tribute ignored [-Wattributes]
[ 47%] Building CXX object generator/CMakeFiles/smokegen.dir/generatorvisitor.cp
p.obj
In file included from C:/src/qtbase/kdebindings/generator/parser/parsesession.h:
30:0,
from C:/src/qtbase/kdebindings/generator/generatorvisitor.h:26,

             from C:/src/qtbase/kdebindings/generator/generatorvisitor.cpp:2

4:
C:/src/qtbase/kdebindings/generator/parser/indexedstring.h:142:30: warning: inli
ne function 'uint qHash(const IndexedString&)' declared as dllimport: attribute
ignored [-Wattributes]
[ 49%] Building CXX object generator/CMakeFiles/smokegen.dir/generatorpreprocess
or.cpp.obj
In file included from C:/src/qtbase/kdebindings/generator/parser/rpp/pp-macro.h:
28:0,
from C:/src/qtbase/kdebindings/generator/parser/rpp/pp-engine.h
:33,
from C:/src/qtbase/kdebindings/generator/generatorpreprocessor.
h:30,
from C:/src/qtbase/kdebindings/generator/generatorpreprocessor.
cpp:19:
C:/src/qtbase/kdebindings/generator/parser/rpp/../indexedstring.h:142:30: warnin
g: inline function 'uint qHash(const IndexedString&)' declared as dllimport: at
tribute ignored [-Wattributes]
[ 50%] Building CXX object generator/CMakeFiles/smokegen.dir/options.cpp.obj
[ 52%] Building CXX object generator/CMakeFiles/smokegen.dir/type_compiler.cpp.o
bj
In file included from C:/src/qtbase/kdebindings/generator/parser/parsesession.h:
30:0,
from C:/src/qtbase/kdebindings/generator/generatorvisitor.h:26,

             from C:/src/qtbase/kdebindings/generator/type_compiler.cpp:22:

C:/src/qtbase/kdebindings/generator/parser/indexedstring.h:142:30: warning: inli
ne function 'uint qHash(const IndexedString&)' declared as dllimport: attribute
ignored [-Wattributes]
[ 54%] Building CXX object generator/CMakeFiles/smokegen.dir/name_compiler.cpp.o
bj
In file included from C:/src/qtbase/kdebindings/generator/parser/lexer.h:27:0,
from C:/src/qtbase/kdebindings/generator/name_compiler.cpp:23:
C:/src/qtbase/kdebindings/generator/parser/indexedstring.h:142:30: warning: inli
ne function 'uint qHash(const IndexedString&)' declared as dllimport: attribute
ignored [-Wattributes]
[ 55%] Building CXX object generator/CMakeFiles/smokegen.dir/type.cpp.obj
Linking CXX executable bin/smokegen.exe
Creating library file: bin/libsmokegen.dll.a
[ 55%] Built target smokegen
Scanning dependencies of target generator_smoke
[ 57%] Building CXX object generator/generators/smoke/CMakeFiles/generator_smoke
.dir/generator_smoke.cpp.obj
[ 59%] Building CXX object generator/generators/smoke/CMakeFiles/generator_smoke
.dir/writeClasses.cpp.obj
[ 60%] Building CXX object generator/generators/smoke/CMakeFiles/generator_smoke
.dir/writeSmokeDataFile.cpp.obj
[ 62%] Building CXX object generator/generators/smoke/CMakeFiles/generator_smoke
.dir/helpers.cpp.obj
Linking CXX shared module ../../bin/generator_smoke.dll
[ 62%] Built target generator_smoke
Scanning dependencies of target generator_dump
[ 63%] Building CXX object generator/generators/dump/CMakeFiles/generator_dump.d
ir/generator_dump.cpp.obj
Linking CXX shared module ../../bin/generator_dump.dll
[ 63%] Built target generator_dump
[ 65%] Generating smokedata.cpp, x_1.cpp, x_2.cpp, x_3.cpp, x_4.cpp, x_5.cpp, x_
6.cpp, x_7.cpp, x_8.cpp, x_9.cpp, x_10.cpp, x_11.cpp, x_12.cpp, x_13.cpp, x_14.c
pp, x_15.cpp, x_16.cpp, x_17.cpp, x_18.cpp, x_19.cpp, x_20.cpp
terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
make[3]: *** [smoke/qt/smokedata.cpp] Error 3
make[2]: *** [smoke/qt/CMakeFiles/smokeqt.dir/all] Error 2
make[1]: *** [all] Error 2
make: *** [all] Error 2
Warning: running command 'make --no-print-directory -f "Makefile.win"' had statu
s 2
ERROR: compilation failed for package 'qtbase'

  • removing 'C:/Program Files/R/R-3.1.0/library/qtbase'

BTW note the warning:

qtbase/kdebindings/generator/parser/parsesession.cpp: In destructor 'ParseSession::~ParseSession()':
qtbase/kdebindings/generator/parser/parsesession.cpp:42:10: warning: possible problem detected in invocation of delete operator: [enabled by default]
qtbase/kdebindings/generator/parser/parsesession.cpp:42:10: warning: invalid use of incomplete type 'struct rpp::MacroBlock' [enabled by default]
qtbase/kdebindings/generator/parser/parsesession.h:43:23: warning: forward declaration of 'struct rpp::MacroBlock' [enabled by default]
qtbase/kdebindings/generator/parser/parsesession.cpp:42:10: note: neither the destructor nor the class-specific operator delete will be called,
even if they are declared when the class is defined

This seems it can be fixed by #include "rpp/pp-environment.h" instead of
the forward declaration of namespace rpp { class MacroBlock; class
LocationTable; } in qtbase/kdebindings/generator/parser/parsesession.h.
However, it is marginal, as it does not solve the "std::bad_alloc" problem.


Reply to this email directly or view it on GitHub
#25.

@lawremi
Copy link
Member

lawremi commented Sep 24, 2014

At some point I should sit down and run the generator through valgrind. Hopefully something pops up.

@tsieger
Copy link
Author

tsieger commented Sep 24, 2014

You mean running through valgrind under wine? (AFAIK valgrind does not run under windows.) Or do you hope for a catch under linux/Mac?
I've tried debugging simply using gdb, but with no luck - I can't even catch the std::bad_alloc exception. Seems like the generator throws the exception even before "main" starts; maybe there is some problem with libs or the way they get linked/loaded, not the generator itself? Maybe, the problem is not even directly related to "out of memory conditions" - I've even tried to simplify the generator (by commenting out pieces of it) to minimize its memory footprint, but the problem persists even in a tiny app (however, I haven't controlled for any libs, I've played with the "main" only).
Also, trying to reproduce the problem with a trivial app compiled in the same way the generator gets compiled (but having dependent libs omitted) does not help - everything works correctly.
(BTW - congratulations for becoming new R Core Member!!)

@lawremi
Copy link
Member

lawremi commented Sep 24, 2014

Sorry, I guess I was wrong about this being the same issue as on Windows. The Windows error happens much later, and appears to be due to memory corruption. That's the one I wanted to find with valgrind (and according to the mailing list, the crash does sometimes happen on Linux). But this issue does seem like something to do with the linking.

@tsieger
Copy link
Author

tsieger commented Sep 28, 2014

I solved it. The problem was that following the Win32 cranvas installation instructions (https://github.com/ggobi/cranvas/wiki/Installation-under-windows-32-bit) I was using g++ from RTools, which apparently did not work for me. I finally managed to compile qtbase using MinGW g++. Maybe, this should be mentioned in the installation instructions?
When compiled using MinGW g++, the smoke generator worked fine!
BTW I also ran the generator through valgrind on linux, and found no memory access problems (just a few memleaks).

However, even though qtbase can be compiled and loaded, it is unstable: see #28.

@lawremi
Copy link
Member

lawremi commented Sep 28, 2014

Since you're all setup, would you please try this with the Qt5 branch? I'll look into the instability issues, but it would be great if we could get qt5 working on Windows.

@tsieger
Copy link
Author

tsieger commented Oct 2, 2014

I tried building the Qt5 branch against qt-opensource-windows-x86-mingw48_opengl-5.2.1.exe. The generator could be built, but when run, it failed in the unspecific way shown e.g. by Yihui in his post to the cranvas google group: https://groups.google.com/d/msg/cranvas/ar2T-HdhMmQ/Mh1PrwLHkcMJ, i.e. producing something like:

[ 63%] Built target generator_dump
[ 65%] Generating smokedata.cpp, x_1.cpp, x_2.cpp, x_3.cpp, x_4.cpp,
x_5.cpp, x_6.cpp, x_7.cpp, x_8.cpp, x_9.cpp, x_10.cpp, x_11.cpp,
x_12.c
pp, x_13.cpp, x_14.cpp, x_15.cpp, x_16.cpp, x_17.cpp, x_18.cpp,
x_19.cpp, x_20.cpp
make[3]: *** [smoke/qt/smokedata.cpp] Error 127
make[2]: *** [smoke/qt/CMakeFiles/smokeqt.dir/all] Error 2
make[1]: *** [all] Error 2
make: *** [all] Error 2
ERROR: compilation failed for package 'qtbase'

When running the generator from the command line, Windows helped by saying that the problem was that some entry point was missing from libstd-c++. Okay, Qt was built with mingw4.8.? and I was using mingw4.8.1 to build qtbase -maybe there was a mingw version mismatch. Then I noticed Qt comes with its copy of mingw 4.8.0. So, using that mingw 4.8.0 to build qtbase helped - the generator could be run. However, it failed with:

[ 66%] Generating smokedata.cpp, x_1.cpp, x_2.cpp, x_3.cpp, x_4.cpp, x_5.cpp, x_6.cpp, x_7.cpp,
 x_8.cpp, x_9.cpp, x_10.cpp, x_11.cpp, x_12.cpp, x_13.cpp, x_14.cpp, x_15.cpp, x_16.cpp, x_17.cpp, x_18.cpp, x_19.cpp, x_20.cpp
attempting to load generator "C:/src/qtbase-qt5/qtbase/kdebindings-build/generator/bin/generator_smoke"
using generator "C:/src/qtbase-qt5/qtbase/kdebindings-build/generator/bin/generator_smoke.DLL"
parsing "C:/src/qtbase-qt5/qtbase/kdebindings/smoke/qt/qt_includes.h"
Generating SMOKE sources...
preparing SMOKE data [qt]
writing out smokedata.cpp [qt]
missing type:  in method  QLatin1Char::ch(c) (while writing out methods table)

The same applies to Qt5.2.0.

BTW the relevant "method" is probably meant to be a char constructor of a private member:

struct QLatin1Char
{
public:
    Q_DECL_CONSTEXPR inline explicit QLatin1Char(char c) : ch(c) {}
    Q_DECL_CONSTEXPR inline char toLatin1() const { return ch; }
    Q_DECL_CONSTEXPR inline ushort unicode() const { return ushort(uchar(ch)); }

private:
    char ch;
};

@lawremi
Copy link
Member

lawremi commented Oct 2, 2014

This is the same exact error that I have hit. Since it's always the same method (QLatin1Char::ch), I'm now thinking it might be simpler to solve than what I had originally expected (some sort of internal corruption).

The smoke generator adds methods for accessing non-private fields. In this case, something has gone wrong, because the 'ch' field is private, as you pointed out. Also, it is werd that the type is an empty string. At least on my Linux machine, no accessor for "ch" is generated.

I guess one approach would be check whether the smoke generator at least parses the header correctly, i.e, that the private flag is seen, but then lost somehow.

@tsieger
Copy link
Author

tsieger commented Oct 7, 2014

The problem seems to be related not to whether the "char ch" is private or not, but to the fact that on Windows (not on Linux), the parser confuses the QLatin1Char constructor
Q_DECL_CONSTEXPR inline explicit QLatin1Char(char c) : ch(c) {}
with a method decl/def:
QLatin1Char::ch(c) {}

It leads calling the GeneratorVisitor to process the method decl "ch(c)", for which the type compiler does not return a valid type.
Subsequently, the "method" QLatin1Char::ch(c) does not have a proper return type (and has even bad name assigned - not the extra leading space).

It is not clear to me why the parser gets confused on Win, but not on Linux.
However, the parser dumps differ:
win:
Q_DECL_CONSTEXPR inline explicit QLatin1Char (char c) : ch(c) {}
on linux, the Q_DECL_CONSTEXPR is missing:
inline explicit QLatin1Char (char c) : ch(c) {}

The DefaultVisitor::visitClassSpecifier's node->member_specs (each line represents a single spec) differ as well:
win:

    char c;
    public:
    ch (c) {} !!!!!! THIS IS WEIRD - NOT A METHOD DECL!
    char toLatin1() const {return ch;}
    unicode() const {return ushort (uchar(ch));}
    private:

linux:

    char ch;
    public:
    inline explicit QLatin1Char (char c) : ch(c) {}
    inline char toLatin1() const { return ch;}
    inline ushort unicode() const {return rushort(uchar(ch));}
    private:

Full commented back trace follows. The top-most frame refers to GeneratorVisitor::visitDeclarator() in which the method "ch(c)" gets no return type. Note the frame #7, in which member_specs->next->next->element points to "ch(c)".

Lines "[number]:[decl]" refer to the parser dump; I copied relevant portions of the parsed stream below each stack frame to ease undertanding.

#0  0x00409020 in GeneratorVisitor::visitDeclarator (this=0x22fb18, node=0x3523c64) at C:/src/qtbase-fresh-zipped141005/qtbase/kdebindings/generator/generatorvisitor.cpp:538
    *node: {<AST> = {kind = 15, start_token = 55075, end_token = 55079},
    Kind_Declarator

    55075: identifierch
    55076: ((
    55077: identifierc
    55078: ))
    55079: {{

#1  0x638c2a3b in Visitor::visit (this=0x22fb18, node=0x3523c64) at C:/src/qtbase-fresh-zipped141005/qtbase/kdebindings/generator/parser/visitor.cpp:113
#2  0x638c1d34 in DefaultVisitor::visitInitDeclarator (this=0x22fb18, node=0x3523e04) at C:/src/qtbase-fresh-zipped141005/qtbase/kdebindings/generator/parser/default_visitor.cpp:192
    *node: {<AST> = {kind = 29, start_token = 55075, end_token = 55079},
    Kind_InitDeclarator
      declarator = 0x3523c64, initializer = 0x0

#3  0x638c2a3b in Visitor::visit (this=0x22fb18, node=0x3523e04) at C:/src/qtbase-fresh-zipped141005/qtbase/kdebindings/generator/parser/visitor.cpp:113
#4  0x0040a068 in GeneratorVisitor::visitFunctionDefinition (this=0x22fb18, node=0x3523e28) at C:/src/qtbase-fresh-zipped141005/qtbase/kdebindings/generator/generatorvisitor.cpp:639
    *node: {<DeclarationAST> = {<AST> = {kind = 26, start_token = 55075, end_token = 55081},
    Kind_FunctionDefinition
          <CommentAST> = {comments = 0x0

    55075: identifierch
    55076: ((
    55077: identifierc
    55078: ))
    55079: {{
    55080: }}
    55081: identifierQ_DECL_CONSTEXPR

*currentMethod->m_type: {static Void = 0x3f5084, 
m_class = 0x0, m_typedef = 0x0, m_enum = 0x0
,  m_name = {static null = <optimized out>, d = 0x68ad41c0},
  m_isConst = false, m_isVolatile = false, m_pointerDepth = 0,
  m_constPointer = {{d = 0x68ad6760, e = 0x68ad6760}}, m_isRef = false,
  m_isIntegral = false, m_templateArgs = {{p = {
        static shared_null = <optimized out>, d = 0x68ad67e4},
      d = 0x68ad67e4}}, m_isFunctionPointer = false, m_params = {{p = {
        static shared_null = <optimized out>, d = 0x68ad67e4},
      d = 0x68ad67e4}}, m_arrayLengths = {d = 0x68ad41c0}}

#5  0x638c2a3b in Visitor::visit (this=0x22fb18, node=0x3523e28) at C:/src/qtbase-fresh-zipped141005/qtbase/kdebindings/generator/parser/visitor.cpp:113
#6  0x638f3fe4 in visitNodes<DeclarationAST*> (v=0x22fb18, nodes=0x3524a24) at C:/src/qtbase-fresh-zipped141005/qtbase/kdebindings/generator/parser/visitor.h:131
    *it->element: {<AST> = {kind = 26, start_token = 55075, end_token = 55081}, 
    Kind_FunctionDefinition

#7  0x638c1718 in DefaultVisitor::visitClassSpecifier (this=0x22fb18, node=0x35237d8) at C:/src/qtbase-fresh-zipped141005/qtbase/kdebindings/generator/parser/default_visitor.cpp:63
    *node: {<TypeSpecifierAST> = {<AST> = {kind = 8, start_token = 55061, end_token = 55117}, 
    Kind_ClassSpecifier
    cv = 0x0}, win_decl_specifiers = 0x0, class_key = 55061, name = 0x35237a4, base_clause = 0x0, member_specs = 0x3524a24}

    55061: structstruct
    55062: identifierQLatin1Char
    55063: {{
    55064: publicpublic
    55065: ::
    55066: identifierQ_DECL_CONSTEXPR
    55067: inlineinline
    55068: explicitexplicit
    55069: identifierQLatin1Char
    55070: ((
    55071: charchar
    55072: identifierc
    55073: ))
    55074: ::
    55075: identifierch
    55076: ((
    55077: identifierc
    55078: ))
    55079: {{
    55080: }}
    55081: identifierQ_DECL_CONSTEXPR
    55082: inlineinline
    55083: charchar
    55084: identifiertoLatin1
    55085: ((
    55086: ))
    55087: constconst
    55088: {{
    55089: returnreturn
    55090: identifierch
    55091: ;;
    55092: }}
    55093: identifierQ_DECL_CONSTEXPR
    55094: inlineinline
    55095: identifierushort
    55096: identifierunicode
    55097: ((
    55098: ))
    55099: constconst
    55100: {{
    55101: returnreturn
    55102: identifierushort
    55103: ((
    55104: identifieruchar
    55105: ((
    55106: identifierch
    55107: ))
    55108: ))
    55109: ;;
    55110: }}
    55111: privateprivate
    55112: ::
    55113: charchar
    55114: identifierch
    55115: ;;
    55116: }}
    55117: ;;

    *node->name: {<AST> = {kind = 36, start_token = 55062, end_token = 55063},
    Kind_Name
      global = false, qualified_names = 0x0, unqualified_name = 0x35237bc}

    55062: identifierQLatin1Char
    55063: {{

    *node->name->unqualified_name: {<AST> = {kind = 70, start_token = 55062, end_token = 55063},
    Kind_UnqualifiedName
      tilde = 0, id = 55062, operator_id = 0x0, template_arguments = 0x0

    55062: identifierQLatin1Char
    55063: {{

    *node->member_specs: {element = 0x3524a00, index = 5, next = 0x352381c}

    *node->member_specs->element: {<AST> = {kind = 52, start_token = 55113, end_token = 55116}, 
    Kind_SimpleDeclaration
    <CommentAST> = {comments = 0x0
    }, <No data fields>}

    55113: charchar
    55114: identifierch
    55115: ;;
    55116: }}


*node->member_specs->element
$3 = {<AST> = {kind = 52, start_token = 55113, end_token = 55116}  "char c;"
*node->member_specs->next->element
$5 = {<AST> = {kind = 1, start_token = 55064, end_token = 55066}   "public:"
*node->member_specs->next->next->element
$7 = {<AST> = {kind = 26, start_token = 55075, end_token = 55081}  "ch (c) {}" !!!!!! THIS IS WEIRD - NOT A METHOD DECL!
*node->member_specs->next->next->next->element
$8 = {<AST> = {kind = 26, start_token = 55083, end_token = 55093}  "char toLatin1() const {return ch;}"
*node->member_specs->next->next->next->next->element
$9 = {<AST> = {kind = 26, start_token = 55096, end_token = 55111}  "unicode() const {return ushort (uchar(ch));}"
*node->member_specs->next->next->next->next->next->element 
$10 = {<AST> = {kind = 1, start_token = 55111, end_token = 55113}  "private:"
*node->member_specs->next->next->next->next->next->next->element
$11 = {<AST> = {kind = 52, start_token = 55113, end_token = 55116} (see $3)


}, <No data fields>}
(gdb) p *node->member_specs->next->next->next->next->next->next->next->element
$12 = {<AST> = {kind = 1, start_token = 55064,
    end_token = 55066}, <CommentAST> = {comments = 0x0}, <No data fields>}
<s->next->next->next->next->next->next->next->next->element
$13 = {<AST> = {kind = 26, start_token = 55075,
    end_token = 55081}, <CommentAST> = {comments = 0x0}, <No data fields>}
<->next->next->next->next->next->next->next->next->element
$14 = {<AST> = {kind = 26, start_token = 55083,
    end_token = 55093}, <CommentAST> = {comments = 0x0}, <No data fields>}
(gdb)

#8  0x004079b3 in GeneratorVisitor::visitClassSpecifier (this=0x22fb18, node=0x35237d8) at C:/src/qtbase-fresh-zipped141005/qtbase/kdebindings/generator/generatorvisitor.cpp:384
#9  0x638c2a3b in Visitor::visit (this=0x22fb18, node=0x35237d8) at C:/src/qtbase-fresh-zipped141005/qtbase/kdebindings/generator/parser/visitor.cpp:113
#10 0x638c2388 in DefaultVisitor::visitSimpleDeclaration (this=0x22fb18, node=0x3524a78) at C:/src/qtbase-fresh-zipped141005/qtbase/kdebindings/generator/parser/default_visitor.cpp:335

    *node: {<DeclarationAST> = {<AST> = {kind = 52, start_token = 55061, end_token = 55118}, 
    Kind_SimpleDeclaration
    <CommentAST> = {comments = 0x0
      type_specifier = 0x35237d8, init_declarators = 0x0
      win_decl_specifiers = 0x0
    }

#11 0x0040b546 in GeneratorVisitor::visitSimpleDeclaration (this=0x22fb18, node=0x3524a78) at C:/src/qtbase-fresh-zipped141005/qtbase/kdebindings/generator/generatorvisitor.cpp:841
#12 0x638c2a3b in Visitor::visit (this=0x22fb18, node=0x3524a78) at C:/src/qtbase-fresh-zipped141005/qtbase/kdebindings/generator/parser/visitor.cpp:113
#13 0x638f3fe4 in visitNodes<DeclarationAST*> (v=0x22fb18, nodes=0x392dbe8) at C:/src/qtbase-fresh-zipped141005/qtbase/kdebindings/generator/parser/visitor.h:131
#14 0x638c2628 in DefaultVisitor::visitTranslationUnit (this=0x22fb18, node=0x311a7e8) at C:/src/qtbase-fresh-zipped141005/qtbase/kdebindings/generator/parser/default_visitor.cpp:394

    *node: {<AST> = {kind = 62, start_token = 3, end_token = 104576},

#15 0x638c2a3b in Visitor::visit (this=0x22fb18, node=0x311a7e8) at C:/src/qtbase-fresh-zipped141005/qtbase/kdebindings/generator/parser/visitor.cpp:113
#16 0x0040334a in main (argc=9, argv=0x3f4cc0) at C:/src/qtbase-fresh-zipped141005/qtbase/kdebindings/generator/main.cpp:229

Do you think that the parser can simply be confused by Q_DECL_CONSTEXPR inline explicit QLatin1Char(char c) : ch(c) {}? (And the issue would demonstrate even on linux in case there were the Q_DECL_CONSTEXPR present?)
Does the parser operate on preprocessed headers on linux, but not on Win? (This would explain why Q_DECL_CONSTEXPR is missing on linux).

@lawremi
Copy link
Member

lawremi commented Oct 7, 2014

Wow, this is seriously impressive debugging work. We're really in debt to you. There is a preprocessor built into the generator, so it should resolve Q_DECL_CONSTEXPR to something, and almost certainly the empty string, since the fake compiler does not advertise itself as cxx11 compliant. That symbol is defined in Qt's qcompilerdetection.h. Why is the processing of that file failing on Windows? Perhaps someting expected to be defined is not. The cmake scripts generate a qtdefines file that is used as input to the preprocessor. This is going to be different between operating systems and could be the source of the problem. Another interesting test would be to force define Q_DECL_CONSTEXPR in generatorpreprocessor.cpp, in the same way e.g. __GNUC__ is defined, except without appending a value. If that does not fix it, then there is a bug in the substitution, but why only on Windows?

@lawremi
Copy link
Member

lawremi commented Oct 7, 2014

I checked in a couple of recent fixes to smokegen from the kde-bindings repository. Not sure if these will help at all.

@tsieger
Copy link
Author

tsieger commented Oct 8, 2014

Thanks. I will check whether these kde-bindings fixes change something.

Getting back to your suggestions regarding the Q_DECL_CONSTEXPR:

i) qtdefines

My linux qtdefines contain:

QT_MULTIMEDIA_LIB
QT_MULTIMEDIAWIDGETS_LIB
QT_NETWORK_LIB
QT_QML_LIB
QT_QUICK_LIB
QT_SQL_LIB
QT_TEST_LIB
QT_WEBKIT_LIB
QT_WEBKITWIDGETS_LIB
QT_DBUS_LIB
QT_SVG_LIB
QT_XMLPATTERNS_LIB
QT_PRINTSUPPORT_LIB
QT_HELP_LIB
QT_UITOOLS_LIB
QT_SERIALPORT_LIB
QT_SENSORS_LIB
QT_BLUETOOTH_LIB
QT_NFC_LIB
QT_POSITIONING_LIB
QT_WEBSOCKETS_LIB

Win are missing QT_DBUS_LIB and QT_WEBSOCKETS_LIB. Don't know if this difference can cause the problems observed.

ii) defining Q_DECL_CONSTEXPR in generatorpreprocessor.cpp

This helps - now the generator processes everything!

However, the generated sources do not compile, as the generated x_QAbstractAnimation class has a copy constructor refering to the private QAbstractAnimation copy constructor, which has been made private by the macro Q_DISABLE_COPY defined in qglobal.h.

x_1.cpp (generated on win) contains:

namespace __smokeqt {
class x_QAbstractAnimation : public QAbstractAnimation, public __internal_SmokeClass {
public:
[...]
explicit x_QAbstractAnimation(const QAbstractAnimation& x1) : QAbstractAnimation(x1) {}
}
}

On linux, the x_QAbstractAnimation class lacks a copy constructor.

For completeness, the compiler output follows:

C:/src/qtbase-fresh-zipped141005/qtbase/kdebindings-build/smoke/qt/x_1.cpp:1:0:
warning: -fPIC ignored for target (all code is position independent) [enabled by default]
 //Auto-generated by C:\src\qtbase-fresh-zipped141005\qtbase\kdebindings-build\generator\bin\smokegen.exe. DO NOT EDIT.
 ^
In file included from C:/Qt/Qt5.2.0/5.2.0/mingw48_32/include/QtCore/qnamespace.h:45:0,
                 from C:/Qt/Qt5.2.0/5.2.0/mingw48_32/include/QtCore/qobjectdefs.h:45,
                 from C:/Qt/Qt5.2.0/5.2.0/mingw48_32/include/QtCore/qobject.h:48,
                 from C:/Qt/Qt5.2.0/5.2.0/mingw48_32/include/QtCore/qabstractanimation.h:45,
                 from C:/Qt/Qt5.2.0/5.2.0/mingw48_32/include/QtCore/QtCore:4,
                 from C:/src/qtbase-fresh-zipped141005/qtbase/kdebindings/smoke/qt/qt_includes.h:1,
                 from C:/src/qtbase-fresh-zipped141005/qtbase/kdebindings-build/smoke/qt/x_1.cpp:2:
C:/Qt/Qt5.2.0/5.2.0/mingw48_32/include/QtCore/qabstractanimation.h: In constructor 
'__smokeqt::x_QAbstractAnimation::x_QAbstractAnimation(const QAbstractAnimation&)':
C:/Qt/Qt5.2.0/5.2.0/mingw48_32/include/QtCore/qabstractanimation.h:129:20: error: 
    'QAbstractAnimation::QAbstractAnimation(const QAbstractAnimation&)' is private
     Q_DISABLE_COPY(QAbstractAnimation)
                    ^
C:/Qt/Qt5.2.0/5.2.0/mingw48_32/include/QtCore/qglobal.h:966:5: note: in definition of macro 'Q_DISABLE_COPY'
     Class(const Class &) Q_DECL_EQ_DELETE;\
     ^
C:/src/qtbase-fresh-zipped141005/qtbase/kdebindings-build/smoke/qt/x_1.cpp:165:8
8: error: within this context
     explicit x_QAbstractAnimation(const QAbstractAnimation& x1) : QAbstractAnimation(x1) {}
        ^

As the qabstractanimation.h is the same on both win and linux, I don't understand why the generator processes them differently.

@lawremi
Copy link
Member

lawremi commented Oct 8, 2014

Looks like the preprocessor might be broken somehow on Windows. No easy way to workaround this one, so we'll have to fix it.

@tsieger
Copy link
Author

tsieger commented Oct 9, 2014

Believe it or not, the two fixes taken from kde-bindings repository solved all the generator/preprocessor issues we've faced so far!
Now the generator works correctly (without any needs to manually define the Q_DECL_CONSTEXPR) and the copy constructor problem is gone as well.

The next issue was that fd_set was undeclared :

[ 10%] Building CXX object CMakeFiles/qtbase.dir/EventLoop.cpp.obj
In file included from C:/src/qtbase-master-parser-fixes141008/qtbase/src/EventLoop.cpp:23:0:
C:/PROGRA~1/R/R-31~1.0/include/R_ext/eventloop.h:73:65: error: 'fd_set' has not been declared
 extern InputHandler *getSelectedHandler(InputHandler *handlers, fd_set *mask);
                                                                 ^
C:/PROGRA~1/R/R-31~1.0/include/R_ext/eventloop.h:74:8: error: 'fd_set' does not name a type
 extern fd_set *R_checkActivity(int usec, int ignore_stdin);
        ^
C:/PROGRA~1/R/R-31~1.0/include/R_ext/eventloop.h:75:8: error: 'fd_set' does not name a type
 extern fd_set *R_checkActivityEx(int usec, int ignore_stdin, void (*intr)(void));
        ^
C:/PROGRA~1/R/R-31~1.0/include/R_ext/eventloop.h:76:51: error: 'fd_set' has not been declared
 extern void R_runHandlers(InputHandler *handlers, fd_set *mask);
                                                   ^
C:/PROGRA~1/R/R-31~1.0/include/R_ext/eventloop.h:78:32: error: 'fd_set' has not been declared
 extern int R_SelectEx(int  n,  fd_set  *readfds,  fd_set  *writefds,
                                ^
C:/PROGRA~1/R/R-31~1.0/include/R_ext/eventloop.h:78:51: error: 'fd_set' has not been declared
 extern int R_SelectEx(int  n,  fd_set  *readfds,  fd_set  *writefds,
                                                   ^
C:/PROGRA~1/R/R-31~1.0/include/R_ext/eventloop.h:79:9: error: 'fd_set' has not been declared
         fd_set *exceptfds, struct timeval *timeout,
         ^
C:/src/qtbase-master-parser-fixes141008/qtbase/src/EventLoop.cpp:62:50: warning:
 deprecated conversion from string constant to 'char*' [-Wwrite-strings]
 static char *qapp_argv[] = { "qtbase", "-nograb" };
                                                  ^
C:/src/qtbase-master-parser-fixes141008/qtbase/src/EventLoop.cpp:62:50: warning:
 deprecated conversion from string constant to 'char*' [-Wwrite-strings]
C:/src/qtbase-master-parser-fixes141008/qtbase/src/EventLoop.cpp: In static member function 'static void EventLoop::begin()':
C:/src/qtbase-master-parser-fixes141008/qtbase/src/EventLoop.cpp:268:18: error:
'pipe' was not declared in this scope
     if (!pipe(fds)) {
                  ^
make[3]: *** [CMakeFiles/qtbase.dir/EventLoop.cpp.obj] Error 1
make[2]: *** [CMakeFiles/qtbase.dir/all] Error 2
make[1]: *** [all] Error 2
make: *** [all] Error 2

It was caused by undefined WIN32 in EventLoop.cpp:

#ifndef WIN32
/* We need these symbols, but <Rinterface.h> declares them using C99
   uintptr_t, which no longer works with gcc 4.4. It seems like
   quintptr is more or less an alias. Could probably check something
   at build time, but without autconf, it's annoying. Don't tell BR. */
extern quintptr R_CStackLimit;  /* C stack limit */
extern quintptr R_CStackStart;  /* Initial stack address */
#include <R_ext/eventloop.h> /* UNIX-specific input handler implementation */
#include <unistd.h>
#else
/* --- Windows-only --- */
#include <QMutexLocker>
extern __declspec(dllimport) uintptr_t R_CStackLimit; /* C stack limit */
extern __declspec(dllimport) uintptr_t R_CStackStart; /* Initial stack address */
#include <windows.h>      
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#define WM_EVENTLOOP_CALLBACK ( WM_USER + 1 )
static HWND message_window;
static LRESULT CALLBACK
EventLoopWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
#ifndef HWND_MESSAGE
#define HWND_MESSAGE ((HWND)-3) /* NOTE: this is supported by >=W2k/XP only! */
#endif

<R_ext/eventloop.h> got thus included directly (in the non-WIN32 branch), having had no fd_set declared.

My hack was to define WIN32 in EventLoop.cpp before the #ifndef WIN32.

BTW, note the warning:

"/cygdrive/C/Program Files/CMake 2.8/bin/cmake.exe" ../src -G "Unix Makefiles" \
-DQT_QMAKE_EXECUTABLE="C:\Qt\Qt5.2.0\5.2.0\mingw48_32\bin" \
-DCMAKE_PREFIX_PATH="C:\Qt\4.8.6\bin/../lib/cmake" \
-DCMAKE_RC_COMPILER="C:/Rtools/gcc-4.6.3/bin/windres.exe" \
-DR_LIBRARIES="-LC:/PROGRA~1/R/R-31~1.0/bin//i386 -lR" -DR_CXX="g++" \
-DCMAKE_CXX_FLAGS="-m32 " -DCMAKE_SHARED_LINKER_FLAGS="-m32   -shared" \
      -DCMAKE_INSTALL_PREFIX=../src \
      -DR_INCLUDES=C:/PROGRA~1/R/R-31~1.0/include; \
make install
-- Found Qt module: Multimedia
-- Found Qt module: MultimediaWidgets
-- Found Qt module: Network
-- Found Qt module: Qml
-- Found Qt module: Quick
-- Found Qt module: Sql
-- Found Qt module: Test
-- Found Qt module: WebKit
-- Found Qt module: WebKitWidgets
-- Found Qt module: Svg
-- Found Qt module: XmlPatterns
-- Found Qt module: PrintSupport
-- Found Qt module: Help
-- Found Qt module: UiTools
-- Found Qt module: SerialPort
-- Found Qt module: Sensors
-- Found Qt module: Bluetooth
-- Found Qt module: Positioning
-- Found Qt module: Nfc
-- Configuring done
-- Generating done
CMake Warning:
  Manually-specified variables were not used by the project:

    QT_QMAKE_EXECUTABLE

Having WIN32 defined, we go further:

[ 89%] Building CXX object CMakeFiles/qtbase.dir/DataFrameModel.cpp.obj
[ 92%] Generating qtbase.def
sed: -e expression #1, char 4: unterminated address regex
Scanning dependencies of target qtbase
[ 94%] Building CXX object CMakeFiles/qtbase.dir/qtbase_automoc.cpp.obj
Linking CXX shared library qtbase.dll
d001289.o:(.idata$2+0x0): multiple definition of `_head_Qt5PrintSupport_dll'
C:/Qt/Qt5.2.0/5.2.0/mingw48_32/lib/libQt5PrintSupport.a(d000049.o):(.idata$2+0x0): first defined here
d001473.o:(.idata$7+0x0): multiple definition of `Qt5PrintSupport_dll_iname'
C:/Qt/Qt5.2.0/5.2.0/mingw48_32/lib/libQt5PrintSupport.a(d000449.o):(.idata$7+0x0): first defined here
d001474.o:(.idata$2+0x0): multiple definition of `_head_Qt5XmlPatterns_dll'
C:/Qt/Qt5.2.0/5.2.0/mingw48_32/lib/libQt5XmlPatterns.a(d000766.o):(.idata$2+0x0): first defined here
d001665.o:(.idata$7+0x0): multiple definition of `Qt5XmlPatterns_dll_iname'
C:/Qt/Qt5.2.0/5.2.0/mingw48_32/lib/libQt5XmlPatterns.a(d001074.o):(.idata$7+0x0): first defined here
d002086.o:(.idata$2+0x0): multiple definition of `_head_Qt5Test_dll'
C:/Qt/Qt5.2.0/5.2.0/mingw48_32/lib/libQt5Test.a(d000017.o):(.idata$2+0x0): first defined here
d002127.o:(.idata$7+0x0): multiple definition of `Qt5Test_dll_iname'
C:/Qt/Qt5.2.0/5.2.0/mingw48_32/lib/libQt5Test.a(d000182.o):(.idata$7+0x0): first defined here
collect2.exe: error: ld returned 1 exit status
make[3]: *** [qtbase.dll] Error 1
make[2]: *** [CMakeFiles/qtbase.dir/all] Error 2
make[1]: *** [all] Error 2
make: *** [all] Error 2
Warning: running command 'make --no-print-directory -f "Makefile.win"' had status 2

The culprit of the sed issue was that sed -n $1 tmp >> qtbase.def was called with $1 = x/^[^ ]* [T|C|B] /s/^[^ ]* [T|C|B] / /px.
Wrapping $1 in quotation marks helped:

sed -n "$1" tmp >> qtbase.def

Next, I run into:

[  2%] Automoc for target qtbase
[  2%] Built target qtbase_automoc
Linking CXX shared library qtbase.dll
d001289.o:(.idata$2+0x0): multiple definition of `_head_Qt5PrintSupport_dll'
C:/Qt/Qt5.2.0/5.2.0/mingw48_32/lib/libQt5PrintSupport.a(d000049.o):(.idata$2+0x0): first defined here
d001473.o:(.idata$7+0x0): multiple definition of `Qt5PrintSupport_dll_iname'
C:/Qt/Qt5.2.0/5.2.0/mingw48_32/lib/libQt5PrintSupport.a(d000449.o):(.idata$7+0x0): first defined here
d001474.o:(.idata$2+0x0): multiple definition of `_head_Qt5XmlPatterns_dll'
C:/Qt/Qt5.2.0/5.2.0/mingw48_32/lib/libQt5XmlPatterns.a(d000766.o):(.idata$2+0x0): first defined here
d001665.o:(.idata$7+0x0): multiple definition of `Qt5XmlPatterns_dll_iname'
C:/Qt/Qt5.2.0/5.2.0/mingw48_32/lib/libQt5XmlPatterns.a(d001074.o):(.idata$7+0x0): first defined here
d002086.o:(.idata$2+0x0): multiple definition of `_head_Qt5Test_dll'
C:/Qt/Qt5.2.0/5.2.0/mingw48_32/lib/libQt5Test.a(d000017.o):(.idata$2+0x0): first defined here
d002127.o:(.idata$7+0x0): multiple definition of `Qt5Test_dll_iname'
C:/Qt/Qt5.2.0/5.2.0/mingw48_32/lib/libQt5Test.a(d000182.o):(.idata$7+0x0): first defined here
Cannot export _R_init_qtbase: symbol not defined
Cannot export __Z10_wrapSmokePvPKcb: symbol not defined
Cannot export __Z10init_smokev: symbol not defined
Cannot export __Z10qDeleteAllI14QTestEventListEvRKT_: symbol not defined
Cannot export __Z10qDeleteAllIN5QListIP10QTestEventE14const_iteratorEEvT_S5_: symbol not defined
Cannot export __Z11ptr_to_sexpPvRK9SmokeTypeb: symbol not defined
Cannot export __Z11qMetaTypeIdI10QMatrix4x4Eiv: symbol not defined
Cannot export __Z11qMetaTypeIdI10QTransformEiv: symbol not defined
...
[a huge number (~7000) undefined symbols]
...
Cannot export __ZplRK10QByteArrayS1_: symbol not defined
Cannot export _addQtEventHandler: symbol not defined
Cannot export _app: symbol not defined
Cannot export _cleanupQtApp: symbol not defined
Cannot export _invokeSmokeMethod: symbol not defined
Cannot export _mutex: symbol not defined
Cannot export _qt_qcast: symbol not defined
Cannot export _qt_qclasses: symbol not defined
Cannot export _qt_qconnect: symbol not defined
Cannot export _qt_qdataFrame: symbol not defined
Cannot export _qt_qdataFrameModel: symbol not defined
Cannot export _qt_qeditable: symbol not defined
Cannot export _qt_qenclose: symbol not defined
Cannot export _qt_qenums: symbol not defined
Cannot export _qt_qinitClass: symbol not defined
Cannot export _qt_qinvoke: symbol not defined
Cannot export _qt_qinvokeStatic: symbol not defined
Cannot export _qt_qmetaInvoke: symbol not defined
Cannot export _qt_qmetacall: symbol not defined
Cannot export _qt_qmethods: symbol not defined
Cannot export _qt_qmocMethods: symbol not defined
Cannot export _qt_qnewMetaObject: symbol not defined
Cannot export _qt_qnormalizedSignature: symbol not defined
Cannot export _qt_qparentClasses: symbol not defined
Cannot export _qt_qsetDataFrame: symbol not defined
Cannot export _qt_qsmokes: symbol not defined
Cannot export _qt_quseRoles: symbol not defined
Cannot export _registerSmokeModule: symbol not defined
collect2.exe: error: ld returned 1 exit status
make[3]: *** [qtbase.dll] Error 1
make[2]: *** [CMakeFiles/qtbase.dir/all] Error 2
make[1]: *** [all] Error 2
make: *** [all] Error 2
Warning: running command 'make --no-print-directory -f "Makefile.win"' had status 2

Do you think these linking problems could be related to the missing WIN32 define?
(Maybe, if WIN32 were defined earlier/more globally (but where?), linking would work?)

@lawremi
Copy link
Member

lawremi commented Oct 9, 2014

It looks like we need to play with the sed expression. Those undefined symbols all have an extra _ prepended to them. In src/CMakeLists.txt we use a different sed expression based on whether we are in 32 bit or 64 bit Windows. You seem to be using the 64 bit compiler (as evidenced by WIN32 not being defined, and cmake using that sed expression). The 32 bit expression removes the preceeding _, but the 64 bit one (wrongly?) does not.

For the intiial duplicate symbol problem, try passing VERBOSE=1 to the cmake calls in src/Makefile.common. My guess is that those libs are being included twice on the linker line somehow.

@tsieger
Copy link
Author

tsieger commented Oct 15, 2014

Thanks for the fixes - they seemed to resolve the relevant problems.

For the duplicate symbol problem: it seems that the duplicated symbols come from lib/lib/libQt5* and bin/Qt5* that both appear on the linker command line:

Linking CXX shared library qtbase.dll
"C:/Program Files/CMake 2.8/bin/cmake.exe" -E remove -f CMakeFiles/qtbase.dir/objects.a
C:/Qt/Qt5.2.0/Tools/mingw48_32/bin/ar.exe cr CMakeFiles/qtbase.dir/objects.a @CMakeFiles/qtbase.dir/objects1.rsp
g++   -m32   -shared qtbase.def qtbase.def -shared -o qtbase.dll -Wl,--out-implib,libqtbase.dll.a
 -Wl,--major-image-version,0,--minor-image-version,0 -Wl,--whole-archive
 CMakeFiles/qtbase.dir/objects.a -Wl,--no-whole-archive
 -LC:/src/qtbase-141013-win32-fixes/qtbase/src/../kdebindings-build/smoke/qt
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/lib/libQt5Widgets.a 
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/lib/libQt5Multimedia.a 
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/lib/libQt5MultimediaWidgets.a 
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/lib/libQt5Network.a 
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/lib/libQt5Qml.a 
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/lib/libQt5Quick.a 
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/lib/libQt5Sql.a 
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/lib/libQt5Test.a 
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/lib/libQt5WebKit.a
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/lib/libQt5WebKitWidgets.a
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/lib/libQt5Svg.a
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/lib/libQt5XmlPatterns.a
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/lib/libQt5PrintSupport.a  <<<<<<<<<<<<<<<<<<<<<<<
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/lib/libQt5Help.a
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/lib/libQt5UiTools.a
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/lib/libQt5SerialPort.a
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/lib/libQt5Sensors.a
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/lib/libQt5Bluetooth.a
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/lib/libQt5Positioning.a
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/lib/libQt5Nfc.a 
 -lsmokeqt 
 -LC:/PROGRA~1/R/R-31~1.0/bin//i386 
 -lR
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/bin/Qt5Multimedia.dll
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/bin/Qt5MultimediaWidgets.dll
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/bin/Qt5Network.dll
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/bin/Qt5Qml.dll
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/bin/Qt5Quick.dll
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/bin/Qt5Sql.dll
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/bin/Qt5Test.dll
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/bin/Qt5WebKit.dll
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/bin/Qt5WebKitWidgets.dll
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/bin/Qt5Svg.dll
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/bin/Qt5XmlPatterns.dll
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/bin/Qt5PrintSupport.dll  <<<<<<<<<<<<<<<<<<<<<<<
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/bin/Qt5Help.dll
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/lib/libQt5UiTools.a
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/bin/Qt5SerialPort.dll
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/bin/Qt5Sensors.dll
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/bin/Qt5Bluetooth.dll
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/bin/Qt5Positioning.dll
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/bin/Qt5Nfc.dll
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/lib/libQt5MultimediaWidgets.a
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/lib/libQt5Multimedia.a
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/lib/libQt5Quick.a
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/lib/libQt5WebKit.a
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/lib/libQt5Qml.a
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/lib/libQt5OpenGL.a
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/lib/libQt5Network.a
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/lib/libQt5Widgets.a
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/lib/libQt5Gui.a
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/lib/libQt5Core.a 
 -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32

d001289.o:(.idata$2+0x0): multiple definition of `_head_Qt5PrintSupport_dll'
C:/Qt/Qt5.2.0/5.2.0/mingw48_32/lib/libQt5PrintSupport.a(d000049.o):(.idata$2+0x0): first defined here
d001473.o:(.idata$7+0x0): multiple definition of `Qt5PrintSupport_dll_iname'
C:/Qt/Qt5.2.0/5.2.0/mingw48_32/lib/libQt5PrintSupport.a(d000449.o):(.idata$7+0x0): first defined here
d001474.o:(.idata$2+0x0): multiple definition of `_head_Qt5XmlPatterns_dll'
C:/Qt/Qt5.2.0/5.2.0/mingw48_32/lib/libQt5XmlPatterns.a(d000766.o):(.idata$2+0x0): first defined here
d001665.o:(.idata$7+0x0): multiple definition of `Qt5XmlPatterns_dll_iname'
C:/Qt/Qt5.2.0/5.2.0/mingw48_32/lib/libQt5XmlPatterns.a(d001074.o):(.idata$7+0x0): first defined here
d002086.o:(.idata$2+0x0): multiple definition of `_head_Qt5Test_dll'
C:/Qt/Qt5.2.0/5.2.0/mingw48_32/lib/libQt5Test.a(d000017.o):(.idata$2+0x0): first defined here
d002127.o:(.idata$7+0x0): multiple definition of `Qt5Test_dll_iname'
C:/Qt/Qt5.2.0/5.2.0/mingw48_32/lib/libQt5Test.a(d000182.o):(.idata$7+0x0): first defined here

While I can't list symbols in bin/Qt5PrintSupport.dll (both nm and objudmp say there are no symbols), the _head_Qt5PrintSupport_dll symbol is present in lib/libQt5PrintSupport.a.

Regarding the undefined symbols, I don't think that I'm using 64bit g++. My g++ resides in mingw48_32/bin and an executable it compiles (by default) seems to be 32bit:

a.exe: PE32 executable for MS Windows (console) Intel 80386 32-bit

Also, WIN32 must be defined, otherwise the sed stuff would not even be reached. The reason that the wrong sed pattern gets used is that CMAKE_SIZEOF_VOID_P EQUAL 4 does not hold simply because CMAKE_SIZEOF_VOID_P is not defined at all.
BTW when using the right sed pattern (by putting it into the non-CMAKE_SIZEOF_VOID_P EQUAL 4 branch), the undefined symbols problem goes away.

@lawremi
Copy link
Member

lawremi commented Oct 15, 2014

The .dll files expose their symbols through the .a files, so the duplicate symbol should be in one of the other libs, perhaps even smokeqt.a. That list of libs does include a lot of dupes, which is probably due to all of the manual LIB_LOC manipulation in src/CMakeLists.txt. I can't recall why we put those in there, but they shouldn't be necessary. Maybe try dropping all of that? Another observation is that this only affects certain modules. As a last resort, we could disable support for those modules. I don't think any of them would be missed.

The cmake WIN32 is always defined on Windows, regardless of the bitness. I'm surprised that the documented CMAKE_SIZEOF_VOID_P is undefined. We should be able to get the bitness from R though, so there are easy work-arounds.

@tsieger
Copy link
Author

tsieger commented Oct 16, 2014

Preventing Qt5Test, Qt5PrintSupport, and Qt5XmlPatterns from being added to LIB_LOC in src/CMakeLists.txt led to:

Linking CXX shared library qtbase.dll
"C:/Program Files/CMake 2.8/bin/cmake.exe" -E remove -f CMakeFiles/qtbase.dir/objects.a
C:/Qt/Qt5.2.0/Tools/mingw48_32/bin/ar.exe cr CMakeFiles/qtbase.dir/objects.a @CMakeFiles/qtbase.dir/objects1.rsp
g++   -m32   -shared qtbase.def qtbase.def -shared -o qtbase.dll -Wl,--out-implib,libqtbase.dll.a 
 -Wl,--major-image-version,0,--minor-image-version,0
 -Wl,--whole-archive CMakeFiles/qtbase.dir/objects.a
 -Wl,--no-whole-archive 
 -LC:/src/qtbase-141013-win32-fixes/qtbase/src/../kdebindings-build/smok
 e/qt C:/Qt/Qt5.2.0/5.2.0/mingw48_32/lib/libQt5Widgets.a
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/lib/libQt5Multimedia.a
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/lib/libQt5MultimediaWidgets.a
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/lib/libQt5Network.a
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/lib/libQt5Qml.a
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/lib/libQt5Quick.a
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/lib/libQt5Sql.a
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/lib/libQt5Test.a
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/lib/libQt5WebKit.a
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/lib/libQt5WebKitWidgets.a
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/lib/libQt5Svg.a
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/lib/libQt5XmlPatterns.a
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/lib/libQt5PrintSupport.a
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/lib/libQt5Help.a
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/lib/libQt5UiTools.a
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/lib/libQt5SerialPort.a
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/lib/libQt5Sensors.a
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/lib/libQt5Bluetooth.a
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/lib/libQt5Positioning.a
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/lib/libQt5Nfc.a -lsmokeqt
 -LC:/PROGRA~1/R/R-31~1.0/bin//i386 -lR
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/bin/Qt5Multimedia.dll
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/bin/Qt5MultimediaWidgets.dll
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/bin/Qt5Network.dll
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/bin/Qt5Qml.dll
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/bin/Qt5Quick.dll
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/bin/Qt5Sql.dll
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/bin/Qt5WebKit.dll
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/bin/Qt5WebKitWidgets.dll
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/bin/Qt5Svg.dll
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/bin/Qt5Help.dll
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/lib/libQt5UiTools.a
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/bin/Qt5SerialPort.dll
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/bin/Qt5Sensors.dll
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/bin/Qt5Bluetooth.dll
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/bin/Qt5Positioning.dll
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/bin/Qt5Nfc.dll
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/lib/libQt5MultimediaWidgets.a
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/lib/libQt5Multimedia.a
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/lib/libQt5Quick.a
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/lib/libQt5WebKit.a
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/lib/libQt5Qml.a
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/lib/libQt5OpenGL.a
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/lib/libQt5Network.a
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/lib/libQt5Widgets.a
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/lib/libQt5Gui.a
 C:/Qt/Qt5.2.0/5.2.0/mingw48_32/lib/libQt5Core.a -lkernel32 -luser32
 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32
 -ladvapi32

C:/src/qtbase-141013-win32-fixes/qtbase/src/../kdebindings-build/smoke/qt/libsmokeqt.a(x_1.cpp.obj):x_1.cpp:
 (.text$_ZN20QAbstractPrintDialog2trEPKcS1_i[__ZN20QAbstractPrintDialog2trEPKcS1_i]+0x20): 
 undefined reference to `_imp___ZN20QAbstractPrintDialog16staticMetaObjectE'

C:/src/qtbase-141013-win32-fixes/qtbase/src/../kdebindings-build/smoke/qt/libsmokeqt.a(x_1.cpp.obj):x_1.cpp:
    (.text$_ZN20QAbstractPrintDialog6trUtf8EPKcS1_i[__ZN20QAbstractPrintDialog6trUtf8EPKcS1_i]+0x20): 
    undefined reference to `_imp___ZN20QAbstractPrintDialog16staticMetaObjectE'

c:/qt/qt5.2.0/tools/mingw48_32/bin/../lib/gcc/i686-w64-mingw32/4.8.0/../../../../i686-w64-mingw32/bin/ld.exe: 
 C:/src/qtbase-141013-win32-fixes/qtbase/src/../kdebindings-build/smoke/qt/libsmokeqt.a(x_1.cpp.obj): 
 bad reloc address 0x20 in section `.text$_ZN20QAbstractPrintDialog6trUtf8EPKcS1_i[__ZN20QAbstractPrintDialog6trUtf8EPKcS1_i]'

So I removed all the Qt5Test, Qt5PrintSupport, and Qt5XmlPatterns modules from qt5_optional_use_modules from both src/CMakeLists.txt and kdebindings/smoke/qt/CMakeLists.txt.

Then I could not compile:

[ 12%] Building CXX object CMakeFiles/qtbase.dir/convert.cpp.obj
C:/src/qtbase-141013-win32-fixes/qtbase/src/convert.cpp: In function 'SEXPREC* to_sexp(QMargins)':
C:/src/qtbase-141013-win32-fixes/qtbase/src/convert.cpp:802:6: error: 'margins' has incomplete type
 SEXP to_sexp(QMargins margins) {
      ^
In file included from C:/Qt/Qt5.2.0/5.2.0/mingw48_32/include/QtGui/qpolygon.h:47:0,
                 from C:/Qt/Qt5.2.0/5.2.0/mingw48_32/include/QtGui/QPolygon:1,
                 from C:/src/qtbase-141013-win32-fixes/qtbase/src/convert.cpp:9:
C:/Qt/Qt5.2.0/5.2.0/mingw48_32/include/QtCore/qrect.h:54:7: error: forward declaration of 'class QMargins'
 class QMargins;
       ^
C:/src/qtbase-141013-win32-fixes/qtbase/src/convert.cpp: In function 'SEXPREC* qt_coerce_QMargins(SEXP)':
C:/src/qtbase-141013-win32-fixes/qtbase/src/convert.cpp:894:44: error: invalid use of incomplete type 'class QMargins'
     return to_sexp(*unwrapSmoke(sexp, type));            \
                                            ^
C:/src/qtbase-141013-win32-fixes/qtbase/src/convert.cpp:909:1: note: in expansion of macro 'DEF_COERCE_ENTRY_POINT'
 DEF_COERCE_ENTRY_POINT(QMargins)
 ^
In file included from C:/Qt/Qt5.2.0/5.2.0/mingw48_32/include/QtGui/qpolygon.h:47:0,
                 from C:/Qt/Qt5.2.0/5.2.0/mingw48_32/include/QtGui/QPolygon:1,
                 from C:/src/qtbase-141013-win32-fixes/qtbase/src/convert.cpp:9:
C:/Qt/Qt5.2.0/5.2.0/mingw48_32/include/QtCore/qrect.h:54:7: error: forward declaration of 'class QMargins'
 class QMargins;
       ^
C:/src/qtbase-141013-win32-fixes/qtbase/src/convert.cpp:802:6: error:   initializing argument 1 of 'SEXPREC* to_sexp(QMargins)'
 SEXP to_sexp(QMargins margins) {
      ^

which could be solved by adding #include <QMargins> into src/convert.cpp
(not creating a pull request - not sure what the order of Qt includes is).

Then I compiled and linked, but could not load the library:

The procedure entry point InterlockedCompareExchange@12 could not be located in the DLL libstdc++6.dll

It seemed to have been caused by more versions of Qt installed (even though only 5.2.0 was on the PATH). (I'm persisting all the problems I encounter in order to possibly help others (running into same problems) making qtbase running on windows, or simply to support writing some more detailed installation instructions.)

Finally, I ended with:

Install the project...
"C:/Program Files/CMake 2.8/bin/cmake.exe" -P cmake_install.cmake
-- Install configuration: ""
-- Installing: C:/src/qtbase-141013-win32-fixes/qtbase/src/./qtbase.dll
installing to C:/Program Files/R/R-3.1.0/library/qtbase/libs/i386
** R
** demo
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
Please install Qt from http://ggobi-documentation.googlecode.com/files/qt-4.8.0-win32.zip
Error : .onLoad failed in loadNamespace() for 'qtbase', details:
  call: .Call("qt_qsmokes", PACKAGE = "qtbase")
  error: "qt_qsmokes" not available for .Call() for package "qtbase"

Don't know what it means - shall I download some extra libraries?

What would be the best solution to the Qt modules problem?

@lawremi
Copy link
Member

lawremi commented Oct 20, 2014

For now, we are going to have to just disable those modules on Windows, though we may want to take a close look at how that linker path is constructed (we ended up with something pretty messy). I think the missing symbol at the end is related to the defs file. Does it list qt_qsmokes?

@tsieger
Copy link
Author

tsieger commented Oct 21, 2014

The defs file contained no symbols. The problem was that there were extra 's around the sed expression. In src/CMakeLists.txt, the sed expression is wrapped in 's in one branch, but not the other:

if (CMAKE_SIZEOF_VOID_P EQUAL 4)
  set(SYMPAT "'s/^.* [BCDRT] _/ /p'")
else ()
  set(SYMPAT "/^[^ ]* [T|C|B] /s/^[^ ]* [T|C|B] / /p")
endif()

such that taking the CMAKE_SIZEOF_VOID_P ~= 4 one, the sed expression must have been wrapped in double quotes in mkdef.sh. However, for the CMAKE_SIZEOF_VOID_P == 4 branch, the expression has already been wrapped (and further wrapping led to the error I ran into).

Removing the extra 's helps. I can now build and install qtbase!
(But there is still #28).

@lawremi
Copy link
Member

lawremi commented Oct 21, 2014

Thanks. This is promising. Please submit a PR for anything you've fixed. If there are things that need to be fixed by me, submit a separate issue for each (for example, the fact that you had to disable some modules). I'm going to close this one. Thanks so much for your help!

@lawremi lawremi closed this as completed Oct 21, 2014
tsieger pushed a commit to tsieger/qtbase that referenced this issue Oct 21, 2014
lawremi added a commit that referenced this issue Oct 21, 2014
extra quotes removed, helps with #25
@tsieger
Copy link
Author

tsieger commented Oct 21, 2014

OK, I sent one PR (for the master branch only, not sure if you want to touch the qt4 branch, which could be fixed as well, even though I haven't experienced the problem there) and highlight two issues encountered in #30 and #31.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants