lf-edge / ekuiper

Lightweight data stream processing engine for IoT edge
https://ekuiper.org
Apache License 2.0
1.47k stars 413 forks source link

How to compile the SQL source plugin? #2986

Open Maingol opened 3 months ago

Maingol commented 3 months ago

I want to compile the SQL source plugin myself. The reference documentation is:

image

After modifying the source code, I executed the following command in a CentOS 7 virtual machine on Windows:

go build -trimpath --buildmode=plugin -o plugins/sources/Sql.so extensions/sources/sql/*.go

This produced Sql.so, which I placed in the sql directory and then compressed into a sql.zip file. The directory structure is as follows:

.
├── Sql.so
├── ext
│   ├── convert.go
│   ├── sql.go
│   ├── sqlLookup.go
│   └── sql_test.go
├── sql.go
├── sql.json
├── sql.yaml
└── sqlLookup.go

The .zip file uploaded successfully, but the plugin could not be created. The error message is as follows: image

How to resolve it?

ngjaying commented 3 months ago

@Maingol The .so/.json file and .yaml (if any) must be in the root of the zip file. It seems you put it in a directory named sql

Maingol commented 3 months ago

@ngjaying Here is the root directory after extracting the zip file, and I don't think I made the mistake you mentioned. image

ngjaying commented 3 months ago

@Maingol In the zip file, did you have that sql directory in the root? We cannot tell from this screenshot. Sql.so must be in the root of the zip.

Maingol commented 3 months ago

@ngjaying This is the result after extracting the sql.zip file. There is no other way to explain it further. What you see is the root directory after extraction, and both the .so and .json files are in the root directory.

ngjaying commented 3 months ago

What about attach the zip file?

Maingol commented 3 months ago

@ngjaying sure,here it is sql.zip

ngjaying commented 3 months ago

image See, inside zip file you have a redundant directory. Do not contain the sql directory in the zip. Move the so out of it.

Maingol commented 3 months ago

you are right,and now another mistake comes,”invalid ELF header“

Maingol commented 3 months ago

maybe the CentOS 7 virtual machine in windows can not compile the expected file?

ngjaying commented 3 months ago

If you run with docker image, you can install pre-compiled plugin, check https://ekuiper.org/docs/en/latest/operation/manager-ui/plugins_in_manager.html. If you do need to build by yourself, check https://ekuiper.org/docs/en/latest/extension/native/develop/plugins_tutorial.html

Golang plugin system has very strict restriction. You need to make sure you build eKuiper and plugin with nearly the same environment including go version or even package path.

Maingol commented 3 months ago

@ngjaying

I completed the plugin compilation in a Docker environment, and then uploaded the zip file in the eKuiper management panel. However, when I clicked submit, an error was reported saying that the .so file could not be found in the corresponding directory. I checked the eKuiper server and indeed, the file was not there. I manually copied the .so file to that directory, but after submitting again, the .so file I copied was automatically deleted, and the same error persisted, stating that the .so file could not be found in the corresponding directory. image

ngjaying commented 3 months ago

Please paste the log

Maingol commented 3 months ago

@ngjaying 13341720159626_ pic