[go: up one dir, main page]

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

编译和运行链接so错误 #20

Open
hdq83611 opened this issue Apr 10, 2024 · 4 comments
Open

编译和运行链接so错误 #20

hdq83611 opened this issue Apr 10, 2024 · 4 comments

Comments

@hdq83611
Copy link

按文档编译指示,在Ubuntu22.04上命令行编译
mkdir build
cd build
cmake ..
这都没问题,但是make的时候报错以下,似乎是无法正确引用java依赖库:
[ 20%] Building C object CMakeFiles/gmssljni-native.dir/gmssljni.c.o
[ 40%] Linking C shared library libgmssljni.so
[ 40%] Built target gmssljni-native
[ 60%] Building Java objects for GmSSLJNI.jar
src/main/java/org/gmssl/NativeLoader.java:11: error: package org.apache.maven.model does not exist
import org.apache.maven.model.Model;
^
src/main/java/org/gmssl/NativeLoader.java:12: error: package org.apache.maven.model.io.xpp3 does not exist
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
^
src/main/java/org/gmssl/NativeLoader.java:13: error: package org.codehaus.plexus.util.xml.pull does not exist
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
^
src/main/java/org/gmssl/NativeLoader.java:159: error: cannot find symbol
Model model = new MavenXpp3Reader().read(new FileReader("pom.xml"));
^
symbol: class Model
location: class NativeLoader
src/main/java/org/gmssl/NativeLoader.java:159: error: cannot find symbol
Model model = new MavenXpp3Reader().read(new FileReader("pom.xml"));
^
symbol: class MavenXpp3Reader
location: class NativeLoader
src/main/java/org/gmssl/NativeLoader.java:161: error: cannot find symbol
} catch (IOException | XmlPullParserException e) {
^
symbol: class XmlPullParserException
location: class NativeLoader
6 errors
make[2]: *** [CMakeFiles/GmSSLJNI.dir/build.make:103: CMakeFiles/GmSSLJNI.dir/java_compiled_GmSSLJNI] Error 1
make[1]: *** [CMakeFiles/Makefile2:111: CMakeFiles/GmSSLJNI.dir/all] Error 2
make: *** [Makefile:101: all] Error 2

如果在项目目录下执行mvn install,可以完成编译,但run test时链接错误,报错以下:

T E S T S

Running org.gmssl.Sm2Test
Tests run: 7, Failures: 0, Errors: 7, Skipped: 0, Time elapsed: 0.115 sec <<< FAILURE!
computeZTest(org.gmssl.Sm2Test) Time elapsed: 0.069 sec <<< ERROR!
java.lang.UnsatisfiedLinkError: /home/hdq/trials/GmSSL-Java-main/target/classes/lib/libgmssljni.so: libgmssl.so.3: cannot open shared object file: No such file or directory
at java.base/java.lang.ClassLoader$NativeLibrary.load0(Native Method)
at java.base/java.lang.ClassLoader$NativeLibrary.load(ClassLoader.java:2450)
at java.base/java.lang.ClassLoader$NativeLibrary.loadLibrary(ClassLoader.java:2506)
at java.base/java.lang.ClassLoader.loadLibrary0(ClassLoader.java:2705)
at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2635)
at java.base/java.lang.Runtime.load0(Runtime.java:768)
at java.base/java.lang.System.load(System.java:1854)
at org.gmssl.NativeLoader.loadLibFile(NativeLoader.java:126)
at org.gmssl.NativeLoader.load(NativeLoader.java:59)
at org.gmssl.GmSSLJNI.(GmSSLJNI.java:360)
at org.gmssl.Sm2Key.generateKey(Sm2Key.java:51)
at org.gmssl.Sm2Test.beforeTest(Sm2Test.java:33)
确认GmSSL已安装到/usr/local/lib,且GmSSL和GmSSL-Java都使用最新dev版,甚至均使用readme指示的zip代码也一样。

以上应该都是小问题,请教解决方法,谢谢。

@yxk123
Copy link
Contributor
yxk123 commented Apr 10, 2024

在路径/usr/local/lib检查libgmssl.so.3是否存在

@hdq83611
Copy link
Author

在路径/usr/local/lib检查libgmssl.so.3是否存在

这个问题解决了,是GmSSL安装版本与GmSSL-Java不匹配导致。后重装了一个GmSSL-master.zip,3.1.2-Dev,so库能找到了。
第一个问题还不知道为什么。
谢谢。

@HokiyaJostar
Copy link

我也遇到了相同的问题
image

@yxk123
Copy link
Contributor
yxk123 commented Apr 12, 2024

cmake编译目前不依赖Maven,要更新编译打包方式,在近期更新中解决

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

3 participants