Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot use in CLang C++ 20 #178

Open
ctigrisht opened this issue Feb 4, 2023 · 5 comments
Open

Cannot use in CLang C++ 20 #178

ctigrisht opened this issue Feb 4, 2023 · 5 comments

Comments

@ctigrisht
Copy link

I am trying to use this in a CLang C++ 20 in visual studio 2022 project and I get errors, it works fine with Microsoft's compiler

image

@eao197
Copy link
Member

eao197 commented Feb 4, 2023

Hi!

Can you provide a description how to reproduce your problem?

@ctigrisht
Copy link
Author

ctigrisht commented Feb 5, 2023

Hi!

Can you provide a description how to reproduce your problem?

Hey,
I created a windows only C++ project in VS 2022.
I tried installing from vcpkg first, using vcpkg install restinio, it gave the the error so I just cloned source code and put it inside 'Libraries' folder and included all.hpp.

I then create some code in main:

// other includes
#include "Libraries/restinio/all.hpp"

int main()
{
	auto port = 5690;
	auto address = "localhost";
	restinio::run(
		restinio::on_thread_pool(2)
		.port(port)
		.address(address)
		.request_handler([](auto req) {
			return req->create_response().set_body("Hello, World!").done();
			})
	);

	return 0;
}

The above code works fine with Microsoft compiler, but not clang. No errors in the code tho, only his lld-link

EDIT: It doesn't work with any CLang C++ version, not just 20

image

@eao197
Copy link
Member

eao197 commented Feb 5, 2023

Thanks for an explanation.

RESTinio itself is a header-only project, but it requires at least one dependency that should be compiled and then linked to the resulting executable: http_parser. fmtlib can be used as a header only or as a compiled library.

I suppose that when you build your example by using VC++ then some pragma lib in http_parser/fmtlib are taken into the account by the compiler/linker. In the case of clang you have to add http_parser and fmtlib to your project.

@ctigrisht
Copy link
Author

add http_parser and fmtlib to your project

Do you mean link it within clang or embed it as source?

@eao197
Copy link
Member

eao197 commented Feb 5, 2023

I mean that you have to compile and link http_parser. You can do it as a separate library or by including its source into your project.

BTW, you can found more information about building RESTinio here: https://stiffstream.com/en/docs/restinio/0.6/obtaining.html#build

PS. I don't use VisualStudio and don't know how to use VisualStudio projects. I hope VisualStudio supports CMakeLists.txt files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants