Jump to content


Noobie mistakes


  • Please log in to reply
25 replies to this topic

#1 PT_Dreamer

PT_Dreamer

    GCS Core Developer

  • Administrators
  • 1207 posts
  • LocationCaparica, Portugal
  • Country: flag of Portugal Portugal


Posted 11 April 2010 - 07:13 PM

If you are an experienced developer then this thread is not for you. On the other hand if you are just a curious person who likes to code for fun maybe the next few lines might be of some use for you. They are the result of mistakes I made while developing a GCS plugin.

OpenPilot GCS aims to be cross platform app, we would expect that using QT as a development environment would be sufficient to achieve this goal.

However if you are like me, and windows is still your OS of choice you have to be careful, windows is not a case sensitive system regarding file and folder names. It is better just using lower case, it can avoid lots of problems. If you don’t, you will have no warranties that your code will compile under Linux.

When committing code you should do a clean compile under at least windows and linux to make sure it works on both systems. I use a Ubuntu virtual machine on a windows 7 host, and code compiles faster on the VM! Windows haters don’t laugh…Posted Image

Be sure you make SVN updates often, it can save you the trouble of having to deal with conflicts.

Regarding coding standards they should be used from the very beginning, I’m Portuguese, we tend to do it first and read the instruction later, that’s why my code is so messy.

Hope the mistakes I made will help others avoiding them!


Jose
Life is just a game, but atleast the graphics are awesome!

#2 Julien

Julien

    GCS Core Developer

  • Members
  • PipPip
  • 19 posts
  • LocationLyon, France
  • Country: flag of France France

Posted 11 April 2010 - 08:20 PM

Jose, interesting post, that would make a good Wiki topic.

For cross platform compilation issues, I would also add:
- Always use slash '/', to separate directories for instance in #include, back-slash are common on Windows, but Linux doesn't understand them. When it comes to applicative code, you can also use Qt abstraction (see QDir)
- Windows needs a compiler directive to import/export classes to a DLL, that's why we have XXX_EXPORT in front of classes. Linux doesn't need that so it's easy to forget them.

#3 dankers

dankers

    Janitor

  • Administrators
  • 5115 posts
  • Country: flag of Australia Australia


Posted 11 April 2010 - 08:22 PM

Noce post Jose! I also like micro commits as from experience it can save a lot of hassle with conflicts especially as we are still fairly early in development.

I'm going to add a suggestion from PeterG here as well which I think is a great idea. We should make SVN commit comments reflect what part they are committing to i.e. GCS/Core or PiOS/I2C or GCS/Dials etc. Additionally if you remember the first part of the comment should be the Jira issue number if one exists.  

If you add the Jira issue number then Jira will add the SVN commits to the issue, for example: OP-36

Click on the Subversion Commits tab of that issue you will see the commits related to it. Additionally, this is linked this with our WebSVN (just like the forums are) so clicking on on a file will take you to that revision of the WebSVN to see what changed.

An example of a good SVN commit comment would be:

OP-44 GCS/Sound: Create initial plugin.

Its just a suggestion, it is not set in stone and I know people are busy and will forget etc, its just that some of the GCS devs are not so interested in PiOS or the firmware and likely the other way around as well.

#4 CheBuzz

CheBuzz

    Ex-Member

  • Banned
  • PipPipPip
  • 397 posts
  • Country: flag of United States United States


Posted 12 April 2010 - 04:57 AM

View Postdankers, on 11 April 2010 - 08:22 PM, said:

Additionally if you remember the first part of the comment should be the Jira issue number if one exists.  

If you add the Jira issue number then Jira will add the SVN commits to the issue, for example: OP-36

Wow, I didn't know that.  I learned something knew today and will remember that for all my future commits.

#5 PT_Dreamer

PT_Dreamer

    GCS Core Developer

  • Administrators
  • 1207 posts
  • LocationCaparica, Portugal
  • Country: flag of Portugal Portugal


Posted 12 April 2010 - 11:31 AM

View Postdankers, on 11 April 2010 - 08:22 PM, said:

Noce post Jose! I also like micro commits as from experience it can save a lot of hassle with conflicts especially as we are still fairly early in development.

I'm going to add a suggestion from PeterG here as well which I think is a great idea. We should make SVN commit comments reflect what part they are committing to i.e. GCS/Core or PiOS/I2C or GCS/Dials etc. Additionally if you remember the first part of the comment should be the Jira issue number if one exists.  

If you add the Jira issue number then Jira will add the SVN commits to the issue, for example: OP-36

Click on the Subversion Commits tab of that issue you will see the commits related to it. Additionally, this is linked this with our WebSVN (just like the forums are) so clicking on on a file will take you to that revision of the WebSVN to see what changed.

An example of a good SVN commit comment would be:

OP-44 GCS/Sound: Create initial plugin.

Its just a suggestion, it is not set in stone and I know people are busy and will forget etc, its just that some of the GCS devs are not so interested in PiOS or the firmware and likely the other way around as well.

If you are not regretting having me granted write permission by nowPosted Image , I promise I will document my next commits in accordance to your suggested format.

The problem was that I was to eager to commit my code and see it part of the project, that I committed it before testing on Linux.

When I did try to compile it and saw it didn't, I was so ashamed that started a fix and commit rampage, completely disregarding documentation.

I'm thinking about passing some of this thread's information to the plugin developing Wiki page. At least for me it will be a constant reminder of mistakes I made and should not do again!

Now that I finished fustigating my self I think that even with proper documentation things could be better if the forum had two SVN commit threads. I don't know if this is possible but it would be nice I think.

Changing the subject slightly, has anyone been developing in Mac OS? here in Portugal the percentage of Jobs OS users is very small, however being this a Transcontinental project (at least four by now) and knowing that globally Mac OS as a 5,9% share against Linux's 1,14% (source wikipedia), I think that this system should not be neglected.

Jose
Life is just a game, but atleast the graphics are awesome!

#6 Reddog

Reddog

    UI Manager

  • Members
  • PipPipPip
  • 1200 posts
  • Country: flag of Australia Australia


Posted 29 May 2010 - 04:38 AM

I tried to compile the GCS on a Mac last night using the instructions on the wiki and it failed, so it does not seem to compile at all for Mac users yet.

#7 PeterG

PeterG

    GCS Core Developer

  • Members
  • PipPipPip
  • 105 posts
  • Country: flag of Sweden Sweden

Posted 29 May 2010 - 08:06 AM

Not surprising as we don't seem to have any developers using Mac yet. It shouldn't be too difficult to get it to work though. Where does the compile fail?

#8 Reddog

Reddog

    UI Manager

  • Members
  • PipPipPip
  • 1200 posts
  • Country: flag of Australia Australia


Posted 29 May 2010 - 08:52 AM

Running build steps for project openpilotgcs...
Configuration unchanged, skipping QMake step.
Could not find make command: make in the build environment
Error while building project openpilotgcs
When executing build step 'Make'
Canceled build.

#9 Reddog

Reddog

    UI Manager

  • Members
  • PipPipPip
  • 1200 posts
  • Country: flag of Australia Australia


Posted 29 May 2010 - 09:49 AM

Running build steps for project openpilotgcs...
Starting: /usr/bin/qmake /Users/nathanaherne/OpenPilot/ground/openpilotgcs.pro -spec macx-g++ -r
Reading /Users/nathanaherne/OpenPilot/ground/src/src.pro [/Users/nathanaherne/OpenPilot/ground/Build/src]
Reading /Users/nathanaherne/OpenPilot/ground/src/libs/libs.pro [/Users/nathanaherne/OpenPilot/ground/Build/src/libs]
Reading /Users/nathanaherne/OpenPilot/ground/src/libs/qtconcurrent/qtconcurrent.pro [/Users/nathanaherne/OpenPilot/ground/Build/src/libs/qtconcurrent]
Reading /Users/nathanaherne/OpenPilot/ground/src/libs/aggregation/aggregation.pro [/Users/nathanaherne/OpenPilot/ground/Build/src/libs/aggregation]
Reading /Users/nathanaherne/OpenPilot/ground/src/libs/extensionsystem/extensionsystem.pro [/Users/nathanaherne/OpenPilot/ground/Build/src/libs/extensionsystem]
/Developer/Tools/Qt/rcc: File does not exist '../../../../src/libs/extensionsystem/pluginview.qrc'
Reading /Users/nathanaherne/OpenPilot/ground/src/libs/qmapcontrol/qmapcontrol.pro [/Users/nathanaherne/OpenPilot/ground/Build/src/libs/qmapcontrol]
Reading /Users/nathanaherne/OpenPilot/ground/src/libs/qmapcontrol/src/src.pro [/Users/nathanaherne/OpenPilot/ground/Build/src/libs/qmapcontrol/src]
Reading /Users/nathanaherne/OpenPilot/ground/src/libs/qwt/qwt.pro [/Users/nathanaherne/OpenPilot/ground/Build/src/libs/qwt]
Reading /Users/nathanaherne/OpenPilot/ground/src/libs/qwt/src/src.pro [/Users/nathanaherne/OpenPilot/ground/Build/src/libs/qwt/src]
Reading /Users/nathanaherne/OpenPilot/ground/src/libs/qextserialport/qextserialport.pro [/Users/nathanaherne/OpenPilot/ground/Build/src/libs/qextserialport]
Reading /Users/nathanaherne/OpenPilot/ground/src/libs/qextserialport/src/src.pro [/Users/nathanaherne/OpenPilot/ground/Build/src/libs/qextserialport/src]
Reading /Users/nathanaherne/OpenPilot/ground/src/libs/utils/utils.pro [/Users/nathanaherne/OpenPilot/ground/Build/src/libs/utils]
/Developer/Tools/Qt/rcc: File does not exist '../../../../src/libs/utils/utils.qrc'
Reading /Users/nathanaherne/OpenPilot/ground/src/libs/glc_lib/glc_lib.pro [/Users/nathanaherne/OpenPilot/ground/Build/src/libs/glc_lib]
Reading /Users/nathanaherne/OpenPilot/ground/src/libs/qymodem/qymodem.pro [/Users/nathanaherne/OpenPilot/ground/Build/src/libs/qymodem]
Reading /Users/nathanaherne/OpenPilot/ground/src/libs/qymodem/src/src.pro [/Users/nathanaherne/OpenPilot/ground/Build/src/libs/qymodem/src]
Reading /Users/nathanaherne/OpenPilot/ground/src/libs/libqxt/libqxt.pro [/Users/nathanaherne/OpenPilot/ground/Build/src/libs/libqxt]
Project MESSAGE: building core module
Reading /Users/nathanaherne/OpenPilot/ground/src/libs/libqxt/src/core/core.pro [/Users/nathanaherne/OpenPilot/ground/Build/src/libs/libqxt/src/core]
Reading /Users/nathanaherne/OpenPilot/ground/src/app/app.pro [/Users/nathanaherne/OpenPilot/ground/Build/src/app]
Reading /Users/nathanaherne/OpenPilot/ground/src/plugins/plugins.pro [/Users/nathanaherne/OpenPilot/ground/Build/src/plugins]
Reading /Users/nathanaherne/OpenPilot/ground/src/plugins/coreplugin/coreplugin.pro [/Users/nathanaherne/OpenPilot/ground/Build/src/plugins/coreplugin]
/Developer/Tools/Qt/rcc: File does not exist '../../../../src/plugins/coreplugin/core.qrc'
/Developer/Tools/Qt/rcc: File does not exist '../../../../src/plugins/coreplugin/fancyactionbar.qrc'
Reading /Users/nathanaherne/OpenPilot/ground/src/plugins/welcome/welcome.pro [/Users/nathanaherne/OpenPilot/ground/Build/src/plugins/welcome]
/Developer/Tools/Qt/rcc: File does not exist '../../../../src/plugins/welcome/welcome.qrc'
Reading /Users/nathanaherne/OpenPilot/ground/src/plugins/rawhid/rawhid.pro [/Users/nathanaherne/OpenPilot/ground/Build/src/plugins/rawhid]
Reading /Users/nathanaherne/OpenPilot/ground/src/plugins/serialconnection/serialconnection.pro [/Users/nathanaherne/OpenPilot/ground/Build/src/plugins/serialconnection]
Reading /Users/nathanaherne/OpenPilot/ground/src/plugins/uavobjects/uavobjects.pro [/Users/nathanaherne/OpenPilot/ground/Build/src/plugins/uavobjects]
Reading /Users/nathanaherne/OpenPilot/ground/src/plugins/uavtalk/uavtalk.pro [/Users/nathanaherne/OpenPilot/ground/Build/src/plugins/uavtalk]
Reading /Users/nathanaherne/OpenPilot/ground/src/plugins/emptygadget/emptygadget.pro [/Users/nathanaherne/OpenPilot/ground/Build/src/plugins/emptygadget]
Reading /Users/nathanaherne/OpenPilot/ground/src/plugins/map/map.pro [/Users/nathanaherne/OpenPilot/ground/Build/src/plugins/map]
Reading /Users/nathanaherne/OpenPilot/ground/src/plugins/scope/scope.pro [/Users/nathanaherne/OpenPilot/ground/Build/src/plugins/scope]
Reading /Users/nathanaherne/OpenPilot/ground/src/plugins/modelview/modelview.pro [/Users/nathanaherne/OpenPilot/ground/Build/src/plugins/modelview]
Reading /Users/nathanaherne/OpenPilot/ground/src/plugins/uavobjectbrowser/uavobjectbrowser.pro [/Users/nathanaherne/OpenPilot/ground/Build/src/plugins/uavobjectbrowser]
Reading /Users/nathanaherne/OpenPilot/ground/src/plugins/uploader/uploader.pro [/Users/nathanaherne/OpenPilot/ground/Build/src/plugins/uploader]
Reading /Users/nathanaherne/OpenPilot/ground/src/plugins/airspeed/airspeed.pro [/Users/nathanaherne/OpenPilot/ground/Build/src/plugins/airspeed]
Reading /Users/nathanaherne/OpenPilot/ground/src/plugins/lineardial/lineardial.pro [/Users/nathanaherne/OpenPilot/ground/Build/src/plugins/lineardial]
Reading /Users/nathanaherne/OpenPilot/ground/src/plugins/systemhealth/systemhealth.pro [/Users/nathanaherne/OpenPilot/ground/Build/src/plugins/systemhealth]
Reading /Users/nathanaherne/OpenPilot/ground/src/plugins/config/config.pro [/Users/nathanaherne/OpenPilot/ground/Build/src/plugins/config]
Reading /Users/nathanaherne/OpenPilot/ground/share/share.pro [/Users/nathanaherne/OpenPilot/ground/Build/share]
Reading /Users/nathanaherne/OpenPilot/ground/share/openpilotgcs/translations/translations.pro [/Users/nathanaherne/OpenPilot/ground/Build/share/openpilotgcs/translations]
WARNING: Cannot open substitute for input '../../../../share/openpilotgcs/translations/extract-mimetypes.xq.in'
Exited with code 0.

#10 PeterG

PeterG

    GCS Core Developer

  • Members
  • PipPipPip
  • 105 posts
  • Country: flag of Sweden Sweden

Posted 29 May 2010 - 10:02 AM

The last post doesn't actually give an error message, the first complains about not finding the command 'make'. Did you do something in between or?

#11 Reddog

Reddog

    UI Manager

  • Members
  • PipPipPip
  • 1200 posts
  • Country: flag of Australia Australia


Posted 29 May 2010 - 11:42 AM

Ok so the first post is running the project and the second is building the project.

#12 PeterG

PeterG

    GCS Core Developer

  • Members
  • PipPipPip
  • 105 posts
  • Country: flag of Sweden Sweden

Posted 29 May 2010 - 11:55 AM

Do you have 'make' installed, ie can you execute the command 'make' in a shell? If not, you might need to install it first.

http://stackoverflow...ing-make-on-osx

#13 Reddog

Reddog

    UI Manager

  • Members
  • PipPipPip
  • 1200 posts
  • Country: flag of Australia Australia


Posted 30 May 2010 - 02:37 PM

Thanks for the heads up PeterG, I should have picked that up. To save me downloading the Apple Developers tools, I moved to Linux.

I am still getting compile errors and as I have no experience with QT and I am a pretty crappy developer, I will leave it to the Pros (I am getting some 6000 build errors as of right now).

#14 PeterG

PeterG

    GCS Core Developer

  • Members
  • PipPipPip
  • 105 posts
  • Country: flag of Sweden Sweden

Posted 30 May 2010 - 02:54 PM

For (Ubuntu) Linux you can look at this page:

http://wiki.openpilo...opment_on_Linux

#15 dankers

dankers

    Janitor

  • Administrators
  • 5115 posts
  • Country: flag of Australia Australia


Posted 30 May 2010 - 03:44 PM

View PostReddog, on 30 May 2010 - 02:37 PM, said:

(I am getting some 6000 build errors as of right now).

That would only be normal if I had committed code and I haven't. :D

#16 Bani Greyling

Bani Greyling

    GCS Core Developer

  • Members
  • PipPipPip
  • 190 posts
  • Country: flag of South Africa South Africa


Posted 06 June 2010 - 08:12 AM

View PostPT_Dreamer, on 11 April 2010 - 07:13 PM, said:

When committing code you should do a clean compile under at least windows and linux to make sure it works on both systems. I use a Ubuntu virtual machine on a windows 7 host, and code compiles faster on the VM! Windows haters don’t laugh…Posted Image

How do you do that? Commit in Windows and update & compile under Linux, or do you share a workspace using shared folders? The latter seem problematic.  :unsure:
What I cannot create, I do not understand - Richard Feynman

#17 dankers

dankers

    Janitor

  • Administrators
  • 5115 posts
  • Country: flag of Australia Australia


Posted 06 June 2010 - 08:38 AM

Both would work but you need to build outside the tree for the latter. I share the SVN source with a shared folder via virtual box and only commit / update on Windows for now.

I only did this yesterday but it does work.

In my svn ground folder I have a Build director and and a buildlin directory.

Attached File  build.png   28.62K   71 downloads

In a shell on Linux I just run:

cd buildlin
qmake ../openpilotgcs.pro
make


On a Windows CMD prompt I run:

cd Build
qmake ../openpilotgcs.pro
mingw32-make


There might be a better way? But this works for me.

Each build is contained to their respective build directories but built from the same source. Very shortly I will switch this around and use Linux as my main dev OS and run WinXP in a VM to test Windows.

View PostBani Greyling, on 06 June 2010 - 08:12 AM, said:

How do you do that? Commit in Windows and update & compile under Linux, or do you share a workspace using shared folders? The latter seem problematic.  :unsure:


#18 Bani Greyling

Bani Greyling

    GCS Core Developer

  • Members
  • PipPipPip
  • 190 posts
  • Country: flag of South Africa South Africa


Posted 06 June 2010 - 02:39 PM

I tried that, but failed :(

Output from build:
g++ -Wl,-z,origin '-Wl,-rpath,$ORIGIN/../lib/openpilotgcs' -shared -Wl,-soname,libQtConcurrent.so.1 -o libQtConcurrent.so.1.0.0 .obj/debug-shared/moc_multitask.o -L/usr/lib -L/home/bani/code/win_openpilot/ground/buildlin/lib/openpilotgcs -lQtTest -lQtGui -lQtCore -lpthread
ln -s libQtConcurrent.so.1.0.0 libQtConcurrent.so
ln: creating symbolic link `libQtConcurrent.so': Operation not permitted

Maybe it fails to create symbolic link on NTFS (or the vboxsf driver used to mount VirtualBox shared folder)

Any ideas?


don't fuss...it is a virtualbox issue...
What I cannot create, I do not understand - Richard Feynman

#19 CheBuzz

CheBuzz

    Ex-Member

  • Banned
  • PipPipPip
  • 397 posts
  • Country: flag of United States United States


Posted 07 June 2010 - 04:50 PM

Other ideas are:

rsync
Shared network folder
svn can also create a patch file

#20 dankers

dankers

    Janitor

  • Administrators
  • 5115 posts
  • Country: flag of Australia Australia


Posted 18 June 2010 - 11:43 AM

Just a small addition, if you have multiple cores, rather than running make (or mingw32-make) you can try using jom instead.

View Postdankers, on 06 June 2010 - 08:38 AM, said:

Both would work but you need to build outside the tree for the latter. I share the SVN source with a shared folder via virtual box and only commit / update on Windows for now.

I only did this yesterday but it does work.

In my svn ground folder I have a Build director and and a buildlin directory.

Attachment build.png

In a shell on Linux I just run:

cd buildlin
qmake ../openpilotgcs.pro
make


On a Windows CMD prompt I run:

cd Build
qmake ../openpilotgcs.pro
mingw32-make


There might be a better way? But this works for me.

Each build is contained to their respective build directories but built from the same source. Very shortly I will switch this around and use Linux as my main dev OS and run WinXP in a VM to test Windows.