![](/img/trans.png)
[英]How can I compile a C console program using Cairo library (that compiles ok on Ubuntu) on Windows 11?
[英]How to compile a C program using a library
我对使用C语言进行编程还很陌生。对于我的论文,我必须使用http://www.libquantum.de/网站上的“ Libquantum”库。 我在记事本中编写代码,然后使用命令窗口进行编译。 我下载了mingw并使用gcc进行编译。
对于普通的C程序,一切正常。 例如,我使用命令gcc -o HelloWorld HelloWorld.c
,程序可以正常编译。 但是我无法在使用该库的地方编译程序...
我下载的图书馆和使用的命令./configure
, make
......, make install
像他们的安装指南(中提到https://github.com/jonbaer/libquantum/blob/master/INSTALL )。 最后一条命令后,命令窗口显示如下:
我确保在代码中包含#include <quantum.h>
,并在尝试编译时在不同位置尝试了链接程序标志-lquantum
,但无济于事。
当我尝试编译时,出现以下错误
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: cannot find -lquantum
collect2.exe: error: ld returned 1 exit status
如make install
输出所示,您需要使用-L<path>
选项告诉链接器库在哪里。 make install
将库放置在\\usr\\local\\lib
。 如果要在MSYS中执行构建,则可以使用-L\\usr\\local\\lib
,但是如果已移动文件,请根据需要进行更改。
如果要从cmd.exe(Windows的外壳程序)而不是MSYS进行构建,则必须使用其本机Windows路径。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.