[ros-users] ROS for Windows via the mingw cross compiler

Daniel Stonier d.stonier at gmail.com
Thu Mar 24 00:16:06 UTC 2011


On 24 March 2011 01:09, Morgan Cormier <MCormier at coroware.com> wrote:

> Hi Daniel,
>
> Thank you again for your help with the ros cross compiler, it is working
> very well now.
>
> However, I may have a question regarding this cross-compilation. I am doing
> an application with ros and qt to run both an Linux and Windows. In this
> application I want to use the joystick. The problem is that I have to use
> the Os API to use the joystick, so Windows and Linux will be different. If
> it was a normal Qt application I would have included into my code "#ifdef
> Q_WS_WIN" to check if we compile on Windows or on Linux but here the case is
> difference, I compile on Linux to have the Linux and Windows binaries.
>
> Could you please tell me if there is a way with the cross compiler you made
> to compile with some Windows specific libraries? If not, do you how to solve
> this problem?
>

Firstly #ifdef's.

I had no problem with Q_OS_WIN32 or Q_WS_WIN...see following code:

*************************************************

#include <iostream>
#include <QtCore/QtGlobal>

int main() {
    std::cout << "Hello Dude" << std::endl;
#ifdef Q_OS_WIN32
    std::cout << "Hello Win" << std::endl;
#endif
    return 0;
}

*************************************************

Maybe you were just missing the header? Perhaps that is something that qmake
does extra that cmake's qt module does not do. Also, if you have a look
inside QtGlobal (which calls qglobal.h), you'll see that the macro is just
dependant on WIN32 being defined, so you could do that just as easily, i.e.

#ifdef WIN32
  // windows code
#else
  // unix code
 #endif

That's the way I usually do cross-platform code, and you dont have to
remember to do it a certain way for a particular library or call a
particular header as the compiler (or maybe it's the c library, can't
remember for sure which) will set that definition for you.

Secondly, what joystick libraries are you depending on? That's usually a
thorny issue for mingw programs - msvc compiled libraries and mingw compiled
libraries are usually incompatible, they store their symbols differently.
There are supposedly ways of getting that too work, but I've tried and is
too much effort too maintain in a stable way (was easier to convince my
company to move to linux!). The base system windows libraries are about the
maximum you can rely on - mingw build environment has compiled their own
versions of these. On top of that, there are the libraries provided by
mingw_cross. If the joystick api you're seeking is in these, you'll be ok,
if not (like if its a downloaded driver)...we have to email again :)

Let me know how it goes.

Regards,
Daniel.

Thank you so much for the help you provided me up until now, especially by
> providing this cross-compiler very useful.
>
> Morgan Cormier
> ________________________________________
> From: Daniel Stonier [d.stonier at gmail.com]
> Sent: Monday, March 14, 2011 11:48 PM
> To: Morgan Cormier; User discussions
> Subject: Re: [ros-users] ROS for Windows via the mingw cross compiler
>
> Hi Morgan,
>
> Sending this back to ros-users as it seems we got sidetracked onto
> private replies and it would be good to have this out there in the
> wild for others to pick up on. With this in mind, a quick summary of
> the problems: there was a broken package link in mingw cross (libpng)
> that is patched now and getting fixed upstream. We're also looking for
> more stability upstream at the moment too. The other problems turned
> out to be a non-event once Morgan got a better handle on how ros
> works.
>
> Morgan, keep me updated (especially if you come across broken elements
> in mingw_cross) and thanks for the testing. We haven't done much
> beyond testing the initial framework yet, so just the basic packages
> are ported which is enough to pass around messages for debugging. I'll
> have to look at porting things like tf, actionlib and nodelet to
> windows soon.
>
> Cheers,
> Daniel.
>
> On 15 March 2011 13:11, Morgan Cormier <MCormier at coroware.com> wrote:
> > Everything is working now, what I didn't do was :
> >
> > $ rostoolchain clear
> > $ rosprotect --unprotect --comms
> >
> > thank you so much for all the help you provided, that was really helpful
> for me who is still inexperienced( a student) and not a linux/ros expert.
> >
> > Morgan Cormier
> > ________________________________________
> > From: Daniel Stonier [d.stonier at gmail.com]
> > Sent: Monday, March 14, 2011 10:19 PM
> > To: Morgan Cormier
> > Subject: Re: [ros-users] ROS for Windows via the mingw cross compiler
> >
> > Ok, I can do it from scratch here without a problem so I think you're
> > doing something different somewhere in the pipeline (aka 'cmake .').
> > One thing I found teaching the other guys in my lab is that its really
> > important to be in the habit to look for errors at the end of every
> > command, linux talks to you, just have to listen. They often ignore
> > and just proceed on to the next command without realising it broke
> > further up the chain. That may or may not help you.
> >
> > So to find where you're going wrong. It can't find -lros, which
> > usually means its not at all there. If its a wrong version then it
> > will babble about that too, but the first thing you should check is to
> > see if its there. i.e.
> >
> > $ roscd roscpp/lib
> > $ ls
> >
> > You should see a libros.a there. If not, go back and make sure your
> > toolchain is selected and precompile everything again.
> >
> > $ rostoolchain clear
> > $ rosprotect --unprotect --comms
> > $ rostoolchain select mingw_cross/i686-pc-mingw32
> > $ rosprotect --pre-clean --comms
> > $ roscd eros_qt_tutorials
> > $ make
> >
> > I also updated the wiki page with some validation checks you can make
> > along the way to ensure everything is properly prepared. That might
> > help better understand what is going on under the hood too.
> >
> > http://www.ros.org/wiki/mingw_cross/Tutorials/cross_platform_qt_ros
> >
> >
> > Cheers,
> > Daniel.
> >
> >
> > On 15 March 2011 10:56, Morgan Cormier <MCormier at coroware.com> wrote:
> >> Hi Daniel,
> >>
> >> Thank you so much for you answer, I am still inexperienced, especially
> in ROS. I followed everything that is written on the tutorial and what you
> said and did it on two computer to make sure but I have the same error on
> both when I try to compile the eros_qt_tutorials package :
> >>
> >>
> /opt/mingw/usr/lib/gcc/i686-pc-mingw32/4.5.1/../../../../i686-pc-mingw32/bin/ld:
> cannot find -lros
> >>
> >> Do you know how to solve this problem?
> >>
> >> Thank you so much for all your help,
> >> Morgan Cormier
> >>
> >> ________________________________________
> >> From: Daniel Stonier [d.stonier at gmail.com]
> >> Sent: Monday, March 14, 2011 12:22 AM
> >> To: Morgan Cormier
> >> Subject: Re: [ros-users] ROS for Windows via the mingw cross compiler
> >>
> >> On 14 March 2011 12:54, Morgan Cormier <MCormier at coroware.com> wrote:
> >>>
> >>> As for the boost problem I still have it, even when I try to compile
> the eros_qt_tutorials package. When I do a "cmake ." on this package I have
> this message :
> >>
> >> Oh, what are you doing 'cmake .' for? That's the cmake way, but not
> >> the current ros way (might be changing with the next ros version).
> >> First of all, even if doing cmake projects, its a good habit to do
> >> something like:
> >>
> >> $ mkdir build
> >> $ cd build
> >> $ cmake ..
> >>
> >> All temporary files are then dumped in the build dir, and if you want
> >> to clean it out, you just have to remove the build dir. On the flip
> >> side, if you do 'cmake .', it populates your directory with all sorts
> >> of junk files and makes it hard to clean out later on.
> >>
> >> Secondly, with ros, even though it builds via cmake, it uses a
> >> makefile frontend to do so. So in any ros package, you always need to
> >> run 'make' (aka build this package) or 'rosmake' (aka build this
> >> package and its deps). If you don't it won't pull in various
> >> configuration files important to cmake. In this case - because we're
> >> cross compiling it will pull in the cross compiling configuration!
> >> That's what you're missing when you do 'cmake .' and why you get the
> >> error (I've managed to see the same error when doing so here).
> >> So...end result, clear out eros_qt_tutorials, update and try again
> >> with make. e.g. something like:
> >>
> >> $ roscd eros_qt_tutorials
> >> $ cd ..
> >> $ rm -rf eros_qt_tutorials
> >> $ svn update                    (should see eros_qt_tutorials download
> again)
> >> $ roscd eros_qt_tutorials
> >> $ make                            (or rosmake)
> >>
> >> Hope this helps,
> >> Daniel.
> >>
> >>
> >>>    link library [libQtGui.so] in /usr/lib may be hidden by files in:
> >>>      /opt/mingw/usr/i686-pc-mingw32/lib
> >>>    link library [libQtCore.so] in /usr/lib may be hidden by files in:
> >>>      /opt/mingw/usr/i686-pc-mingw32/lib
> >>>
> >>> Do you think the boost error can be related to the fact that it doesn't
> find the qt libs?
> >>>
> >>>
> >>> boost error message :
> >>> /opt/mingw/usr/i686-pc-mingw32/lib/libboost_signals-mt.a: member
> /opt/mingw/usr/i686-pc-mingw32/lib/libboost_signals-mt.a(trackable.o) in
> archive is not an object
> >>>
> >>>
> >>> As for the plateform I am using, I have ubuntu with an intel board
> (intel D525).
> >>>
> >>> Thank you so much for your help and please tell me if you can find a
> solution to my boost problem.
> >>>
> >>> Morgan Cormier
> >>>
> >>> ________________________________________
> >>> From: Daniel Stonier [d.stonier at gmail.com]
> >>> Sent: Sunday, March 13, 2011 3:58 AM
> >>> To: Morgan Cormier; User discussions
> >>> Subject: Re: [ros-users] ROS for Windows via the mingw cross compiler
> >>>
> >>> Ok, my apologies. I must have had an old tarball lying around and
> >>> missed the libpng problem, but I'm now seeing the same thing. It's
> >>> also come up on mingw cross' mailing list. Problem is due to a broken
> >>> link in libpng having been upgraded recently and they moved their old
> >>> tarballs to a different directory.
> >>>
> >>> I've patched mingw_cross in eros to handle this for now.
> >>>
> >>> - Update eros
> >>> - Clear out your /opt/mingw and redo mingw_cross, OR
> >>>  - Simply copy mingw_cross/patches/libpng.mk to /opt/mingw/src
> >>> followed by 'cd /opt/mingw; make gcc boost qt'
> >>>
> >>> I don't think I like the fact that their stable branch is prone to
> >>> broken links though, so I sent them an email about how we can resolve
> >>> this more practically. Another option I might try if more users start
> >>> coming on board is to make some binary tarballs of mingw_cross for ros
> >>> of the more popular platforms. Out of interest, what are you using?
> >>>
> >>> Anyway, let me know how that goes and especially how boost fares once
> >>> you are done.
> >>>
> >>> Cheers,
> >>> Daniel.
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>> On 13 March 2011 06:20, Morgan Cormier <MCormier at coroware.com> wrote:
> >>>> Hi Again,
> >>>>
> >>>> Just to tell you that even after doing a svn update in the eros folder
> and checking that it really downloads the 2.18 version, there is still the
> checksum error  :
> >>>>
> >>>> [download] libpng
> >>>>
> >>>> Wrong checksum of package libpng!
> >>>> ------------------------------------------------------------
> >>>>           => `-'
> >>>> Resolving ftp.simplesystems.org... 65.66.246.92
> >>>> Connecting to ftp.simplesystems.org|65.66.246.92|:21... connected.
> >>>> Logging in as anonymous ... Logged in!
> >>>> ==> SYST ... done.    ==> PWD ... done.
> >>>> ==> TYPE I ... done.  ==> CWD (1) /pub/libpng/png/src ... done.
> >>>> ==> SIZE libpng-1.4.4.tar.bz2 ... done.
> >>>> ==> PASV ... done.    ==> RETR libpng-1.4.4.tar.bz2 ...
> >>>> No such file `libpng-1.4.4.tar.bz2'.
> >>>> ------------------------------------------------------------
> >>>> [log]      /opt/mingw/log/libpng-download
> >>>>
> >>>> make[1]: *** [/opt/mingw/usr/installed/libpng] Error 1
> >>>> make[1]: Leaving directory `/opt/mingw'
> >>>>
> >>>>
> >>>> I am sure that we will find a solution to this problem,
> >>>>
> >>>> Thank you so much for your help,
> >>>>
> >>>> Morgan Cormier
> >>>>
> >>>> ________________________________________
> >>>> From: Daniel Stonier [d.stonier at gmail.com]
> >>>> Sent: Saturday, March 12, 2011 1:35 AM
> >>>> To: Morgan Cormier
> >>>> Subject: Re: [ros-users] ROS for Windows via the mingw cross compiler
> >>>>
> >>>> On 12 March 2011 09:44, Morgan Cormier <MCormier at coroware.com> wrote:
> >>>>> Hi,
> >>>>>
> >>>>> Thanks for this reply,
> >>>>>
> >>>>> I think the second error I had is because mingw didn't finish to
> compile because of the checksum error in libpng. I compiled it during the
> night, I didn't see the result since my computer shut down automatically,
> but since I could do the following step I though it was installed.
> >>>>>
> >>>>
> >>>> I went back to the version from 2 weeks ago and checked - came out
> >>>> with the same libpng error which led me to think you have an old
> >>>> version of eros. You can check by looking at mingw's makefile.
> >>>>
> >>>> $ roscd mingw_cross
> >>>> $ vim Makefile
> >>>>
> >>>> If it's downloading 2.16, you've got an old version. You should be
> seeing 2.18.
> >>>>
> >>>>> I tried to do as you said, I did an svn update of eros and so had the
> lasest version, and tried to compile again mingw_cross but I had the same
> problem.
> >>>>> Is the "svn co link" command enough
> >>>>
> >>>> If you mean by link, https://code.ros.org/svn/eros/trunk, then that
> >>>> has probably just checked out another eros inside eros under a dir
> >>>> called trunk. To svn update, simply:
> >>>>
> >>>> $ roscd eros
> >>>> $ svn update
> >>>>
> >>>>> or do I have to use the command "rosinstall /opt/ros
> https://code.ros.org/gf/project/eros/scmsvn/?action=browse&path=%2F*checkout*%2Ftrunk%2Feros_diamondback.rosinstall"
> ?
> >>>>
> >>>> Running:
> >>>>
> >>>> $ rosinstall /opt/ros
> >>>> "
> https://code.ros.org/gf/project/eros/scmsvn/?action=browse&path=%2F*checkout*%2Ftrunk%2Feros_diamondback.rosinstall
> "
> >>>>
> >>>> on an existing installation in /opt/ros will simply update all your
> >>>> repos in /opt/ros. So that should work too. As I said before, check
> >>>> mingw's Makefile to be sure.
> >>>>
> >>>> With regards to the boost problem, I just tried a simple boost signals
> >>>> program and it linked without a problem. I've attached that package
> >>>> with this. Is there any chance you could simplify your package to a
> >>>> standalone test that reproduces the problem and send it to me? I can'
> >>>> try and reproduce here on my machine.
> >>>>
> >>>> Cheers,
> >>>> Daniel.
> >>>>
> >>>>>
> >>>>> Thank you for your help,
> >>>>>
> >>>>> Morgan Cormer
> >>>>>
> >>>>> On 2011-03-11 14:31, Daniel Stonier wrote:
> >>>>>> On 11 March 2011 07:16, Morgan Cormier <MCormier at coroware.com>
> wrote:
> >>>>>> > Hi,
> >>>>>> >
> >>>>>> > I am interested in doing a Qt interface with ROS and found this
> tutorial which does exactly what I want :
> >>>>>> >
> http://www.ros.org/wiki/mingw_cross/Tutorials/cross_platform_qt_ros
> >>>>>> >
> >>>>>> > I experience some problems during the installation. When i compile
> mingw_cross (roscd mingw_cross;make) the compilation stop after downloading
> libpng, it says that the checksum is wrong.
> >>>>>> >
> >>>>>> > I installed it using : http://mingw-cross-env.nongnu.org/  and
> could finally do all the steps in the tutorial.
> >>>>>> > Another problem occured at this point, I couldn't compile because
> of this error :
> >>>>>> >
> >>>>>> > /opt/mingw/usr/i686-pc-mingw32/lib/libboost_signals-mt.a: member
> /opt/mingw/usr/i686-pc-mingw32/lib/libboost_signals-mt.a(trackable.o) in
> archive is not an object
> >>>>>> >
> >>>>>> > Do you know how to solve this problem?
> >>>>>> >
> >>>>>> > Thank you,
> >>>>>> >
> >>>>>>
> >>>>>> Just a quick reply before I crash for the night - will look at it
> >>>>>> again tomorrow.
> >>>>>>
> >>>>>> libpng checksum : we found a couple of broken link problems like
> this
> >>>>>> a couple of weeks ago, but that was because we were using mingw_2.16
> >>>>>> which was a bit dated. I upgraded the links in eros to actually use
> >>>>>> that tarball you downloaded (version 2.18), so can you make sure you
> >>>>>> reinstall, or at least svn update your eros again? We've fixed one
> or
> >>>>>> two other bugs in the meantime as well that you might need.
> >>>>>>
> >>>>>> The latter problem is a bit harder - I haven't come across that one
> >>>>>> before. Some links that might be relevant:
> >>>>>>
> >>>>>> http://www-01.ibm.com/support/docview.wss?rs=4036
> >>>>>
> >>>>
> >>>>
> >>>>
> >>>> --
> >>>> Phone : +82-10-5400-3296 (010-5400-3296)
> >>>> Home: http://snorriheim.dnsdojo.com/
> >>>> Yujin Robot: http://www.yujinrobot.com/
> >>>> Embedded Ros : http://www.ros.org/wiki/eros
> >>>> Embedded Control Libraries:
> http://snorriheim.dnsdojo.com/redmine/wiki/ecl
> >>>>
> >>>
> >>>
> >>>
> >>> --
> >>> Phone : +82-10-5400-3296 (010-5400-3296)
> >>> Home: http://snorriheim.dnsdojo.com/
> >>> Yujin Robot: http://www.yujinrobot.com/
> >>> Embedded Ros : http://www.ros.org/wiki/eros
> >>> Embedded Control Libraries:
> http://snorriheim.dnsdojo.com/redmine/wiki/ecl
> >>>
> >>
> >>
> >>
> >> --
> >> Phone : +82-10-5400-3296 (010-5400-3296)
> >> Home: http://snorriheim.dnsdojo.com/
> >> Yujin Robot: http://www.yujinrobot.com/
> >> Embedded Ros : http://www.ros.org/wiki/eros
> >> Embedded Control Libraries:
> http://snorriheim.dnsdojo.com/redmine/wiki/ecl
> >>
> >
> >
> >
> > --
> > Phone : +82-10-5400-3296 (010-5400-3296)
> > Home: http://snorriheim.dnsdojo.com/
> > Yujin Robot: http://www.yujinrobot.com/
> > Embedded Ros : http://www.ros.org/wiki/eros
> > Embedded Control Libraries:
> http://snorriheim.dnsdojo.com/redmine/wiki/ecl
> >
>
>
>
> --
> Phone : +82-10-5400-3296 (010-5400-3296)
> Home: http://snorriheim.dnsdojo.com/
> Yujin Robot: http://www.yujinrobot.com/
> Embedded Ros : http://www.ros.org/wiki/eros
> Embedded Control Libraries: http://snorriheim.dnsdojo.com/redmine/wiki/ecl
>



-- 
Phone : +82-10-5400-3296 (010-5400-3296)
Home: http://snorriheim.dnsdojo.com/
Yujin Robot: http://www.yujinrobot.com/
Embedded Ros : http://www.ros.org/wiki/eros
Embedded Control Libraries: http://snorriheim.dnsdojo.com/redmine/wiki/ecl
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ros.org/pipermail/ros-users/attachments/20110324/96ddb97c/attachment-0004.html>


More information about the ros-users mailing list