我在使用windows环境下的clion上去安装密码学的miracle库,提示
undefined reference to `mirsys'
D:\CLion 2022.1.3\bin\mingw\bin/ld.exe: F:/sm9pro/test.c:12: undefined reference to `mirvar'
D:\CLion 2022.1.3\bin\mingw\bin/ld.exe: F:/sm9pro/test.c:14: undefined reference to `cotnum'
D:\CLion 2022.1.3\bin\mingw\bin/ld.exe: F:/sm9pro/test.c:15: undefined reference to `cinnum'
D:\CLion 2022.1.3\bin\mingw\bin/ld.exe: F:/sm9pro/test.c:16: undefined reference to `cotnum'
collect2.exe: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
cmake代码是这样的
cmake_minimum_required(VERSION 3.20)
project(sm9pro)
include_directories(miracl/include/miracl)
link_directories(miracl/lib)
add_executable(test test.c)
target_link_directories(test PUBLIC glut32.lib miracl.h mirdef.h)
undefined reference to `mirsys'
D:\CLion 2022.1.3\bin\mingw\bin/ld.exe: F:/sm9pro/test.c:12: undefined reference to `mirvar'
D:\CLion 2022.1.3\bin\mingw\bin/ld.exe: F:/sm9pro/test.c:14: undefined reference to `cotnum'
D:\CLion 2022.1.3\bin\mingw\bin/ld.exe: F:/sm9pro/test.c:15: undefined reference to `cinnum'
D:\CLion 2022.1.3\bin\mingw\bin/ld.exe: F:/sm9pro/test.c:16: undefined reference to `cotnum'
collect2.exe: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
我把这些lib h文件移植到vs2022上面去就可以正常运行
可以在clion上使用miracl库
target_link_directories(test PUBLIC glut32.lib miracl.h mirdef.h)
这里是链接库文件,改为
target_link_directories(test PUBLIC glut32.lib miracl.lib)