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

How to compile the SQL source plugin? #2986

Open
Maingol opened this issue Jul 4, 2024 · 13 comments
Open

How to compile the SQL source plugin? #2986

Maingol opened this issue Jul 4, 2024 · 13 comments

Comments

@Maingol
Copy link

Maingol commented Jul 4, 2024

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
Copy link
Collaborator

ngjaying commented Jul 4, 2024

@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
Copy link
Author

Maingol commented Jul 4, 2024

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

@ngjaying
Copy link
Collaborator

ngjaying commented Jul 4, 2024

@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
Copy link
Author

Maingol commented Jul 4, 2024

@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
Copy link
Collaborator

ngjaying commented Jul 4, 2024

What about attach the zip file?

@Maingol
Copy link
Author

Maingol commented Jul 4, 2024

@ngjaying
sure,here it is
sql.zip

@ngjaying
Copy link
Collaborator

ngjaying commented Jul 4, 2024

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
Copy link
Author

Maingol commented Jul 4, 2024

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

@Maingol
Copy link
Author

Maingol commented Jul 4, 2024

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

@ngjaying
Copy link
Collaborator

ngjaying commented Jul 4, 2024

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
Copy link
Author

Maingol commented Jul 5, 2024

@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
Copy link
Collaborator

ngjaying commented Jul 5, 2024

Please paste the log

@Maingol
Copy link
Author

Maingol commented Jul 5, 2024

@ngjaying
13341720159626_ pic

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

No branches or pull requests

2 participants