Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emscripten compilation #1

Open
kalwalt opened this issue Apr 25, 2021 · 17 comments
Open

Emscripten compilation #1

kalwalt opened this issue Apr 25, 2021 · 17 comments
Assignees
Labels
enhancement New feature or request

Comments

@kalwalt
Copy link
Owner

kalwalt commented Apr 25, 2021

Compile PTAM with Emscripten

@Carnaux @ThorstenBux i created this issue to share our results.
I'm testing under Ubuntu 20.04. Emscripten 1.38.15 (need to update to a newest version) Followed the instructions by @ThorstenBux in the Readme:

emcmake cmake .
emmake make

First issue i need to copy the file arith.h included in external/clapack-3.2.1/build-x86-vc12/F2CLIBS/libf2c" inside external/clapack-3.2.1/F2CLIBS/libf2c

then the cmake config is build and i can run emmake make but it fails with this error:

/home/walter/kalwalt-github/PTAM-GPL/external/clapack-3.2.1/BLAS/SRC/xerbla.c:70:2: error: 
      implicitly declaring library function 'printf' with type
      'int (const char *, ...)' [-Werror,-Wimplicit-function-declaration]
        printf("** On entry to %6s, parameter number %2i had an illegal ...
        ^
/home/walter/kalwalt-github/PTAM-GPL/external/clapack-3.2.1/BLAS/SRC/xerbla.c:70:2: note: 
      include the header <stdio.h> or explicitly provide a declaration for
      'printf'
/home/walter/kalwalt-github/PTAM-GPL/external/clapack-3.2.1/BLAS/SRC/xerbla.c:71:11: warning: 
      format specifies type 'int' but the argument has type 'integer'
      (aka 'long') [-Wformat]
                srname, *info);
                        ^~~~~
1 warning and 1 error generated.

i solved this issue adding inside /external/clapack-3.2.1/BLAS/SRC/xerbla.c a stdio.h include:

#include "f2c.h"
#include "blaswrap.h"
+ #include <stdio.h>
-

After that the build process continue and it fails at external/libcvd/cvd_src/get_time_of_day_ns.cc :

/home/walter/kalwalt-github/PTAM-GPL/external/libcvd/cvd_src/get_time_of_day_ns.cc:9:57: error: 
      no member named 'to_time_t' in 'std::__2::chrono::steady_clock'
  return (long long)std::chrono::high_resolution_clock::to_time_t(std::c...
                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
1 error generated.
ERROR:root:compiler frontend failed to generate LLVM bitcode, halting

i excluded for now that line of code;

#include "cvd/timer.h"
#include <chrono>

namespace CVD {

long long get_time_of_day_ns()
{
 // i excluded this line of code from compilation
 // return (long long)std::chrono::high_resolution_clock::to_time_t(std::chrono::high_resolution_clock::now());
}

}

the build process continue but fails at external/libcvd/CMakeFiles/libcvd.dir/cvd_src/i686/convolve_gaussian.cc :

[ 96%] Building CXX object external/libcvd/CMakeFiles/libcvd.dir/cvd_src/i686/convolve_gaussian.cc.o
/home/walter/kalwalt-github/PTAM-GPL/external/libcvd/cvd_src/i686/convolve_gaussian.cc:260:30: error: 
      use of undeclared identifier '_mm_getcsr'
    unsigned int csr_state = _mm_getcsr();
                             ^
/home/walter/kalwalt-github/PTAM-GPL/external/libcvd/cvd_src/i686/convolve_gaussian.cc:261:29: error: 
      use of undeclared identifier '_MM_FLUSH_ZERO_ON'
    _MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON);
                            ^
/home/walter/kalwalt-github/PTAM-GPL/external/libcvd/cvd_src/i686/convolve_gaussian.cc:374:5: error: 
      use of undeclared identifier '_mm_setcsr'; did you mean '_mm_set_ss'?
    _mm_setcsr(csr_state);
    ^~~~~~~~~~
    _mm_set_ss
/home/walter/emsdk/emscripten/1.38.15/system/include/SSE/xmmintrin.h:35:1: note: 
      '_mm_set_ss' declared here
_mm_set_ss(float __w)
^
3 errors generated.

This last issue i haven't solved...

@kalwalt kalwalt self-assigned this Apr 26, 2021
@kalwalt kalwalt added the enhancement New feature or request label Apr 26, 2021
@Carnaux
Copy link

Carnaux commented Apr 27, 2021

Maybe we could create a standard setup(hardware-independent?) with Docker? One of the issues might be including different versions of the libraries. We will always get a new file error, at least I always got when trying to build ORB, then you get to a system file that should be there, but it isn't. If we can find a way to do that maybe we can compile it nicely. @thorsten @kalwalt did you compile it without emscripten?

@kalwalt
Copy link
Owner Author

kalwalt commented Apr 27, 2021

Yes a Docker set up would be nice, haven't yet tested the standard compilation.

@ThorstenBux
Copy link

On one Mac I can compile it (the normal compile with make) on the other I get ioStream file not found.

@ThorstenBux
Copy link

Hm, now I can actually build it with EM successfully too. But only on that isolated case.

@kalwalt
Copy link
Owner Author

kalwalt commented Apr 27, 2021

I can compile the static lib with gcc without problems, i will try to build also the apps.

@Carnaux
Copy link

Carnaux commented May 2, 2021

I'm almost compiling it with emscripten, I solved the cvd issues @kalwalt was having, also needed to update the libcvd, use this repo, only copy the cvd and cvd_src folders, maintain the make instructions.

To use the new libcvd:

  1. Rename the config.h.in file
  2. Remove the "Video" folder from the cvd folder
  3. Remove the "ucvbuffer.cc" file from the cvd_src folder

Now I'm getting:

[100%] Building CXX object ptam/CMakeFiles/PTAM.dir/construct/small_blurry_image.cc.o
clang-13: warning: argument unused during compilation: '-stdlib=libstdc++' [-Wunused-command-line-argument]
/home/daniel/Desktop/emscriptenProjects/emsdk/ptam-projects/ptam_plus/thorsten/ptam_plus/ptam/construct/small_blurry_image.cc:122:10: error: no member named 'transform' in namespace 'CVD'
    CVD::transform(mimTemplate, imWarped, se2XForm.get_rotation().get_matrix(),
    ~~~~~^
1 error generated.

Also I'm using ptam_plus as base.

In case you want to use my changes I created this repo

@kalwalt
Copy link
Owner Author

kalwalt commented May 2, 2021

@kalwalt
Copy link
Owner Author

kalwalt commented May 2, 2021

no it is defined here https://github.com/edrosten/libcvd/blob/b30062150f6a5f105df7d1d8a3899ef96170820e/cvd/vision.h#L412 but why it fails? And: which libcvd branch did you used? the say master branch requires C++14.

@kalwalt
Copy link
Owner Author

kalwalt commented May 2, 2021

Testing your ptam_plus.js, it is required to add a define
#if defined(CVD_HAVE_TOON)
https://github.com/edrosten/libcvd/blob/b30062150f6a5f105df7d1d8a3899ef96170820e/cvd/vision.h#L399
but not sure how is best to add.

@kalwalt
Copy link
Owner Author

kalwalt commented May 2, 2021

running emcmake cmake -D=CVD_HAVE_TOON . doesn't change anything.

@Carnaux
Copy link

Carnaux commented May 2, 2021

I was using the master, didn't notice it was c++14. I tried to add it too, but no luck

@kalwalt
Copy link
Owner Author

kalwalt commented May 2, 2021

I was using the master, didn't notice it was c++14. I tried to add it too, but no luck

I think we are very close to a full build!

@Carnaux
Copy link

Carnaux commented May 3, 2021

I was using the master, didn't notice it was c++14. I tried to add it too, but no luck

I think we are very close to a full build!

Yeah, it's already building the ptam files, if I find time I will work on it today.

@Carnaux
Copy link

Carnaux commented May 3, 2021

@ThorstenBux did manage to get the build working on both Mac setups?

@ThorstenBux
Copy link

@ThorstenBux did manage to get the build working on both Mac setups?

No unfortunately only on one.

@kalwalt
Copy link
Owner Author

kalwalt commented May 14, 2021

Hi Daniel @Carnaux have you made some progresses on this side?

@Carnaux
Copy link

Carnaux commented May 16, 2021

Not yet :/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants