C++ Compilation Error: zmq.hpp Not Found When Using ZeroMQ with VSCode and MinGW-w64

C++ Compilation Error: zmq.hpp Not Found When Using ZeroMQ with VSCode and MinGW-w64

Manage alerts

Loading saved threads...

Hydra Corporation · External communityPost link
External question — Stack Overflow Stack Exchange Author: Hydra Corporation Original post: https://stackoverflow.com/questions/79166526 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. I am developing a C++ project that utilizes the ZeroMQ library for communication with Python and MetaTrader 4 (MT4). I am setting up my development environment on Windows using VSCode and MinGW-w64 as the compiler. Steps I've taken so far: 1. Cloning the cppzmq Repository: git clone https://github.com/zeromq/cppzmq.git 2.Creating the Directory for ZeroMQ Include Files: mkdir C:\ZeroMQ\include\cppzmq 3.Copying the zmq.hpp File to the Include Directory: Copy-Item "C:\Users\Leonardo Alves\Desktop\Python Projects\project_socket\cppzmq\zmq.hpp" "C:\ZeroMQ\include\cppzmq\" 4.Configuring tasks.json in VSCode: { "version": "2.0.0", "tasks": [ { "label": "Build DLL (Debug)", "type": "shell", "command": "g++", "args": [ "-shared", "-o", "output/mq4socket.dll", "mq4socket.cpp", "-I", "C:/ZeroMQ/include", "-L", "C:/ZeroMQ/lib", "-lzmq", "-g" ], "group": { "kind": "build", "isDefault": true }, "problemMatcher": ["$gcc"] }, { "label": "Build Test App (Debug)", "type": "shell", "command": "g++", "args": [ "-o", "output/test_app.exe", "test_app.cpp", "-I", "C:/ZeroMQ/include", "-L", "C:/ZeroMQ/lib", "-lzmq", "-g" ], "group": { "kind": "build", "isDefault": false }, "problemMatcher": ["$gcc"] } ] } 5.Configuring c_cpp_properties.json in VSCode: { "configurations": [ { "name": "Win32", "includePath": [ "${workspaceFolder}/**", "C:/ZeroMQ/include" ], "defines": [ "_DEBUG", "UNICODE", "_UNICODE" ], "compilerPath": "C:/mingw64/bin/g++.exe", "cStandard": "c11", "cppStandard": "c++17", "intelliSenseMode": "gcc-x64" } ], "version": 4 } Problems: When attempting to compile my mq4socket.cpp code, I receive the following error: c:\Users\Leonardo Alves\Desktop\Python Projects\project_socket\mq4socket.cpp:3:10: fatal error: zmq.hpp: No such file or directory 3 | #include <zmq.hpp> | ^~~~~~~~~ compilation terminated. What I've Checked: The zmq.hpp file is present at C:\ZeroMQ\include\cppzmq\zmq.hpp. The include and library paths in tasks.json appear to be correct. The ZeroMQ libraries are present in C:\ZeroMQ\lib. Questions: How can I resolve the error of zmq.hpp not being found during compilation? Should I adjust the include path or the way I include zmq.hpp in my code? Are there any other configurations I should verify to ensure the compiler can locate the ZeroMQ header files and libraries? Relevant Snippet from My Code (mq4socket.cpp): #include <zmq.hpp> Current Configuration of tasks.json: { "version": "2.0.0", "tasks": [ { "label": "Build DLL (Debug)", "type": "shell", "command": "g++", "args": [ "-shared", "-o", "output/mq4socket.dll", "mq4socket.cpp", "-I", "C:/ZeroMQ/include", "-L", "C:/ZeroMQ/lib", "-lzmq", "-g" ], "group": { "kind": "build", "isDefault": true }, "problemMatcher": ["$gcc"] }, { "label": "Build Test App (Debug)", "type": "shell", "command": "g++", "args": [ "-o", "output/test_app.exe", "test_app.cpp", "-I", "C:/ZeroMQ/include", "-L", "C:/ZeroMQ/lib", "-lzmq", "-g" ], "group": { "kind": "build", "isDefault": false }, "problemMatcher": ["$gcc"] } ] } Current Configuration of c_cpp_properties.json: { "configurations": [ { "name": "Win32", "includePath": [ "${workspaceFolder}/**", "C:/ZeroMQ/include" ], "defines": [ "_DEBUG", "UNICODE", "_UNICODE" ], "compilerPath": "C:/mingw64/bin/g++.exe", "cStandard": "c11", "cppStandard": "c++17", "intelliSenseMode": "gcc-x64" } ], "version": 4 } Any assistance or guidance on resolving this issue would be greatly appreciated!
Quote
Report
john · External communityPost link
External answer — Stack Overflow Stack Exchange Author: john Original post: https://stackoverflow.com/a/79166538 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. You told the compiler to look here "C:/ZeroMQ/include" for this file #include <zmq.hpp> but the file is actually located in C:\ZeroMQ\include\cppzmq\zmq.hpp . This is not correct because the path element cppzmq is not present either in the location where the compiler is looking, or in the path of the header file being looked for. Maybe you thought you were telling the compiler to look in "C:/ZeroMQ/include" or any directory contained therein, but that is not how it works. The simplest (and probably correct) change would be to replace #include <zmq.hpp> with #include <cppzmq/zmq.hpp> The alternative would be to change tasks.json to "-I", "C:/ZeroMQ/include/cppzmq", that seems less likely to be correct, but I don't know this for sure.
Quote
Report

Post Reply

Checking account access…