[Qt 5.1.0] utiliser le protocole FTP

Fermé
twiiiix Messages postés 325 Date d'inscription jeudi 14 janvier 2010 Statut Membre Dernière intervention 25 janvier 2014 - 29 juil. 2013 à 23:36
twiiiix Messages postés 325 Date d'inscription jeudi 14 janvier 2010 Statut Membre Dernière intervention 25 janvier 2014 - 30 juil. 2013 à 10:43
Bonjour,

Je me suis lancé dans le développement d'une application permettant la synchronisation automatique de mes fichiers sur un serveur FTP. J'utilise Qt 5.1.0 compilé, sous windows, avec MinGW (g++ 4.7.2). Sur les versions précédentes, il existait une classe QFtp qui permettait de se connecter à un serveur FTP et d'envoyer certaines commandes (list, mkdir, rmdir) facilement. Cependant cette classe n'existe plus.

J'ai essayé d'utiliser QNetworkRequest et QNetworkAccessManager, mais je ne vois pas comment envoyer des commandes au serveur.

J'ai vu que l'on pouvait télécharger QtFTP séparément, ce que j'ai fait. J'ai extrait le contenu de l'archive, executé qmake et mingw32-make. Mais la compilation échoue avec :

cd src\ && ( if not exist Makefile E:\Qt\5.1.0\qtbase\bin\qmake.exe E:\qt-qtftp\src\src.pro -o Makefile ) && mingw32-make -f Makefile
mingw32-make[1]: Entering directory 'E:/qt-qtftp/src'
cd qftp\ && ( if not exist Makefile E:\Qt\5.1.0\qtbase\bin\qmake.exe E:\qt-qtftp\src\qftp\qftp.pro -o Makefile ) && mingw32-make -f Makefile
mingw32-make[2]: Entering directory 'E:/qt-qtftp/src/qftp'
mingw32-make -f Makefile.Debug all
mingw32-make[3]: Entering directory 'E:/qt-qtftp/src/qftp'
E:\Qt\5.1.0\qtbase\bin\moc.exe -DUNICODE -DQT_BUILD_FTP_LIB -DQT_BUILDING_QT -DQT_NO_CAST_TO_ASCII -DQT_ASCII_CAST_WARNINGS -DQT_MOC_COMPAT -DQT_USE_QSTRINGBUILDER -DQT_DEPRECATED_WARNINGS -DQT_DISABLE_DEPRECATED_BEFORE=0x040800 -D_USE_MATH_DEFINES -DQT_NO_EXCEPTIONS -DQT_NETWORK_LIB -DQT_CORE_LIB -D__GNUC__ -DWIN32 -I. -I"E:\MySQL\include" -I"E:\SQLite" -I"E:\qt-qtftp\include" -I"E:\qt-qtftp\include\QtFtp" -I"E:\Qt\5.1.0\qtbase\include" -I"E:\Qt\5.1.0\qtbase\include\QtFtp" -I"E:\qt-qtftp\include\QtFtp\5.0.0" -I"E:\qt-qtftp\include\QtFtp\5.0.0\QtFtp" -I"tmp" -I"E:\Qt\5.1.0\qtbase\include\QtNetwork" -I"E:\Qt\5.1.0\qtbase\include\QtCore" -I".moc\debug_shared" -I"E:\Qt\5.1.0\qtbase\mkspecs\win32-g++" qftp.h -o .moc\debug_shared\moc_qftp.cpp
E:\Qt\5.1.0\qtbase\bin\moc.exe -DUNICODE -DQT_BUILD_FTP_LIB -DQT_BUILDING_QT -DQT_NO_CAST_TO_ASCII -DQT_ASCII_CAST_WARNINGS -DQT_MOC_COMPAT -DQT_USE_QSTRINGBUILDER -DQT_DEPRECATED_WARNINGS -DQT_DISABLE_DEPRECATED_BEFORE=0x040800 -D_USE_MATH_DEFINES -DQT_NO_EXCEPTIONS -DQT_NETWORK_LIB -DQT_CORE_LIB -D__GNUC__ -DWIN32 -I. -I"E:\MySQL\include" -I"E:\SQLite" -I"E:\qt-qtftp\include" -I"E:\qt-qtftp\include\QtFtp" -I"E:\Qt\5.1.0\qtbase\include" -I"E:\Qt\5.1.0\qtbase\include\QtFtp" -I"E:\qt-qtftp\include\QtFtp\5.0.0" -I"E:\qt-qtftp\include\QtFtp\5.0.0\QtFtp" -I"tmp" -I"E:\Qt\5.1.0\qtbase\include\QtNetwork" -I"E:\Qt\5.1.0\qtbase\include\QtCore" -I".moc\debug_shared" -I"E:\Qt\5.1.0\qtbase\mkspecs\win32-g++" qftp.cpp -o .moc\debug_shared\qftp.moc
g++ -c -pipe -fno-keep-inline-dllexport -g -std=c++0x -fno-exceptions -frtti -Wall -Wextra -DUNICODE -DQT_BUILD_FTP_LIB -DQT_BUILDING_QT -DQT_NO_CAST_TO_ASCII -DQT_ASCII_CAST_WARNINGS -DQT_MOC_COMPAT -DQT_USE_QSTRINGBUILDER -DQT_DEPRECATED_WARNINGS -DQT_DISABLE_DEPRECATED_BEFORE=0x040800 -D_USE_MATH_DEFINES -DQT_NO_EXCEPTIONS -DQT_NETWORK_LIB -DQT_CORE_LIB -I. -I"E:\MySQL\include" -I"E:\SQLite" -I"E:\qt-qtftp\include" -I"E:\qt-qtftp\include\QtFtp" -I"E:\Qt\5.1.0\qtbase\include" -I"E:\Qt\5.1.0\qtbase\include\QtFtp" -I"E:\qt-qtftp\include\QtFtp\5.0.0" -I"E:\qt-qtftp\include\QtFtp\5.0.0\QtFtp" -I"tmp" -I"E:\Qt\5.1.0\qtbase\include\QtNetwork" -I"E:\Qt\5.1.0\qtbase\include\QtCore" -I".moc\debug_shared" -I"E:\Qt\5.1.0\qtbase\mkspecs\win32-g++" -o .obj\debug_shared\qftp.o qftp.cpp
g++ -c -pipe -fno-keep-inline-dllexport -g -std=c++0x -fno-exceptions -frtti -Wall -Wextra -DUNICODE -DQT_BUILD_FTP_LIB -DQT_BUILDING_QT -DQT_NO_CAST_TO_ASCII -DQT_ASCII_CAST_WARNINGS -DQT_MOC_COMPAT -DQT_USE_QSTRINGBUILDER -DQT_DEPRECATED_WARNINGS -DQT_DISABLE_DEPRECATED_BEFORE=0x040800 -D_USE_MATH_DEFINES -DQT_NO_EXCEPTIONS -DQT_NETWORK_LIB -DQT_CORE_LIB -I. -I"E:\MySQL\include" -I"E:\SQLite" -I"E:\qt-qtftp\include" -I"E:\qt-qtftp\include\QtFtp" -I"E:\Qt\5.1.0\qtbase\include" -I"E:\Qt\5.1.0\qtbase\include\QtFtp" -I"E:\qt-qtftp\include\QtFtp\5.0.0" -I"E:\qt-qtftp\include\QtFtp\5.0.0\QtFtp" -I"tmp" -I"E:\Qt\5.1.0\qtbase\include\QtNetwork" -I"E:\Qt\5.1.0\qtbase\include\QtCore" -I".moc\debug_shared" -I"E:\Qt\5.1.0\qtbase\mkspecs\win32-g++" -o .obj\debug_shared\qurlinfo.o qurlinfo.cpp
ar -ru E:\Qt\5.1.0\qtbase\lib\libQt5Ftpd.a .obj/debug_shared/qftp.o .obj/debug_shared/qurlinfo.o
mingw32-make[3]: Leaving directory 'E:/qt-qtftp/src/qftp'
mingw32-make -f Makefile.Release all
mingw32-make[3]: Entering directory 'E:/qt-qtftp/src/qftp'
E:\Qt\5.1.0\qtbase\bin\moc.exe -DUNICODE -DQT_BUILD_FTP_LIB -DQT_BUILDING_QT -DQT_NO_CAST_TO_ASCII -DQT_ASCII_CAST_WARNINGS -DQT_MOC_COMPAT -DQT_USE_QSTRINGBUILDER -DQT_DEPRECATED_WARNINGS -DQT_DISABLE_DEPRECATED_BEFORE=0x040800 -D_USE_MATH_DEFINES -DQT_NO_EXCEPTIONS -DQT_NO_DEBUG -DQT_NETWORK_LIB -DQT_CORE_LIB -D__GNUC__ -DWIN32 -I. -I"E:\MySQL\include" -I"E:\SQLite" -I"E:\qt-qtftp\include" -I"E:\qt-qtftp\include\QtFtp" -I"E:\Qt\5.1.0\qtbase\include" -I"E:\Qt\5.1.0\qtbase\include\QtFtp" -I"E:\qt-qtftp\include\QtFtp\5.0.0" -I"E:\qt-qtftp\include\QtFtp\5.0.0\QtFtp" -I"tmp" -I"E:\Qt\5.1.0\qtbase\include\QtNetwork" -I"E:\Qt\5.1.0\qtbase\include\QtCore" -I".moc\release_shared" -I"E:\Qt\5.1.0\qtbase\mkspecs\win32-g++" qftp.h -o .moc\release_shared\moc_qftp.cpp
E:\Qt\5.1.0\qtbase\bin\moc.exe -DUNICODE -DQT_BUILD_FTP_LIB -DQT_BUILDING_QT -DQT_NO_CAST_TO_ASCII -DQT_ASCII_CAST_WARNINGS -DQT_MOC_COMPAT -DQT_USE_QSTRINGBUILDER -DQT_DEPRECATED_WARNINGS -DQT_DISABLE_DEPRECATED_BEFORE=0x040800 -D_USE_MATH_DEFINES -DQT_NO_EXCEPTIONS -DQT_NO_DEBUG -DQT_NETWORK_LIB -DQT_CORE_LIB -D__GNUC__ -DWIN32 -I. -I"E:\MySQL\include" -I"E:\SQLite" -I"E:\qt-qtftp\include" -I"E:\qt-qtftp\include\QtFtp" -I"E:\Qt\5.1.0\qtbase\include" -I"E:\Qt\5.1.0\qtbase\include\QtFtp" -I"E:\qt-qtftp\include\QtFtp\5.0.0" -I"E:\qt-qtftp\include\QtFtp\5.0.0\QtFtp" -I"tmp" -I"E:\Qt\5.1.0\qtbase\include\QtNetwork" -I"E:\Qt\5.1.0\qtbase\include\QtCore" -I".moc\release_shared" -I"E:\Qt\5.1.0\qtbase\mkspecs\win32-g++" qftp.cpp -o .moc\release_shared\qftp.moc
g++ -c -pipe -fno-keep-inline-dllexport -O2 -std=c++0x -fno-exceptions -frtti -Wall -Wextra -DUNICODE -DQT_BUILD_FTP_LIB -DQT_BUILDING_QT -DQT_NO_CAST_TO_ASCII -DQT_ASCII_CAST_WARNINGS -DQT_MOC_COMPAT -DQT_USE_QSTRINGBUILDER -DQT_DEPRECATED_WARNINGS -DQT_DISABLE_DEPRECATED_BEFORE=0x040800 -D_USE_MATH_DEFINES -DQT_NO_EXCEPTIONS -DQT_NO_DEBUG -DQT_NETWORK_LIB -DQT_CORE_LIB -I. -I"E:\MySQL\include" -I"E:\SQLite" -I"E:\qt-qtftp\include" -I"E:\qt-qtftp\include\QtFtp" -I"E:\Qt\5.1.0\qtbase\include" -I"E:\Qt\5.1.0\qtbase\include\QtFtp" -I"E:\qt-qtftp\include\QtFtp\5.0.0" -I"E:\qt-qtftp\include\QtFtp\5.0.0\QtFtp" -I"tmp" -I"E:\Qt\5.1.0\qtbase\include\QtNetwork" -I"E:\Qt\5.1.0\qtbase\include\QtCore" -I".moc\release_shared" -I"E:\Qt\5.1.0\qtbase\mkspecs\win32-g++" -o .obj\release_shared\qftp.o qftp.cpp
g++ -c -pipe -fno-keep-inline-dllexport -O2 -std=c++0x -fno-exceptions -frtti -Wall -Wextra -DUNICODE -DQT_BUILD_FTP_LIB -DQT_BUILDING_QT -DQT_NO_CAST_TO_ASCII -DQT_ASCII_CAST_WARNINGS -DQT_MOC_COMPAT -DQT_USE_QSTRINGBUILDER -DQT_DEPRECATED_WARNINGS -DQT_DISABLE_DEPRECATED_BEFORE=0x040800 -D_USE_MATH_DEFINES -DQT_NO_EXCEPTIONS -DQT_NO_DEBUG -DQT_NETWORK_LIB -DQT_CORE_LIB -I. -I"E:\MySQL\include" -I"E:\SQLite" -I"E:\qt-qtftp\include" -I"E:\qt-qtftp\include\QtFtp" -I"E:\Qt\5.1.0\qtbase\include" -I"E:\Qt\5.1.0\qtbase\include\QtFtp" -I"E:\qt-qtftp\include\QtFtp\5.0.0" -I"E:\qt-qtftp\include\QtFtp\5.0.0\QtFtp" -I"tmp" -I"E:\Qt\5.1.0\qtbase\include\QtNetwork" -I"E:\Qt\5.1.0\qtbase\include\QtCore" -I".moc\release_shared" -I"E:\Qt\5.1.0\qtbase\mkspecs\win32-g++" -o .obj\release_shared\qurlinfo.o qurlinfo.cpp
ar -ru E:\Qt\5.1.0\qtbase\lib\libQt5Ftp.a .obj/release_shared/qftp.o .obj/release_shared/qurlinfo.o
mingw32-make[3]: Leaving directory 'E:/qt-qtftp/src/qftp'
mingw32-make[2]: Leaving directory 'E:/qt-qtftp/src/qftp'
mingw32-make[1]: Leaving directory 'E:/qt-qtftp/src'
cd examples\ && ( if not exist Makefile E:\Qt\5.1.0\qtbase\bin\qmake.exe E:\qt-qtftp\examples\examples.pro -o Makefile ) && mingw32-make -f Makefile
mingw32-make[1]: Entering directory 'E:/qt-qtftp/examples'
cd qftp\ && ( if not exist Makefile E:\Qt\5.1.0\qtbase\bin\qmake.exe E:\qt-qtftp\examples\qftp\qftp.pro -o Makefile ) && mingw32-make -f Makefile
mingw32-make[2]: Entering directory 'E:/qt-qtftp/examples/qftp'
mingw32-make -f Makefile.Debug
mingw32-make[3]: Entering directory 'E:/qt-qtftp/examples/qftp'
g++ -c -pipe -fno-keep-inline-dllexport -g -fno-exceptions -frtti -Wall -Wextra -DUNICODE -DQT_NO_EXCEPTIONS -DQT_FTP_LIB -DQT_WIDGETS_LIB -DQT_NETWORK_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_NEEDS_QMAIN -I. -I"E:\MySQL\include" -I"E:\SQLite" -I"E:\qt-qtftp\include" -I"E:\qt-qtftp\include\QtFtp" -I"E:\Qt\5.1.0\qtbase\include" -I"E:\Qt\5.1.0\qtbase\include\QtFtp" -I"E:\Qt\5.1.0\qtbase\include\QtWidgets" -I"E:\Qt\5.1.0\qtbase\include\QtNetwork" -I"E:\Qt\5.1.0\qtbase\include\QtGui" -I"E:\Qt\5.1.0\qtbase\include\QtCore" -I".moc\debug_shared" -I"E:\Qt\5.1.0\qtbase\mkspecs\win32-g++" -o .obj\debug_shared\ftpwindow.o ftpwindow.cpp
Makefile.Debug:1281: recipe for target '.obj/debug_shared/ftpwindow.o' failed
mingw32-make[3]: Leaving directory 'E:/qt-qtftp/examples/qftp'
Makefile:34: recipe for target 'debug' failed
mingw32-make[2]: Leaving directory 'E:/qt-qtftp/examples/qftp'
Makefile:38: recipe for target 'sub-qftp-make_first' failed
mingw32-make[1]: Leaving directory 'E:/qt-qtftp/examples'
Makefile:65: recipe for target 'sub-examples-make_first' failed
ftpwindow.cpp:43:17: erreur fatale: QtFtp : No such file or directory
compilation terminée.
mingw32-make[3]: *** [.obj/debug_shared/ftpwindow.o] Error 1
mingw32-make[2]: *** [debug] Error 2
mingw32-make[1]: *** [sub-qftp-make_first] Error 2
mingw32-make: *** [sub-examples-make_first] Error 2


J'ai réussi à utiliser libcurl avec Qt, mais cette solution ne me semble vraiment pas adaptée...

Est-il possible d'utiliser QNetworkAccessManager et QNetworkRequest ?

Pourquoi QFtp ne veut pas compiler ?

Existe-il une solution alternative (à part utiliser Qt4)?

Je sais que ça fait beaucoup de questions mais je commence à désespérer.

Merci d'avance pour votre aide.
A voir également:

1 réponse

Char Snipeur Messages postés 9696 Date d'inscription vendredi 23 avril 2004 Statut Contributeur Dernière intervention 3 octobre 2023 1 297
30 juil. 2013 à 08:30
Salut
Un début de réponse là:
https://forum.qt.io/topic/23122/qt5-and-qftp
Sinon, il faut se pencher sur le QnetworkRequest.
0
twiiiix Messages postés 325 Date d'inscription jeudi 14 janvier 2010 Statut Membre Dernière intervention 25 janvier 2014 54
30 juil. 2013 à 10:43
Merci. Mais je suis déjà tombé la dessus, je vois comment télécharger et uploader un fichier avec QNetworkRequest, mais pas comment envoyer des commandes au serveur (MKD, RMD, list, etc...)
C'est pour ça que j'ai essayé de compiler QFtp, mais sans succès...
0