我收到错误 #include <czmq.h>运行程序时丢失 [英] I get error #include <czmq.h> missing when running program
问题描述
过去 4 天我一直在尝试让 Zeromq 在我的 Windows 机器上运行,但似乎没有任何进展.
I am trying from past 4 days to get Zeromq working on my Windows machine but nothings seems to go my way.
我按照给定的步骤解决了一些依赖性问题.
I followed given steps and solved few dependcy issues.
我已经成功构建了 libzmq、czmq、libsodium.
I have build libzmq,czmq,libsodium successfully.
我使用 cmake 3.12 进行配置,使用 VS2015 SDK 8.1 构建解决方案.
I used cmake 3.12 to configure and VS2015 SDK 8.1 to build solution.
我能够运行 czmq_selftest.exe,但是它因为一些事情而失败,这是不同的问题.
I was able to run czmq_selftest.exe however it failed for few things and thats different issue.
但是当我尝试运行基本程序 myapp.c
But when I try to run basic program myapp.c
#include <czmq.h>
int main (void) {
zsock_t *publisher = zsock_new (ZMQ_PUB);
zsock_set_curve_server (publisher, true);
puts ("Hello, Curve!");
zsock_destroy(&publisher);
return 0;
}
我看到这个缺少库的问题,我尝试了给定的链接方法-
I see this missing library issue , I tried given link method-
gcc myapp.c -o myapp -lczmq -lzmq
但没有任何效果,如果有人能提供一些解决方案,那将非常有帮助.
But nothing is working it would be really helpful if someone can provide some solution.
这是其他信息-
OS - Windows 10
Cmake - 3.13.2
Visual Studio 2015, SDK 8.1
libzmq 4.3.0
czmq 4.1.1
来源:https://github.com/zeromq/czmq
更多信息-
我的系统-
C:\Users\P\go\src\github.com\zeromq\czmq\include
包含所有库.
我的程序在 -
C:\Users\P\go\src\github.com\zeromq\czmq\examples\security
谢谢
推荐答案
编译器无法自行跟踪用户可能已安装在系统上的所有库.您必须告诉编译器在哪里可以找到头文件或链接器库等内容.
The compiler can't keep track of all libraries that a user might have installed on a system by itself. You have to tell the compiler where it can find things like header files or linker-libraries.
要告诉编译器向用于搜索头文件的列表添加路径,请使用 -I
(大写 i)选项.
To tell the compiler to add a path to the list it uses for searching for header file, use the -I
(upper-case i) option.
要告诉链接器向用于搜索链接器库的列表添加路径,请使用 -L
选项.
To tell the linker to add a path to the list it uses to search for linker-libraries use the -L
option.
考虑到您在问题和评论中提到的路径,您需要添加 -I../../include
和 -L../../Debug
>.
Considering the paths you mention in your question and comments you need to add both -I../../include
and -L../../Debug
.
也就是说,您的完整命令应该类似于
That is, your complete command should look something like
gcc myapp.c -o myapp -I../../include -L../../Debug -lczmq -lzmq
当然,这需要你在目录 C:\Users\P\go\src\github.com\zeromq\czmq\examples\security
中,如你所说.
Of course, that requires your to be in the directory C:\Users\P\go\src\github.com\zeromq\czmq\examples\security
as you say.
这篇关于我收到错误 #include <czmq.h>运行程序时丢失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!