www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Trying to link to Qt 5 on dmd 2.068.0~beta1

reply Shriramana Sharma via Digitalmars-d <digitalmars-d puremagic.com> writes:
Trying to compile the attached program to test DMD 2.068's promised
C++ interfacing capabilities:

$ dmd qt.d -L-L/usr/share/x86_64-linux-gnu -L-lQt5Core -L-lQt5Gui
qt.o:(.rodata+0x40): undefined reference to `QWidget::show()'
qt.o: In function `_Dmain':
qt.d:(.text._Dmain+0x3b): undefined reference to
`QApplication::__ctor(int&, char**)'
qt.d:(.text._Dmain+0x4f): undefined reference to `QApplication::exec()'
collect2: error: ld returned 1 exit status
--- errorlevel 1

Seems like I'm doing something hopelessly wrong. Please enlighten.
Also, please specifically review my hastily put-together argv(string[]
args) function...

I'm using Kubuntu Trusty 64 bit.

--=20
Shriramana Sharma =E0=AE=B6=E0=AF=8D=E0=AE=B0=E0=AF=80=E0=AE=B0=E0=AE=AE=E0=
=AE=A3=E0=AE=B6=E0=AE=B0=E0=AF=8D=E0=AE=AE=E0=AE=BE =E0=A4=B6=E0=A5=8D=E0=
=A4=B0=E0=A5=80=E0=A4=B0=E0=A4=AE=E0=A4=A3=E0=A4=B6=E0=A4=B0=E0=A5=8D=E0=A4=
=AE=E0=A4=BE
Jul 20 2015
parent "John Colvin" <john.loughran.colvin gmail.com> writes:
On Monday, 20 July 2015 at 16:03:03 UTC, Shriramana Sharma wrote:
 Trying to compile the attached program to test DMD 2.068's 
 promised C++ interfacing capabilities:

 $ dmd qt.d -L-L/usr/share/x86_64-linux-gnu -L-lQt5Core 
 -L-lQt5Gui
 qt.o:(.rodata+0x40): undefined reference to `QWidget::show()'
 qt.o: In function `_Dmain':
 qt.d:(.text._Dmain+0x3b): undefined reference to
 `QApplication::__ctor(int&, char**)'
 qt.d:(.text._Dmain+0x4f): undefined reference to 
 `QApplication::exec()'
 collect2: error: ld returned 1 exit status
 --- errorlevel 1

 Seems like I'm doing something hopelessly wrong. Please 
 enlighten. Also, please specifically review my hastily 
 put-together argv(string[] args) function...

 I'm using Kubuntu Trusty 64 bit.
I don't know much about the C++ interface but Qt is a massive, complicated library. Have you tried some simple examples with C++ code you've written yourself? Just guessing here, but those class definitions don't inherit from anything (e.g. QApplication should perhaps inherit from QGUIApplication which inherits from QCoreApplication which inherits from QObject) so maybe that is a problem? Also exec is a static member function.
Jul 20 2015