Dear Dr. David Grayson, and All,
hello,
 
thank you for your answer. i deleted a static part of Qt5 using the command,
pacman -R mingw-w64-x86_64-qt5-static
 
then re-installed qt5 using the command
pacman -S mingw-w64-x86_64-qt5
 
now, i try to compile an example1b.cpp demonstrated below, using the command,
g++ -o example1b.exe example1b.cpp -I/C:/msys64/mingw64/include/QtCore -L/C:/msys64/mingw64/bin -lQt5Core.dll -fPIC

and, also,
 
g++ -o example1b.exe example1b.cpp -I/C:/msys64/mingw64/include/QtCore -lQt5Core -fPIC
 
and, also,
 
g++ -o example1b.exe example1b.cpp -I/C:/msys64/mingw64/include/QtCore -L/C:/msys64/mingw64/bin -lQt5Core -fPIC
 
the example1b is compiled (in all three cases) without error messages.
however, when i run it (in the console) using the command "./example1b.exe" nothing is happened, that is, for example, "Hello, World !" line does not appear in the console.
 
i would appreciate someone's help in the Forum to solve this issues related to Qt5, and Msys2-Mingw64.
 
Thank you.
 
---------------------------
example1b.cpp
---------------------------
#include<stdio.h>
#include <QtCore>
#include <iostream>
 
int main() {
 
printf("Hello, World ! \n");
 
std::cout << "Qt version: ... " << "\n" << std::endl;
 
std::cout << "Qt version: " << qVersion() << std::endl;
 
}
 
 
 
 
26.07.2020, 21:36, "David Grayson" <davidegray...@gmail.com>:
Looking at the GCC command you issued in example 1, it looks like you are using pieces of the regular qt5 package and also pieces of the qt5-static package.  You should decide which package you want to use and then just stick to using only that one package.  It might be a good idea to uninstall the other package just so you don't get confused.  Specifically, it looks like you are using the "Qt5Core" include directory from the regular Qt5 package, which would probably define qVersion to a be function imported from a DLL.  But then at link time you are actually linking to the static version of Qt, which means qVersion would be a function that comes from a static library, not a DLL.
 
--David 
 
On Sun, Jul 26, 2020 at 8:07 AM Il'dar Al'Miev <ialm...@yandex.ru> wrote:
Dear All,
hello,
 
Windows 7 (64-bit), Msys2-Mingw64 are installed in my computer.
i installed Qt using the command,
pacman -S mingw-w64-x86_64-qt-creator
and
pacman -S mingw-w64-x86_64-qt
 
i am a newbie in Qt programming. i discovered two examples in Internet.
 
example1.cpp
---------------------------------------
#include <QtCore>

#include <iostream>

int main() {

std::cout << "Qt version: " << qVersion() << std::endl;
}
 
in order to compile the example1.cpp, i used a command found in Internet,

g++ -o example1.exe example1.cpp -I/C:/msys64/mingw64/include/QtCore -I/C:/msys64/mingw64/qt5-static/include/QtCore -L/C:/msys64/mingw64/qt5-static/lib -lQt5Core -fPIC

however, compilation comes with an error message,

C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\msys64\tmp\ccpq7uZL.o:my_qt_program2.cpp:(.text+0x2c): undefined reference to `__imp_qVersion'
collect2.exe: error: ld returned 1 exit status

 

may be i have not installed all Qt-packages required in Msys2-Mingw64 ?

 

example2.cpp

-----------------------------

#include <QApplication>
#include <QWidget>

int main(int argc, char *argv[]) {

QApplication app(argc, argv);

QWidget window;

window.resize(250, 150);
window.setWindowTitle("Simple example");
window.show();

return app.exec();
}
 
that file i saved in a separate directory, and as it was recomended in Internet i used the following commands,

qmake -project
qmake
make

 

after that the separate directory "release" was created (inside), where the executable "example2.exe" was created. however, when i try to execute that file in Mingw64 console, nothing is happened, that is the windows "Simple example" does not appear.

 

i would appreciate someone(s) in the Forum to explain me, where i made a compilation error; or it is associated with Mingw64-Msys2 ?

 
Thank you.
_______________________________________________
Msys2-users mailing list
Msys2-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/msys2-users
 
 
_______________________________________________
Msys2-users mailing list
Msys2-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/msys2-users

Reply via email to