Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

[Note: I have been using Notepad++ (with some customisations as per this page), rather than MapBasic itself. This may make things a bit trickier, but so far the time saved in development has been worth the extra hassle during setup.]

I am trying to start using project files with MapBasic. As I understand it the process is as follows: compile your modules from .mb files into .mbo files. Then process the .mbp file which links the .mbo files together and, if there are no errors, creates a .mbx.

This makes sense to me except for one thing...how do i get my .mb files to compile to .mbo instead of .mbx? What am I missing?!

share|improve this question
1  
It really is well worth setting up Notepad++ for Mapbasic development. +1 for including the link to the instructions. –  James S Jun 30 '11 at 13:35
    
Yep, definitely worth doing. For the record I've been trying to set up projects using the default MapBasic editor as well, just to check it's not my Notepad++ config that's causing the problems. So far there's no difference in the outcomes. –  Mr_Chimp Jun 30 '11 at 13:37
add comment

1 Answer

up vote 1 down vote accepted

If the .mb files have a Main sub in them, they will compile to .mbx.

Remove the main and they will compile to an .mbo file

share|improve this answer
    
Hmmm, doesn't appear to make a difference. All I have in the .mb is 'note "test"' and it still compiles to a .mbx. Also, I've been using CoordinateExtractor.mb as an example and that uses a Sub Main and is linked as a .mbo. –  Mr_Chimp Jun 30 '11 at 13:35
1  
I have found that sometimes its best to compile each of my mb files separately. One of your mb files should still have a main sub in it. I just put the following into an .mb file and it compiled to an mbo. Declare sub other Sub Other Note "test" End Sub –  James S Jun 30 '11 at 13:39
    
Yes, I've been compiling each .mb individually so I can check for errors at each stage. Which is lucky as the most basic test failed! You're right, your code does create a .mbo. But mine (Note "test") creates an .mbx. I guess if you only have commands and no sub definitions then it counts the entire file as one big Sub Main? It makes sense, now that I think about it. Thanks! –  Mr_Chimp Jun 30 '11 at 13:47
    
Hang on a minute though... If one of my files should have a Sub Main in it, how do I make that one a .mbo? Can you link one .mbx with some .mbos? –  Mr_Chimp Jun 30 '11 at 13:56
2  
From MapBasic Help "Whenever you choose Project > Compile Current File, MapBasic tries to compile the current file into an executable application file (ending with .mbx). However, if the program file contains calls to functions or procedures that are not in the file, MapBasic cannot create an .mbx file. In this case, MapBasic assumes that the program is part of a larger project. MapBasic then builds an object file (.mbo) instead of an executable file (.mbx). MapBasic also creates an object file whenever the module that you are compiling does not have a Main procedure." –  James S Jun 30 '11 at 15:09
show 4 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.