ekuiper icon indicating copy to clipboard operation
ekuiper copied to clipboard

How to compile the SQL source plugin?

Open Maingol opened this issue 1 year ago • 13 comments

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?

Maingol avatar Jul 04 '24 08:07 Maingol

@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

ngjaying avatar Jul 04 '24 08:07 ngjaying

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

Maingol avatar Jul 04 '24 09:07 Maingol

@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.

ngjaying avatar Jul 04 '24 09:07 ngjaying

@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.

Maingol avatar Jul 04 '24 09:07 Maingol

What about attach the zip file?

ngjaying avatar Jul 04 '24 09:07 ngjaying

@ngjaying sure,here it is sql.zip

Maingol avatar Jul 04 '24 09:07 Maingol

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.

ngjaying avatar Jul 04 '24 09:07 ngjaying

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

Maingol avatar Jul 04 '24 09:07 Maingol

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

Maingol avatar Jul 04 '24 09:07 Maingol

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.

ngjaying avatar Jul 04 '24 09:07 ngjaying

@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

Maingol avatar Jul 05 '24 04:07 Maingol

Please paste the log

ngjaying avatar Jul 05 '24 05:07 ngjaying

@ngjaying 13341720159626_ pic

Maingol avatar Jul 05 '24 06:07 Maingol

Close for now, reopen if you still have problems

ngjaying avatar Aug 15 '25 06:08 ngjaying