24/7 Support: 800.608.6482

Videos

Try our new AI assistant by clicking the chat icon in the lower right corner.

Developer Videos

Videos | Installing the Compiler

ver. 9.0 and later

Video Transcript

Now that we have our Miva Merchant Developer Store all set up, access to the Admin, being able to connect via ftp, and access to the Database, the next thing we need to do is install the Miva Merchant compiler. The compiler is free to download from miva.com.  It's supported on three operating systems. FreeBSD, Linux and Windows. Because I'm working on a Windows machine here, we're going to do the Windows install. However, make sure to pick the version for the operating system you're running. I'll go ahead and click Download here and it will download an exe or executable file and then we'll double click to run. 

There's an installation wizard that will walk me through the process of installing the Miva Merchant Compiler. That's it. The Miva Merchant Compiler is now installed. Well what does that actually mean? Let's take a look at what was set up on our computer. Let me go into the folder that I installed it in. I put it in this msc (Miva Script Compiler) and you'll see there's a few folders here. There's an API, BIN, BUILTINS, and EXAMPLES along with license and release notes. The release notes will just give you all the updates for all the different versions of the Miva Merchant Compiler. 

So what is a compiler? Well the compiler itself is a command line tool to be able to take a MivaScript file, a .mv file, and convert it to a compiled MivaScript file, a .mvc file. Everything you can do with a compiler is always going to be through a command line interface. 

The heart of the Miva Merchant Compiler are these little executable files which actually do the heavy lifting. MVC.exe is the main executable that you can use to compile your programs. The other ones are just utilities and tools like mvcov.exe which is the code coverage tool, and mvprof.exe which is a code profiling tool. Now there's one more thing we want to do to configure the Miva Merchant Compiler so we can use it within any directory and that is to add the location of this exe file to the windows environment path variable. Now, if you're not familiar with the path variable, it's simply an environment variable in both windows and unix that specifies the path to any executable files. This way, if you're familiar with using command lines on say a Unix Machine and you type CD (change directory), that command is actually executing and executable file. The path of that file is usually saved within the path variable. Configuring the path variable is something you usually do one time and then you can forget about it. It allows you to type mvc to compile a mivascript file in any directory without having to reference this specific directory here, or on the c drive, mvc bin. So let's go ahead and do that. I'm going to right click my computer, go to properties, I'm going to go into Advanced Settings, and click here on Environment Variables. This will show me all the Environment Variables and I'm going to scroll down here until I find the path. So there it is. It already has some paths to other executable files. That's ok. It's simply a semicolon delimited list of all the places where the operating system should look for an executable file any time you type in a command in the command line. 

You see here, I already have this set up. So at the very end it has c:/msc/bin. This is the location of the MivaScript compiler. Now, if your system doesn't have that, you want to make sure you add it in. Again, all this does is allow you to run the mvc compiler command from any directory within your system. So I'm going to go ahead and hit ok, ok and ok. That's it. Our compiler is now set up. 

How do we actually use the compiler? To use it we have to open up our command prompt. In windows that's going to be cmv for the command prompt or in Unix you can open up your shell terminal. Let's take a look at a quick example. I have created a very basic MivaScript file. All it does is output "Hello World." Don't worry about the syntax here, the mveval tag, or the curly braces. We're going to get into that in one of the next videos. For now, this is just a basic mivascript file and I called it Hello_World.mv and let's see how we can compile this into a compiled MivaScript file. I'm going to come back to my command line and I have this saved to my desktop, so I'm going to change directories, and go into my module development series folder.  Now if I do dir and see what's in here, I see I have one file, "hello_world.mv" and the command will be ls on a unix machine. So to use the Miva Merchant Compiler, you simply type mvc and then you pass in parameters. The first parameter is going to be the name of the file I want to compile. So I can type in "hello" and I can use tab to auto complete and it will find the file for me. I can simply hit enter and this will compile the file. You'll see it refreshes. Now if I do a dir command again for directory, you'll see I now have a hello_world.mv and a hello_world.mvc. So what it did was it ran that file through the compiler and produced a compiled mivascript file. 

You may be wondering what options are available with MivaScript Compiler? Well, the MivaScript Compiler has built in help docs. So if I do mvc and then -- help, it will show me all the different options I can use when I run the command. So we have here mvc -- version, which gives me the compiler version which is 5.20 which is the latest at the timing of this video. 

Let's look at how to use one of these options. Say for example I want to use -0, which allows me to determine the output file. So I'm going to do mvc -0 and then I'm going to specify the file name that I want output to. So instead of having it called hello_world.mvc maybe I just want it to be called hello.mvc and then a space and specify the input file which is the file I want to compile which is hello_world.mvc and then hit enter. Now we'll run it through the compiler. So now if I do a dir command I should see hello.mvc. Perfect. Now let's jump back here to my text editor and let's make a quick  syntax error to this file. I'm going to go ahead and leave off that single quote which specifies that Hello World is a string and I'm going to hit save and jump back to my command prompt and so let's do mvc, let's try to recompile this, and I'm going to do hello_world.mv and hit enter. You'll see that it tells me on hello_world.mv line 1 found end of file when looking for end of expression. So it will output syntax errors that it finds when it tries to compile the file. This will tell you all the problems you have with your file that are preventing it from being compiled. So now if I come back here and I add in my single quote back and resave, come here and recompile and it works correctly. 

So the compiler is a key part of the Miva Merchant architecture. When you're developing Miva Merchant Modules, it's the only way to take an uncompiled source code file, a .mv file, and convert it to a compiled MivaScript file, or .mvc file. The .mvc file is what the engine can execute. It's what the engine runs. It's part of the core architecture of Miva Merchant. 





Looking for Developer Docs?

We have a whole section for that, including: Developer Training Series, Template Language docs, Module Development tutorials and much, much more.

Head to the Developer Section

Copyright © 1997 – 2024 Miva®, Miva Merchant®, MivaPay®, MivaCon®, Camp Miva®, Miva Connect®, Miva, Inc. All Rights Reserved.