I'm trying to run a sample c++ program using crow but getting the error fatal error: asio.hpp: No such file or directory
Installed crow using the instructions in https://crowcpp.org/master/getting_started/setup/linux/#installing-from-source
Followed the instructions and created a crow_all.h file.
Copied and created a sample crowtest.cpp program from the crow website
#include "crow_all.h"
int main()
{
crow::SimpleApp app;
CROW_ROUTE(app, "/")([](){
return "Hello world";
});
app.port(18080).run();
}
Compiled the code g++ crowtest.cpp -o crowtest.o
But getting the following error
In file included from crowtest.cpp:1:
crow_all.h:931:10: fatal error: asio.hpp: No such file or directory
931 | #include <asio.hpp>
| ^~~~~~~~~~
compilation terminated.
Note: Also installed boost using apt install libboost-dev
I'm new to c++ and crow, can anyone please help.
The include isn't the Boost Asio, but the standalone asio: https://think-async.com/Asio/AsioStandalone.html
They're practically the same, so you can probably also get it working with
#include <boost/asio.hpp>
namespace asio = boost::asio;
But if you don't feel confident that you know how to fix any issues, just download the expected version.
Related
I'm trying to use asio in VSCode with C++. I keep getting the warning:
fatal error: 'asio.hpp' file not found
#include <asio.hpp>
Using the code:
#include <iostream>
#include <asio.hpp>
#include <asio/ts/buffer.hpp>
#include <asio/ts/internet.hpp>
int main(){
asio::error_code ec;
//Create a 'context which is like a platform specific interface
asio::io_context context;
//Get the address of somewhere we wish to connect to
asio::ip::tcp::endpoint endpoint(asio::ip::make_address("93.184.216.34", ec),80);
return 0;
}
In the include path UI settings, I have the following paths listed which should take care of things:
${workspaceFolder}/**
/opt/homebrew/Cellar/asio/**
/opt/homebrew/Cellar/asio/1.24.0_1/include
/opt/homebrew/Cellar/boost/**
/opt/homebrew/Cellar/boost/1.81.0/include/boost
/opt/homebrew/Cellar/boost/1.81.0/include
/Library/Developer/CommandLineTools/SDKs/MacOSX13.1.sdk/usr/include
(there are redundant paths here but I am trying everything at this point)
Finally, it should be able to find the file since the file is there:
ls /opt/homebrew/Cellar/asio/1.24.0_1/include ls /opt/homebrew/Cellar/asio/1.24.0_1/include
Gives:
/opt/homebrew/Cellar/asio/1.24.0_1/include:
asio asio.hpp
I would expect it to just find those files. I have also installed boost using brew. It is available at the boost path included.
I am using Mac M1 with Monterey 12.5.1, and VSCode Version: 1.74.2.
Thanks for the help!
The includePath element in the json file is for intelliSense and not your compiler. If you aren't using CMake you will have to go into tasks.json, there you can specify additional compiler flags.
You want to add a flag: -Ipath/to/asio.
I installed Aspose.Cells and tried to write a simple C++ file that includes Aspose.Cells.h. I soon realized that I had to install two other external libraries, boost and icu4c as without these libraries my compiler would throw errors saying some h or hpp files can not be found.
My problem is: even after I installed these libraries, I still couldn’t compile my code, as I received a new error saying “Fatal ERROR: comdef.h: No such file or directory.”
And the error persisted even after I installed the latest version for SDK for Win 10.
My simple file can run if I remove the line "#include Aspose.Cells.h" .
Can someone please enlighten me as to how to solve this error?
Also I noticed there is a folder called “Publish” under “include” folder for Aspose.Cells. This folder is besides boost and icu. Could this mean Publish is the third external library to be installed? But I couldn’t find any library called Public on the web. Pls see the screenshot below.
directory of include folder that comes with the installed Aspose.Cells package
Thanks a lot!
My code is as follows:
#include <iostream>
#include <Aspose.Cells.h>
using namespace std;
int main() {
cout << "hello!!!" << endl;
return 0;
}
Regards
Hillary
After installing LLVM and Clank from a cydia repo I am trying to compile a c++ program using iTerminal
I am running the following command with the following result:
~ mobile$ clang++ test.cpp
In file included from test.cpp:1:
In file included from /usr/include/stdio.h:64:
/usr/include/_types.h:27:10: fatal error:
'sys/_types.h' file not found
#include <sys/_types.h>
^
1 error generated
My code:
#include <stdio.h>
int main()
{
}
How do I fix this?
This code is being written, compiled, and (soon to be) run entirely on an ipod touch.
I have a compilation error in my program related to the included files, in my program I am including this files:
#include "clang/AST/ASTConsumer.h"
#include "clang/AST/RecursiveASTVisitor.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Frontend/FrontendAction.h"
#include "clang/Tooling/Tooling.h"
The error message I get when I compile the program using g++ is:
In file included from /usr/include/clang/AST/APValue.h:17:0,
from /usr/include/clang/AST/Decl.h:17,
from /usr/include/clang/AST/RecursiveASTVisitor.h:17,
from FindClassDecls.cpp:2:
/usr/include/clang/Basic/LLVM.h:20:34: fatal error: llvm/Support/Casting.h: No such file or directory
compilation terminated.
I don't have any idea how to solve the problem, and also I am not sure that I installed the CLang library correctly, so can you please tell me how to solve the problem or how to install it correctly on linux (Ubuntu).
It seems that you have the Clang headers installed, but not the LLVM headers (which Clang relies upon). When you are compiling your code, you need to pass the path of LLVM headers with -I to your compiler, as usual.
I'd grab a pre-built Clang+LLVM from the Download page and compile/link against that.
sudo apt-get install libclang-3.8-dev # or libclang-3.9-dev
I'm new to the boost C++ library and I'm trying to use boost with python. Whenever I compile my simple test program I get an error:
error: pyconfig.h: No such file or dirctory
(followed by thousand more errors which I'm sure are because of this missing header).
I downloaded boost from it's website and then built the library. I still have no idea why that file is missing and how to get it. Please help!
I'm using code::blocks MinGW compiler and I have pointed code blocks to the boost folder as a search directory for headers as well as libraries.
Here's my simple program:
#include <boost/python.hpp>
using namespace boost::python;
int main()
{
Py_Initialize();
PyRun_SimpleString("from time import time,ctime\n"
"print ’Today is’,ctime(time())\n");
Py_Finalize();
return 0;
}
You apparently do not have the CPython headers in your include path. Just having boost::python is not enough, you need Python itself, too.