Giter VIP home page Giter VIP logo

Comments (1)

trzy avatar trzy commented on July 18, 2024 3

It won't build on Windows, not directly at least. I got it to build with gcc using MSYS2 but I had to make a few changes because the code appears to rely on a non-standard version of stdlib.h as well as signed time types not available on Windows/MSYS2.

From an MSYS2 terminal in the build directory:

cmake .. .. -DCMAKE_BUILD_TYPE=Release -G "MinGW Makefiles"
mingw32-make

For this to work you must have installed make as follows:

pacman -S mingw64/mingw-w64-x86_64-make

You will now encounter a number of errors. Basically, you'll have to open up the problematic files and fix them. For errors about random() and srandom() not being found, simply redefine them to use rand() and srand(), which use an inferior RNG but whatever:

#define random rand
#define srandom srand

If you get an error about suseconds_t not existing:

typedef long long suseconds_t;

Lastly, in core/contrib/box.c:

  1. Comment out the reference to alloca.h
  2. Make sure _linux is defined before the ifdef.
  3. Replace my_memalign with these two functions:

void *aligned_alloc(size_t align, size_t size)
{
    /* align must be a power of 2 */
    /* size must be a multiple of align */
    if ((align & (align - 1)) || (size & (align - 1)))
    {
        errno = EINVAL;
        return NULL;
    }

#ifdef HAVE_POSIX_MEMALIGN
    if (align < sizeof (void *)) /* POSIX does not allow small alignment */
        align = sizeof (void *);

    void *ptr;
    int err = posix_memalign(&ptr, align, size);
    if (err)
    {
        errno = err;
        ptr = NULL;
    }
    return ptr;

#elif defined(HAVE_MEMALIGN)
    return memalign(align, size);
#elif defined (_WIN32) && defined(__MINGW32__)
    return __mingw_aligned_malloc(size, align);
#elif defined (_WIN32) && defined(_MSC_VER)
    return _aligned_malloc(size, align);
#else
    /* align must be valid/supported */
    assert(align <= alignof (max_align_t));
    return malloc(((void) align, size));
#endif
}


int my_memalign(void** pptr, size_t alignment, size_t size) {
  *pptr = aligned_alloc(alignment, size);
  //*pptr = memalign(alignment, size);
  int fail = (!*pptr);
  return fail;
}

It should compile now. If you then have trouble running the Python apriltags.py demo, make sure it is trying to open the correct libapriltag.dll file. If it complains about missing dependencies there, edit your CMakeLists.txt and add -static like so:

set(EXTRA_FLAGS "-static -Wall -g -march=native ${CMAKE_THREAD_LIBS_INIT}")

This should build a DLL that includes its dependencies statically.

I'm thinking of cleaning this all up and making a PR myself...

from apriltag.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.