行 待 2022-09-28 10:04 采纳率: 50%
浏览 143
已结题

在windows环境下使用clion安装miracl库c语言

问题遇到的现象和发生背景

我在使用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)

运行结果及报错内容

img

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上面去就可以正常运行

img

我想要达到的结果

可以在clion上使用miracl库

  • 写回答

1条回答 默认 最新

  • 浪客 2022-09-28 10:22
    关注

    target_link_directories(test PUBLIC glut32.lib miracl.h mirdef.h)
    这里是链接库文件,改为
    target_link_directories(test PUBLIC glut32.lib miracl.lib)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 系统已结题 10月6日
  • 已采纳回答 9月28日
  • 赞助了问题酬金15元 9月28日
  • 赞助了问题酬金1元 9月28日
  • 展开全部