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

Build from source with ICU extension #1166

Open
Drus566 opened this issue Sep 2, 2024 · 8 comments
Open

Build from source with ICU extension #1166

Drus566 opened this issue Sep 2, 2024 · 8 comments
Labels
question Further information is requested

Comments

@Drus566
Copy link

Drus566 commented Sep 2, 2024

Hello!
Please tell me how to compile jdbc-sqlite.jar from sources with additional ICU module?

Thanks in advance!

@Drus566 Drus566 added the triage label Sep 2, 2024
@gotson gotson added question Further information is requested and removed triage labels Sep 3, 2024
@michael-o
Copy link
Contributor

Have this lib dynamically link against the libsqlite3 with your options.

@Drus566
Copy link
Author

Drus566 commented Sep 5, 2024

Have this lib dynamically link against the libsqlite3 with your options.

I didn't quite understand it at the time of compilation jdbc-sqlite ?

@michael-o
Copy link
Contributor

michael-o commented Sep 5, 2024

Have this lib dynamically link against the libsqlite3 with your options.

I didn't quite understand it at the time of compilation jdbc-sqlite ?

Build sqlite3 first, then link this native code against it.

@Drus566
Copy link
Author

Drus566 commented Sep 6, 2024

Have this lib dynamically link against the libsqlite3 with your options.

I didn't quite understand it at the time of compilation jdbc-sqlite ?

Build sqlite3 first, then link this native code against it.

I try build make native command, but errors

The syntax of the command is incorrect.
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   138  100   138    0     0     17      0  0:00:08  0:00:07  0:00:01    29
  0     0    0     0    0     0      0      0 --:--:--  0:00:11 --:--:--     0Warning: Failed to open the file target/classpath/slf4j-api.jar: No such file
Warning: or directory
  0 41125    0     0    0     0      0      0 --:--:--  0:00:11 --:--:--     0
curl: (23) Failure writing output to destination, passed 16384 returned -1
process_begin: CreateProcess(NULL, $JAVA_HOME/bin/javac -cp target/classpath/slf4j-api.jar -sourcepath src/main/java -d lib src/main/java/org/sqlite/util/OSInfo.java, ...) failed.
Makefile.common:22: pipe: Bad file descriptor
process_begin: CreateProcess(NULL, $JAVA_HOME/bin/java -cp lib:target/classpath/slf4j-api.jar org.sqlite.util.OSInfo --os, ...) failed.
Makefile.common:26: pipe: Bad file descriptor
process_begin: CreateProcess(NULL, $JAVA_HOME/bin/java -cp lib:target/classpath/slf4j-api.jar org.sqlite.util.OSInfo --arch, ...) failed.
Makefile.common:29: pipe: Bad file descriptor
File not found - -L
File not found - -NAME
File not found - JNI.H
File not found - -L
File not found - -NAME
File not found - JNI_MD.H
Will build using target: - (detected os: , arch: )
process_begin: CreateProcess(NULL, env bash C:\Users\LykovA\Desktop\Workplace\Projects\sqlite-jdbc\amalgamation_version.sh 3.46.1, ...) failed.
Makefile:24: pipe: No error
process_begin: CreateProcess(NULL, env bash C:\Users\LykovA\Desktop\Workplace\Projects\sqlite-jdbc\amalgamation_version.sh 3.46.1, ...) failed.
Makefile:24: pipe: No error
process_begin: CreateProcess(NULL, env bash C:\Users\LykovA\Desktop\Workplace\Projects\sqlite-jdbc\amalgamation_version.sh 3.46.1, ...) failed.
Makefile:28: pipe: No error
process_begin: CreateProcess(NULL, dirname target/sqlite-amalgamation-/sqlite3.h, ...) failed.
Makefile:28: pipe: No error
process_begin: CreateProcess(NULL, env bash C:\Users\LykovA\Desktop\Workplace\Projects\sqlite-jdbc\amalgamation_version.sh 3.46.1, ...) failed.
Makefile:108: pipe: No error
process_begin: CreateProcess(NULL, env bash C:\Users\LykovA\Desktop\Workplace\Projects\sqlite-jdbc\amalgamation_version.sh 3.46.1, ...) failed.
Makefile:110: pipe: No error
process_begin: CreateProcess(NULL, env bash C:\Users\LykovA\Desktop\Workplace\Projects\sqlite-jdbc\amalgamation_version.sh 3.46.1, ...) failed.
Makefile:34: pipe: No such file or directory
process_begin: CreateProcess(NULL, env bash C:\Users\LykovA\Desktop\Workplace\Projects\sqlite-jdbc\amalgamation_version.sh 3.46.1, ...) failed.
Makefile:34: pipe: No such file or directory
process_begin: CreateProcess(NULL, env bash C:\Users\LykovA\Desktop\Workplace\Projects\sqlite-jdbc\amalgamation_version.sh 3.46.1, ...) failed.
Makefile:34: pipe: No such file or directory
process_begin: CreateProcess(NULL, env bash C:\Users\LykovA\Desktop\Workplace\Projects\sqlite-jdbc\amalgamation_version.sh 3.46.1, ...) failed.
Makefile:34: pipe: No such file or directory
process_begin: CreateProcess(NULL, env bash C:\Users\LykovA\Desktop\Workplace\Projects\sqlite-jdbc\amalgamation_version.sh 3.46.1, ...) failed.
Makefile:34: pipe: No such file or directory
process_begin: CreateProcess(NULL, env bash C:\Users\LykovA\Desktop\Workplace\Projects\sqlite-jdbc\amalgamation_version.sh 3.46.1, ...) failed.
Makefile:34: pipe: No such file or directory
curl -L --max-redirs 0 -f -otarget/sqlite-3.46.1-amal.zip https://www.sqlite.org/2024/sqlite-amalgamation-.zip || \
curl -L --max-redirs 0 -f -otarget/sqlite-3.46.1-amal.zip https://www.sqlite.org/2023/sqlite-amalgamation-.zip || \
curl -L --max-redirs 0 -f -otarget/sqlite-3.46.1-amal.zip https://www.sqlite.org/2022/sqlite-amalgamation-.zip || \
curl -L --max-redirs 0 -f -otarget/sqlite-3.46.1-amal.zip https://www.sqlite.org/2021/sqlite-amalgamation-.zip || \
curl -L --max-redirs 0 -f -otarget/sqlite-3.46.1-amal.zip https://www.sqlite.org/2020/sqlite-amalgamation-.zip || \
curl -L --max-redirs 0 -f -otarget/sqlite-3.46.1-amal.zip https://www.sqlite.org/sqlite-amalgamation-.zip || \
curl -L --max-redirs 0 -f -otarget/sqlite-3.46.1-amal.zip https://www.sqlite.org/sqlite-amalgamation-3_46_1.zip
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:--  0:00:07 --:--:--     0
curl: (22) The requested URL returned error: 404
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
curl: (22) The requested URL returned error: 404
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
curl: (22) The requested URL returned error: 404
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
curl: (22) The requested URL returned error: 404
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
curl: (22) The requested URL returned error: 404
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
curl: (22) The requested URL returned error: 404
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
curl: (22) The requested URL returned error: 404
make: *** [Makefile:34: target/sqlite-3.46.1-amal.zip] Error 22

If you build a project using mvn package, all ok, but i try load dinamyc library, but this not work

    public Application() {
        String url = "jdbc:sqlite:example.db";
        Connection connection = null;
        Properties properties = new Properties();
        properties.setProperty("enable_load_extension", String.valueOf(true));

        try {
            connection = DriverManager.getConnection(url,properties);
            Statement sm = connection.createStatement();
//        I TRY DIFFERENT VARIANTS
//            ResultSet rr = sm.executeQuery("select * from");
//            sm.execute("SELECT load_extension('libSqliteIcu64');");
//            sm.execute("SELECT load_extension('C:\\Users\\LykovA\\Desktop\\Workplace\\Projects\\untitled1\\dll\\libSqliteIcu64',sqlite3_extension_init);");

            String searchName = "%а%";
            String sql = "SELECT * FROM users WHERE LOWER(name) LIKE LOWER('" + searchName + "')";
            ResultSet rs = sm.executeQuery(sql);

            // Обработка результатов
            while (rs.next()) {
                int id = rs.getInt("id");
                String name = rs.getString("name");
                int age = rs.getInt("age");
                System.out.println("ID: " + id + ", Name: " + name + ", Age: " + age);
            }

            // Закрытие ResultSet
            rs.close();


        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
}

@Drus566
Copy link
Author

Drus566 commented Sep 6, 2024

How i can compile jdbc-sqlite with new native (own-compiled from source code) sqlite.dll ?
I try do this, but get errors, from mvn package command, errors related to unfound functions

@gotson
Copy link
Collaborator

gotson commented Sep 6, 2024

How i can compile jdbc-sqlite with new native (own-compiled from source code) sqlite.dll ? I try do this, but get errors, from mvn package command, errors related to unfound functions

you don't need to. You can load your own sqlite.dll.

@Drus566
Copy link
Author

Drus566 commented Sep 6, 2024

How i can compile jdbc-sqlite with new native (own-compiled from source code) sqlite.dll ? I try do this, but get errors, from mvn package command, errors related to unfound functions

you don't need to. You can load your own sqlite.dll.

Thank you, but i try this with sqlite with icu extension dll and get error:

Exception in thread "main" java.lang.UnsatisfiedLinkError: org.sqlite.core.NativeDB._open_utf8([BI)V
	at org.sqlite.core.NativeDB._open_utf8(Native Method)
	at org.sqlite.core.NativeDB._open(NativeDB.java:81)
	at org.sqlite.core.DB.open(DB.java:216)
	at org.sqlite.SQLiteConnection.open(SQLiteConnection.java:287)
	at org.sqlite.SQLiteConnection.<init>(SQLiteConnection.java:67)
	at org.sqlite.jdbc3.JDBC3Connection.<init>(JDBC3Connection.java:28)
	at org.sqlite.jdbc4.JDBC4Connection.<init>(JDBC4Connection.java:19)
	at org.sqlite.JDBC.createConnection(JDBC.java:106)
	at org.sqlite.JDBC.connect(JDBC.java:79)
	at java.sql.DriverManager.getConnection(DriverManager.java:664)
	at java.sql.DriverManager.getConnection(DriverManager.java:208)
	at Application.<init>(Application.java:23)
	at Application.main(Application.java:11)

I do this with compile from source code sqlite dll without icu, but get same error.

But when i get sqlite dll from source code jdbc-sqlite, it worked.

Maybe i missing flag when compile source code? For example. I build from mingw32 for windows ?

 gcc -I. -shared -fPIC sqlite3.c -ldl -lm -lreadline -lncurses -o sqlite3_32.dll

Help me please

@gotson
Copy link
Collaborator

gotson commented Sep 24, 2024

you can check here https://github.com/xerial/sqlite-jdbc/blob/master/.github/workflows/ci.yml#L157-L181 how we build against an external amalgamation

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

No branches or pull requests

3 participants