bryanherger / xdrawchem

XDrawChem is a two-dimensional molecule drawing program.
37 stars 11 forks source link

Xdrawchem 1.10: Build error under gcc 5.4.0, qt 5.7.0, openbabel 2.3.2 #3

Closed thegreyshadow closed 7 years ago

thegreyshadow commented 7 years ago

Hi Bryan! Happy new year! Xdrawchem fails to build on my system. Here are the relevant software tools and dependencies: gcc-5.4.0 openbabel 2.3.2 qt 5.7.0

the output is the following:

[eduardo:~/build/slackbuilds/xdrawchem/xdrawchem-1.10.0]$ make
g++ -c -pipe -g -O0 -g3 -Wall -W -D_REENTRANT -DUNIX -DRINGHOME=\"/usr/local/share/xdrawchem\" -DXDC_SERVER=\"http://www.woodsidelabs.com/chemistry\" -DQT_XML_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/lib64/qt/mkspecs/linux-g++ -I. -I/usr/lib64/qt/include/QtCore -I/usr/lib64/qt/include/QtNetwork -I/usr/lib64/qt/include/QtGui -I/usr/lib64/qt/include/QtXml -I/usr/lib64/qt/include -I/usr/include/openbabel-2.0 -I.moc -o .obj/application_ring.o xdrawchem/application_ring.cpp
xdrawchem/application_ring.cpp: In member function ‘QMenu* ApplicationWindow::BuildNewRingMenu()’:
xdrawchem/application_ring.cpp:83:11: error: ‘qInfo’ was not declared in this scope
     qInfo() << "BuildNewRingMenu";
           ^
xdrawchem/application_ring.cpp: In member function ‘void ApplicationWindow::FromNewerRingMenu(QAction*)’:
xdrawchem/application_ring.cpp:409:9: error: ‘qInfo’ was not declared in this scope
   qInfo() << "FromNewerRingMenu() invoked";
         ^
xdrawchem/application_ring.cpp: In member function ‘void ApplicationWindow::setRingAction(QAction*)’:
xdrawchem/application_ring.cpp:418:9: error: ‘qInfo’ was not declared in this scope
   qInfo() << "setRingAction() invoked for action " << action->objectName() << " with data " << action->data();
         ^
Makefile:714: recipe for target '.obj/application_ring.o' failed
make: *** [.obj/application_ring.o] Error 1

I'd appreciate any hint or help.

bryanherger commented 7 years ago

Hi, I think there is a missing include file. Please try the following.

Open xdrawchem/application.h in an editor and add "#include <QtGlobal>" at line 14 as shown here:

#ifndef APPLICATION_H #define APPLICATION_H

#include <QtGlobal> #include <QString> #include <QLabel>

Please let me know if this works so I can add the fix. Please also check that all code compiles; this #include may be missing in other places.

thegreyshadow commented 7 years ago

Hi Bryan!

I did what you suggested and compilation advanced up to a point, but I ran into another error. Below is the output:

g++ -c -pipe -g -O0 -g3 -Wall -W -D_REENTRANT -DUNIX -DRINGHOME=\"/usr/local/share/xdrawchem\" -DXDC_SERVER=\"http://www.woodsidelabs.com/chemistry\" -DQT_XML_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/lib64/qt/mkspecs/linux-g++ -I. -I/usr/lib64/qt/include/QtCore -I/usr/lib64/qt/include/QtNetwork -I/usr/lib64/qt/include/QtGui -I/usr/lib64/qt/include/QtXml -I/usr/lib64/qt/include -I/usr/include/openbabel-2.0 -I.moc -o .obj/application_ring.o xdrawchem/application_ring.cpp
xdrawchem/application_ring.cpp: In member function ‘QMenu* ApplicationWindow::BuildNewRingMenu()’:
xdrawchem/application_ring.cpp:83:11: error: ‘qInfo’ was not declared in this scope
     qInfo() << "BuildNewRingMenu";
           ^
xdrawchem/application_ring.cpp: In member function ‘void ApplicationWindow::FromNewerRingMenu(QAction*)’:
xdrawchem/application_ring.cpp:409:9: error: ‘qInfo’ was not declared in this scope
   qInfo() << "FromNewerRingMenu() invoked";
         ^
xdrawchem/application_ring.cpp: In member function ‘void ApplicationWindow::setRingAction(QAction*)’:
xdrawchem/application_ring.cpp:418:9: error: ‘qInfo’ was not declared in this scope
   qInfo() << "setRingAction() invoked for action " << action->objectName() << " with data " << action->data();
         ^
Makefile:714: recipe for target '.obj/application_ring.o' failed
make: *** [.obj/application_ring.o] Error 1

Thanks!!

bryanherger commented 7 years ago

Does it help to place the #include <QtGlobal> at the top of the xdrawchem/application_ring.cpp file?

Also, could you verify qmake version with qmake -version ? Thanks!

thegreyshadow commented 7 years ago

I placed the #include on application_ring.cpp and now compilation proceeded much further.

I had to edit the Makefile to include among the CXXFLAGS the -std=c+11 flag because I was compiling with qt 5.7.0

This is my qmake-qt5 output:

[eduardo:~/build/slackbuilds/xdrawchem/xdrawchem-1.10.0]$ qmake-qt5 --version
QMake version 3.0
Using Qt version 5.7.0 in /usr/lib64

And now compilation stops with this error:

g++ -c -pipe -g -O0 -std=c++11 -g3 -Wall -W -D_REENTRANT -fPIC -DUNIX -DRINGHOME=\"/usr/local/share/xdrawchem\" -DXDC_SERVER=\"http://www.woodsidelabs.com/chemistry\" -DQT_PRINTSUPPORT_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_XML_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -I. -I/usr/include/openbabel-2.0 -I/usr/include/qt5 -I/usr/include/qt5/QtPrintSupport -I/usr/include/qt5/QtWidgets -I/usr/include/qt5/QtGui -I/usr/include/qt5/QtXml -I/usr/include/qt5/QtNetwork -I/usr/include/qt5/QtCore -I.moc -I/usr/lib64/qt5/mkspecs/linux-g++ -o .obj/http.o xdrawchem/http.cpp
xdrawchem/http.cpp:31:56: warning: unused parameter ‘e’ [-Wunused-parameter]
 void HTTP::slotError(const QNetworkReply::NetworkError e)
                                                        ^
xdrawchem/http.cpp: In member function ‘void HTTP::execute(QString)’:
xdrawchem/http.cpp:53:62: error: ‘sleep’ was not declared in this scope
         while (!finished) { qDebug() << "Waiting..."; sleep(1); }
                                                              ^
Makefile:10739: recipe for target '.obj/http.o' failed
make: *** [.obj/http.o] Error 1

Thanks again for your help. Best regards,

Eduardo

bryanherger commented 7 years ago

Hi, I thought I removed that from the source code. Please edit xdrawchem/http.cpp to remove the sleep(1); statement as that code can't be reached anyways.

bryanherger commented 7 years ago

Also for newer compiler than gcc4, it might help to edit xdrawchem.pro and comment out these lines (lines 32-33, I think) as shown, as these override some settings for C++11 on gcc:

//QMAKE_CXXFLAGS_GNUCXX11 = //QMAKE_CXXFLAGS_CXX11 =

thegreyshadow commented 7 years ago

Removed sleep(1); in http.cpp, line 53. Commented out the relevant settings you mentioned in lines 32-33 of xdrawchem.pro.

SUCCESS!!

Now xdrawchem compiled flawlessly. Attached proof ;)

image

If I could suggest something, I would ask for a new release with these changes. In order to build a package I would need to compile it from pristine sources, and I suck at creating patches.

Thanks! Closing the issue since it was thoroughly solved.

bryanherger commented 7 years ago

Excellent, thanks for helping! I made a new source release and posted to SourceForge:

https://sourceforge.net/projects/xdrawchem/files/xdrawchem/1.10.1/