0

Problem:

I need to install Primer3, a widely used bio tool that finds allows one to design primers.

Attempts at resolution:

I have attempted to follow their instructions for a Windows installation to no avail as it does not seem provide enough information. I not a experienced programmer by any means. So far I've also referenced this stack overflow post about a similar issue and tried to follow the suggested answer. I also briefly looked at a thread in their github repository, though I can't really understand what they are saying in it. Nothing seems to work so far as the output I get from my command terminal (the mingw32 version) is this:

C:\Users\mqian\Desktop\CGIProject\primer3-2.4.0\primer3-2.4.0\test>mingw32-make
TESTOPTS=--windows
cd ..\src & mingw32-make
mingw32-make[1]: Entering directory 'C:/Users/mqian/Desktop/CGIProject/primer3-2
.4.0/primer3-2.4.0/src'
g++ -c -g -Wall -D__USE_FIXED_PROTOTYPES__ -O2  masker.c
masker.c:8:22: fatal error: sys/mman.h: No such file or directory
compilation terminated.
Makefile:226: recipe for target 'masker.o' failed
mingw32-make[1]: *** [masker.o] Error 1
mingw32-make[1]: Leaving directory 'C:/Users/mqian/Desktop/CGIProject/primer3-2.
4.0/primer3-2.4.0/src'
Makefile:94: recipe for target 'makeexes' failed
mingw32-make: *** [makeexes] Error 2

and if I just try to run a make in the src folder:

C:\Users\mqian\Desktop\CGIProject\primer3-2.4.0\primer3-2.4.0\src>mingw32-make
g++ -c -g -Wall -D__USE_FIXED_PROTOTYPES__ -O2  masker.c
masker.c:8:22: fatal error: sys/mman.h: No such file or directory
compilation terminated.
Makefile:226: recipe for target 'masker.o' failed
mingw32-make: *** [masker.o] Error 1

Is it something that I missing in terms of a software or package needed? Is their makefile bugged? Any help would be appreciated.

P.S. here is a link to their download site on sourceforge. I am using version 2.4.0.

Thunderpurtz
  • 189
  • 2
  • 12
  • Does this SO question help: [Windows Equivalent for sys/mman.h](https://stackoverflow.com/q/29660492/1380680)? – Reinier Torenbeek Oct 03 '18 at 03:32
  • not really. My knowledge of compiling doesn't go that far so I don't really understand what they are talking about. Thank you for trying though! – Thunderpurtz Oct 03 '18 at 20:09
  • In a nutshell: the functionality provided by the include file `sys/mman.h` is not natively available on windows and that is not easily resolved. It looks like this was introduced into the `primer3` code base with v2.4.0, looking at the source code of v2.3.7 it does not seem to be present yet. So maybe you should try building v2.3.7, if that version is acceptable. – Reinier Torenbeek Oct 04 '18 at 04:07

1 Answers1

0

I was able to build it like this on Windows (replace /usr/local with the path where you want to install):

Build mman-win32 from https://github.com/witwall/mman-win32/releases under MSYS2 using:

./configure --prefix=/usr/local --cc=gcc --enable-static --enable-shared &&
make &&
mkdir -p /usr/local/include/mman-win32/sys /usr/local/lib &&
cp -f *.h /usr/local/include/mman-win32/sys/ &&
cp -f *.a /usr/local/lib/ &&
echo Success

Then build primer3 from https://github.com/primer3-org/primer3/releases:

mv src/masker.c src/masker.c.bak
cat > src/masker.c << EOF
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define GETLINE_BUFLEN 128
static ssize_t getline(char** lineptr, size_t* n, FILE* stream)
{
  char* bufptr;
  char* p;
  ssize_t size;
  int c;
  if (!lineptr || !n || !stream)
    return -1;
  bufptr = *lineptr;
  size = *n;
  c = fgetc(stream);
  if (c == EOF)
    return -1;
  if (!bufptr) {
    if ((bufptr = (char*)malloc(GETLINE_BUFLEN)) == NULL)
      return -1;
    size = GETLINE_BUFLEN;
  }
  p = bufptr;
  while (c != EOF) {
    if ((p - bufptr) > (size - 1)) {
      size = size + GETLINE_BUFLEN;
      if ((bufptr = (char*)realloc(bufptr, size)) == NULL)
        return -1;
    }
    *p++ = c;
    if (c == '\n') {
      break;
    }
    c = fgetc(stream);
  }
  *p++ = 0;
  *lineptr = bufptr;
  *n = size;
  return p - bufptr - 1;
}
EOF
cat src/masker.c.bak >> src/masker.c
make -Csrc install PREFIX=/usr/local CC_OPTS="-I/usr/local/include/mman-win32" LDLIBS="-Wl,--as-needed -lmman" &&
echo Success
Brecht Sanders
  • 6,215
  • 1
  • 16
  • 40