Qt MinGW and NXT++
-
Hello everybody,
I am trying to use NXT++ with Qt to control LEGO Mindstorms robot.
I've downloaded it "here":https://github.com/dbworth/nxt-plus-plus .Unfortunately it has been designed for Visual C++ so I tried to edit it for classic C++ (MinGW).
There are changes I did:
- .pro file
@
added HEADERS and SOURCES
SOURCES += main.cpp
src/comm.cpp
src/nxt++.cppHEADERS += include/comm.h
include/NXT++.h
include/visatype.h
include/fantom/iFile.h
include/fantom/iFileIterator.h
include/fantom/iModule.h
include/fantom/iModuleIterator.h
include/fantom/iNXT.h
include/fantom/iNXTIterator.h
include/fantom/platform.h
include/fantom/tStatus.hinstead of #pragma comment (lib, "lib/fantom.lib" ) added
win32: LIBS += -L$$PWD/lib/ -lfantom
INCLUDEPATH += $$PWD/include
DEPENDPATH += $$PWD/includewin32: PRE_TARGETDEPS += $$PWD/lib/fantom.lib
instead of #include "stdafx.h" in nxt++.cpp and comm.cpp
PRECOMPILED_HEADER += stdafx.h
@
- platform.h (there are platform-related defines)
original
@
/*!
\file platform.h
\brief This file contains platform-related defines.
/
/
© Copyright 2005,
National Instruments Corporation.
All rights reserved.File: platform.h
Originated: 23 June 2005
*/#ifndef fantom_platform_h
#define fantom_platform_h#ifndef VISATYPE_HEADER
#include "visatype.h"
#endif#define nFANTOM100_kOSMacOSX 0
#define nFANTOM100_kOSWin32 0#define nFANTOM100_kProcessorI386 0
#define nFANTOM100_kProcessorPPC 0#define nFANTOM100_kCompilerMSVC 0
#define nFANTOM100_kCompilerApple 0#if (( defined( GNUG ) || defined( GNUC )) && defined( APPLE ))
#undef nFANTOM100_kOSMacOSX
#define nFANTOM100_kOSMacOSX 1#undef nFANTOM100_kCompilerApple
#define nFANTOM100_kCompilerApple ( GNUC * 10000
+ GNUC_MINOR * 100
+ GNUC_PATCHLEVEL )#if ( defined( ppc ))
#undef nFANTOM100_kProcessorPPC
#define nFANTOM100_kProcessorPPC 1#define nFANTOM100_kBigEndian 1 #define nFANTOM100_kLittleEndian 0
#elif ( defined( i386 ))
#undef nFANTOM100_kProcessorI386
#define nFANTOM100_kProcessorI386 1#define nFANTOM100_kBigEndian 0 #define nFANTOM100_kLittleEndian 1
#else
#error Unknown processor.
#endif#ifdef nFANTOM100_kExportSymbols
#define nFANTOM100_kExport attribute ((section ("__TEXT,__export")))
#else
#define nFANTOM100_kExport
#endif#elif ( defined( _MSC_VER ) && ( defined( _M_IX86 ) || defined( _M_I86 )))
#undef nFANTOM100_kOSWin32
#define nFANTOM100_kOSWin32 1#undef nFANTOM100_kCompilerMSVC
#define nFANTOM100_kCompilerMSVC _MSC_VER#undef nFANTOM100_kProcessorI386
#define nFANTOM100_kProcessorI386 1#ifdef nFANTOM100_kExportSymbols
#define nFANTOM100_kExport __declspec(dllexport)
#else
#define nFANTOM100_kExport __declspec(dllimport)
#endif#define nFANTOM100_kBigEndian 0
#define nFANTOM100_kLittleEndian 1#else
#error Unknown platform. // when i tried to compile, always ends here
#endif
#endif // fantom_platform_h
@edited
@
/*!
\file platform.h
\brief This file contains platform-related defines.
/
/
© Copyright 2005,
National Instruments Corporation.
All rights reserved.File: platform.h
Originated: 23 June 2005
*/#ifndef fantom_platform_h
#define fantom_platform_h#ifndef VISATYPE_HEADER
#include "../visatype.h"
#endif#define nFANTOM100_kOSMacOSX 0
#define nFANTOM100_kOSWin32 0#define nFANTOM100_kProcessorI386 0
#define nFANTOM100_kProcessorPPC 0#define nFANTOM100_kCompilerMSVC 0
#define nFANTOM100_kCompilerApple 0#undef nFANTOM100_kOSWin32
#define nFANTOM100_kOSWin32 1#undef nFANTOM100_kCompilerMSVC
#define nFANTOM100_kCompilerMSVC _MSC_VER#undef nFANTOM100_kProcessorI386
#define nFANTOM100_kProcessorI386 1#ifdef nFANTOM100_kExportSymbols
#define nFANTOM100_kExport __declspec(dllexport)
#else
#define nFANTOM100_kExport __declspec(dllimport)
#endif#define nFANTOM100_kBigEndian 0
#define nFANTOM100_kLittleEndian 1#endif // fantom_platform_h
@So what's the problem?
!http://s22.postimage.org/4za42ypsx/qt_nxt.png(Error 1)!
And when I try to remove (from .pro file)
@PRECOMPILED_HEADER += stdafx.h@ - .pro file
-
You are aware of the possibility that you are not stuck with MinGW?
You can download an express version of MSVC for free. It may be combined with Qt creator with msvc as tool chain. -
Yes but I hoped that I can get it work on Symbian.
Edit:
Symbian GCCE toolchain does not have any problem with stdafx.h but there is still problem with undefined reference.
These errors looks same as I got when I forgot to add pragma comment in MSVC. So there should be problem with reading phantom.lib file? -
I have no experience with Symbian.
Did you check out comm.cpp?
The only explanation I can offer is that part of the source might be excluded from compiling with #if -
It is problem of the .lib file. It has been built in Microsoft Visual Studio. It cannot be used with MinGW GCC. It does not matter if it's for Symbian or Windows.
When I try to run the application in Symbian simulator with Visual C++ toolchain everything works.
-
Yes, you have to use the proper compiler and its version for compatibility.
You cannot mix between versions of msvc. And you cannot mix MinGW 4.7 with MinGW 4.6 at least. So, you need a recompilation of the libs. -
OK, thank you very much.
I believe that Lego support will be willing to help me to get the proper library.