Closed
Description
C++ Code:
#include <iostream>
using namespace std;
extern "C" {
void ReadHead(char *path)
{
if ((m_ShpFile_fp = fopen(path, "rb")) == NULL)
{
return;
}
fread(&file_Head.FileCode, sizeof(int), 1, m_ShpFile_fp);
fread(&file_Head.FileLength, sizeof(int), 1, m_ShpFile_fp);
file_Head.FileLength = OnChangeByteOrder(file_Head.FileLength);
fread(&file_Head.ShapeType, sizeof(int), 1, m_ShpFile_fp);
...
}
}
here, the functions "fopen" and "fread" can not be found。
emcc:
emcc shp.cpp -Os -s WASM=1 -s SIDE_MODULE=1 -o shp.wasm
wasm file:
...
(import "env" "_fopen" (func $env._fopen (type $t0)))
(import "env" "_fread" (func $env._fread (type $t8)))
...
Error:
- Uncaught (in promise) LinkError: Import GHC output: TypeError: Cannot read property 'tokens' #1 module="env" function="_fopen" error: function import requires a callable at fetch.then.then.then.module (http://127.0.0.1:5500/index.html:126:36)
- Uncaught (in promise) LinkError: Import GHC output: TypeError: Cannot read property 'tokens' #1 module="env" function="_fread" error: function import requires a callable at fetch.then.then.then.module (http://127.0.0.1:5500/index.html:126:36)
Here are some of the errors listed. I think it may be that emcc
compiles without introducing the required lib
, which is the header file (.h
).
Metadata
Metadata
Assignees
Labels
No labels