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

channel01.cpp : /usr/include/stlab/concurrency/variant.hpp:37:10: fatal error: boost/variant.hpp: No such file or directory #142

Closed
marcoippolito opened this issue May 18, 2018 · 9 comments

Comments

@marcoippolito
Copy link

First example channel taken here: https://github.com/FelixPetriconi/accu2017_course/tree/master/Channels

`#include <stlab/concurrency/channel.hpp>
 #include <stlab/concurrency/default_executor.hpp>
  #include <iostream>

  int main() {
    stlab::sender<int> send;       // sending part of the channel
    stlab::receiver<int> receiver; // receiving part of the channel
    std::tie(send, receiver) =     // combining both to a channel
    stlab::channel<int>(stlab::default_executor);

    auto printer =
      [](int x){ std::cout << x << '\n'; };       // stateless process

    auto printer_process =
      receiver | printer;                                  // attaching process to the receiving
                                                                                                                             // part
    receiver.set_ready();          // no more processes will be attached
                                                                                                                             // process starts to work
    send(1); send(2); send(3);     // start sending into the channel
    int end; std::cin >> end;      // simply wait to end application
    return 0;
  }
 `

When compiling:

`accu2017_course-master/Channels$ g++ -std=c++17 channel01.cpp -ochannel01`

`In file included from /usr/include/stlab/concurrency/channel.hpp:26:0,
                 from channel01.cpp:1:
 /usr/include/stlab/concurrency/variant.hpp:37:10: fatal error: boost/variant.hpp: No such file or    
 directory
  #include <boost/variant.hpp>
           ^~~~~~~~~~~~~~~~~~~
 compilation terminated.
`

Do I have to install boost even if I use C++17 ?

Marco

@FelixPetriconi
Copy link
Member

I think you have found a hole in the lib. Could you try to add in file stlab/concurrency/config.hpp below line 58 (#define STLAB_TASK_SYSTEM STLAB_TASK_SYSTEM_PORTABLE) the lines

#if __cplusplus >= 201703L
#define STLAB_CPP_VERSION 17
#endif

? I think it does not recognize that it should work with C++17 on Linux.

@marcoippolito
Copy link
Author

marcoippolito commented May 18, 2018

After adding the suggested lines below line 58 in file /usr/include/stlab/concurrency/config.hpp :

`// Default configuration

#ifndef STLAB_TASK_SYSTEM
#define STLAB_TASK_SYSTEM STLAB_TASK_SYSTEM_PORTABLE
#if __cplusplus >= 201703L
#define STLAB_CPP_VERSION 17
#endif
#endif
`

The compilation gives the following error messages:

CompilationErrors.txt

@FelixPetriconi
Copy link
Member

I found the problem: std::optional does not allow an instantiation of a reference type (compared to boost::optional) So you either have to attach the process directly as written below or put it into a struct, that implements the operator().

`
#include <stlab/concurrency/channel.hpp>
#include <stlab/concurrency/default_executor.hpp>
#include

int main() {
stlab::sender send; // sending part of the channel
stlab::receiver receiver; // receiving part of the channel
std::tie(send, receiver) = // combining both to a channel
stlab::channel(stlab::default_executor);

auto printer_process =
  receiver | [](int x){ std::cout << x << '\n'; };         // attaching process to the receiving
                                                                                   // part
receiver.set_ready();          // no more processes will be attached
                                             // process starts to work
send(1); send(2); send(3);     // start sending into the channel
int end; std::cin >> end;      // simply wait to end application
return 0;

}
`

@marcoippolito
Copy link
Author

After directly attaching the process to the receiving part, the error messages changed
CompilationErrors2.txt

@FelixPetriconi
Copy link
Member

You have to add to channel.hpp an #include
It depends a bit to the distributions, if you have to add it manually.
I will change it in the repo.

@marcoippolito
Copy link
Author

After adding in /usr/include/stlab/concurrency/channel.hpp

 `#include <assert>`

`/Channels$ g++ -std=c++17 channel01.cpp -pthread -ochannel01
 ./channel01
1
2
3
`

I close the issue

@FelixPetriconi
Copy link
Member

Fixed with PR #148

@FelixPetriconi
Copy link
Member

Reopend for release note

@FelixPetriconi
Copy link
Member

Fixed in 1.2.0

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

No branches or pull requests

2 participants