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

在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日
  • 展开全部

悬赏问题

  • ¥15 远程桌面文档内容复制粘贴,格式会变化
  • ¥15 关于#java#的问题:找一份能快速看完mooc视频的代码
  • ¥15 这种微信登录授权 谁可以做啊
  • ¥15 请问我该如何添加自己的数据去运行蚁群算法代码
  • ¥20 用HslCommunication 连接欧姆龙 plc有时会连接失败。报异常为“未知错误”
  • ¥15 网络设备配置与管理这个该怎么弄
  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题