LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Quick and dirty guide: using mingw as an external compiler

Hello,

 

Here is how I managed to use mingw as an external compiler on my CVI 8.5.0 running under windows XP.

 

I'm attaching two files, one is the "ecc" file to be provided to CVI, the other one is a C file to be used to build a "wrapper" to mingw.

 

To use the wrapper, just build the executable and place it at a location of your choice. You will need to edit the "compiler configuration" to adjust the path of that executable.

You also need to adjust the path of the mingw compiler. But please be aware that there must not be any spaces, so you may need to use a command line to get the "short name" of any folder containing a space.

 

Please note that, to avoid linking problems (I have done another thread for that), you will probably need to define a __main function like that:

int __main(void) { return 0; }

 

For those who will ask why a wrapper is needed, this is beacause CVI generates an .rsp file for each file to be compiled but this files contains backslashes as a directory separator and it looks like mingw just don't like that and prefers slashes.

 

I'm not sure I will try on CVI 2010 (the only other version available to me) or any other CVI (as I don't have any other), so comments/contributions are welcome.

 

This is a quick and dirty guide, but it works for me. 😉

 

Frédéric Lochon.

 

Download All
Message 1 of 3
(3,055 Views)

Thanks for this.  I got it to work for a relatively simple program in CVI 2012.  A few notes:

 

In the Advanced Settings for the Compiler Setup, I had to change the path so that it points to where MinGW is installed on my PC.

 

It looks like MinGW doesn't recognize the __int64 type, which causes all sorts of problems with CVI's header files.  This can be fixed by adding the following at the start of the file:

#define __int64 long long int 

 

Also, for some reason it's not liking path names with spaces, even though it looks like CVI is putting things into quotes.  That includes the project path and any .c file in the project.

Message 2 of 3
(2,949 Views)

Indeed, spaces are not handled correctly (because of my wrapper).

 

That would require a too-boring-for-my-needs modification of the wrapper.

The idea is to recognize that an argument begins with a quote to combine it up to the argument ending with a quote to build a single argument to be passed to the _spawnv function.

 

0 Kudos
Message 3 of 3
(2,945 Views)