-
Notifications
You must be signed in to change notification settings - Fork 69
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
make this project Qt - compatible. #26
Comments
I guess you are using QMake and not CMake, so for the LINUX or WINDOWS macros, you can define them in the .pro file (google for the win32/unix qmake directives). |
So this code basically checks if QT_CORE_LIB is defined (it is defined by qmake), Yes i know i can do it in *.pro file, but as i added your files directly to my project source tree So it is like more local solution, applicable to this file only. If you feel it is not needed, just close the issue :) |
A better solution is to get rid off the macros WINDOWS and LINUX and use Visual Studio macro for Windows (and MinGW) and a GCC macro for Linux. There's plenty of project on github (e.g. libmodbus) that uses compilers macros to detect the platform. |
Don't know if it's correct list, but here what i found:
|
I'm also interested in Qt support, don't think I could help though. |
@nicmorais What build system do you use ? CMake or qmake ? Qt is now fully supporting CMake and will not use qmake in the future (CMake will be the default build system for Qt). You can use CMake's add_subdirectory to include ftpclient to the build and then use target_link_libraries to link the library to your output program. The problem with learning CMake is that there is the old one and the modern one (aim for the modern CMake). I think it's better to always use the same build system in your C++ projects. If you are a C++ developer, knowing CMake is a very valuable asset. I don't really like it (it's complex and the script language is ugly, it sucks like the other Kitware products I have already worked with such as VTK and ParaView), but it's becoming the de-facto build system for C++ projects. Like git or the C++ language, if you stick to a small subset, everything will be fine 😆 |
Hello @embeddedmz Am I doing something wrong? Thanks in advance for your effort. |
@nicmorais if you search the web for this error, you will see that it's because GetProgressFnCallback definition works only with C++14, what you can do is to change auto to "ProgressFnCallback" (which is an alias of std::function<int(void *, double, double, double, double)>). In fact CMake is a script build generator (it can generate GNU/Linux Makefiles, solutions for Visual Studio etc...). |
@embeddedmz Thanks a lot, I'm almost there. Now it says: I tried changing the return type to void as an workaround, but there are more errors |
@nicmorais You are trying to compile some parts that should be hidden with "#ifdef WINDOWS" WINDOWS macro should not be defined ! I added some helpers for Windows users to be able to handle file names correctly because under Windows, file names are not encoded in UTF-8 unlike on GNU/Linux systems. If you read the CMakeLists.txt, you will see that this macro is only enabled when using CMake to generate a Visual Studio solution. I hope it's clear, what you can do is discard all the code that requires that "WINDOWS" preprocessor macro is defined. Please ensure that this macro is not defined. |
And be careful when using this library with Qt (thread safety concerns) ! I have already made a discussion here : #27 |
@embeddedmz So, that's what I've tried here, now I'm able to build it separately under Qt Creator. I'm trying to figure out how to add the library to a project and build them. Once again, thanks a lot for your help! |
I change GCC
|
use this typedef : You can get the meaning of this last using https://cdecl.org/
it was not easy to find the type definition, I used this code to find the answer :
C++ is a pain in this ass. If you want, in your fork you can get rid of std::function and use a simple function pointer. std::function offers more security at compile time, that's why I used it but it's better to keep things stupid simple. |
@embeddedmz |
You can add on top of FTPClient.h, right after FTPCLIENT_VERSION define:
#ifdef QT_CORE_LIB #include <QtGlobal> #ifdef Q_OS_LINUX #define LINUX #endif #ifdef Q_OS_WINDOWS #define WINDOWS #endif #endif
The text was updated successfully, but these errors were encountered: