Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 157 Stack Exchange communities.

What is meta?
Here's how it works:
  1. Any Stack Exchange user can ask a question
  2. The community provides support, votes on ideas, and reports bugs
  3. Your voice helps shape the way Stack Exchange operates

Whats wrong with the following markdown? I keep getting "Your post appears to contain code that is not properly formatted as code" when trying to answer a question. And why couldn't markdown at least give me a row number if it finds a "not properly formatted" piece of code to help debugging?

First of all, thank you to Gilles solution, which would work if I hadn't included any of sicstus built in libraries.

After having searched the internet, I e-mailed SICS and got two methods to create a standalone. I was using:

 - SICStus prolog VC9 4.2.0
 - Microsoft Visual C++ 2010 Service Pack 1

To create a standalone .exe file you need a C-compiler that matches your installation of SICStus. These C-compilers are included in the following versions of Visual C++.

 - SICStus VC10 4.2.x -  Visual Studio 2010 SP1
 - SICStus VC9  4.2.x  - Visual Studio 2008 SP1
 - SICStus [without VC] - Visual Studio 2005 SP1

Although there seems to be some backwards compability since I'm using SICStus VC9 and Visual Studio 2010.

To run the .exe file on another computer that computer will need the corresponding C-library(which is called Redistributable Packages by Microsoft). They can be downloaded [here][libs]:

 - SICStus VC10 4.2.x -  Visual C++ 2010 SP1 Redistributable Package (x86)
 - SICStus VC9  4.2.x  - Visual C++ 2008 SP1 Redistributable Package (x86)
 - SICStus [without VC] - Visual C++ 2005 SP1 Redistributable Package (x86)

This is the example pl file we will be compiling. It's using one of SICStus built-in libraries namely library(sets). Lets call it

    :- module(test, []).
    :- use_module(library(sets), [intersection/3]).

    main :-

    %% argv is the commands passed on the command line (or after the
    %% option '--' if run in a development system).
    current_prolog_flag(argv, Argv),
    sort(Argv, Set1),
    Set2 = [a, c, g],
    intersection(Set1, Set2, Intersection),
    format('The intersection of ~w and ~w is ~w~n', [Set1, Set2, Intersection]).

    % .sav-file entry point
    user:runtime_entry(start) :-

**Method 1:**

Create the .sav-file by compiling from the SICStus top level. This can be done using the SICStus interpreter,emacs, SPIDER or from the command line by  navigating to the SICStus binary folder "C:\Program Files (x86)\SICStus Prolog VC10 4.2.1\bin" and typing:

sicstus.exe -i

-i stand for interactive

From the sicstus top level, type the following:

    |?- compile('C:\filepath...\test'), save_program('C:\filepath...\test.sav').

Then end your session using

    |?- halt.

Now you need to load some settings to make your C-compiler available. Do this by navigating to (might be slightly different depending on your version of visual studio) C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\ run the [vcvarsall][vcvarsall] file.

    vcvarsall.bat x86

Remember the x86.

Then navigate to the SICStus binary folder and build your exe file using spld.exe. The flag --static makes sure that all you'll need will be in the .exe file though  the target machine must have the correct C-library installed.

    C:\Program Files (x86)\SICStus Prolog VC10 4.2.1\bin>spld.exe --static c:\long filepath...\test.sav -o c:\long filepath...\test1.exe

This should create an .exe file that will run on any computer with the right C library.

**METHOD 2**

Create the save file again. It's important that you name it main.sav.

    |?- compile('C:\filepath...\test'), save_program('C:\filepath...\main.sav').

Create a new folder for this example. Copy your main.sav file to the folder.  Copy sprt.exe, sprt4-2-x.dll and sprt.sav from the SICStus installation's bin folder into your new folder.

To run your program, run sprt.exe. Now your folder contains everything you need to run your .exe on another computer(except for the C library).

I hope this will help someone stuck in the same situation as I was.

This is a translation of a mail conversation with Per Mildner at SICS. The entire conversation (IN SWEDISH) can be found [here][mail]

share|improve this question
Well, at a glance, sicstus.exe -i looks like code, but it's not indented with 4 spaces. So does -i stand for interactive. – Cody Gray Mar 31 '12 at 6:19
(Slightly off-topic: Always remove the parenthetical part of links to MSDN documentation. It's the part that contains the version number—it's been escaped already in the sample you posted here. Removing that ensures that you always link to the current version of the documentation, rather than an old version.) – Cody Gray Mar 31 '12 at 6:20
@TheEstablishment Yes I've tried formatting sicstus.exe -i as code too and I've removed "-i stand for interactive". – Johan Wikström Mar 31 '12 at 6:26

You must log in to answer this question.

Browse other questions tagged .