Skip to content

Fix build error resulting from assigning boost::uuids::random_generator#41

Merged
DanielSWolf merged 3 commits intoDanielSWolf:masterfrom
argent0:linux-build-fix
Jul 19, 2018
Merged

Fix build error resulting from assigning boost::uuids::random_generator#41
DanielSWolf merged 3 commits intoDanielSWolf:masterfrom
argent0:linux-build-fix

Conversation

@argent0
Copy link
Copy Markdown
Contributor

@argent0 argent0 commented Jul 18, 2018

Hi, I had trouble building rhubarb on linux using boost 1.67.0

[ 71%] Building CXX object CMakeFiles/rhubarb-tools.dir/src/tools/platformTools.cpp.o                                        
/home/rhubarb_user/Docs/...../rhubarb-lip-sync/rhubarb/src/tools/platformTools.cpp: In function ‘boost::filesyst
em::path getTempFilePath()’:                                                                                                 
/home/rhubarb_user/Docs/...../rhubarb-lip-sync/rhubarb/src/tools/platformTools.cpp:60:60: error: use of deleted 
function ‘boost::uuids::random_generator_pure::random_generator_pure(boost::uuids::random_generator_pure&&)’                 
  static auto generateUuid = boost::uuids::random_generator();                                                               
                                                            ^                                                                
In file included from /usr/include/boost/uuid/uuid_generators.hpp:17,                                                        
                 from /home/rhubarb_user/Docs/...../rhubarb-lip-sync/rhubarb/src/tools/platformTools.cpp:5:     
/usr/include/boost/uuid/random_generator.hpp:149:7: note: ‘boost::uuids::random_generator_pure::random_generator_pure(boost::
uuids::random_generator_pure&&)’ is implicitly deleted because the default definition would be ill-formed:                   
 class random_generator_pure                                                                                                 
       ^~~~~~~~~~~~~~~~~~~~~                                                                                                 
/usr/include/boost/uuid/random_generator.hpp:149:7: error: use of deleted function ‘boost::uuids::detail::random_provider::ra
ndom_provider(boost::uuids::detail::random_provider&&)’                                                                      
In file included from /usr/include/boost/uuid/random_generator.hpp:20,                                                       
                 from /usr/include/boost/uuid/uuid_generators.hpp:17,                                            
                 from /home/rhubarb_user/Docs/...../rhubarb-lip-sync/rhubarb/src/tools/platformTools.cpp:5:
/usr/include/boost/uuid/detail/random_provider.hpp:41:7: note: ‘boost::uuids::detail::random_provider::random_provider(boost$
:uuids::detail::random_provider&&)’ is implicitly deleted because the default definition would be ill-formed:               
 class random_provider                                                                                                      
       ^~~~~~~~~~~~~~~                                                                                          
/usr/include/boost/uuid/detail/random_provider.hpp:41:7: error: use of deleted function ‘boost::noncopyable_::noncopyable::n$ncopyable(const boost::noncopyable_::noncopyable&)’                                                             
In file included from /usr/include/boost/noncopyable.hpp:15,                                                                
                 from /usr/include/boost/system/error_code.hpp:18,                                                         
                 from /usr/include/boost/filesystem/path_traits.hpp:23,                                                    
                 from /usr/include/boost/filesystem/path.hpp:25,                                                            
                 from /usr/include/boost/filesystem/operations.hpp:25,                                             
                 from /home/rhubarb_user/Docs/...../rhubarb-lip-sync/rhubarb/src/tools/platformTools.cpp:1:
/usr/include/boost/core/noncopyable.hpp:34:7: note: declared here                                                
       noncopyable( const noncopyable& ) = delete;                                                                          
       ^~~~~~~~~~~                                                                                             
make[2]: *** [CMakeFiles/rhubarb-tools.dir/build.make:89: CMakeFiles/rhubarb-tools.dir/src/tools/platformTools.cpp.o] Error $
make[1]: *** [CMakeFiles/Makefile2:651: CMakeFiles/rhubarb-tools.dir/all] Error 2                                        
make: *** [Makefile:130: all] Error 2

This fixes the issue for me. What do you think?

@sh-dave
Copy link
Copy Markdown

sh-dave commented Jul 19, 2018

Your changes will create a new generator every time the function is called, which might affect performance depending on how often temporary files are created. Maybe try this instead?

static boost::uuids::random_generator generateUuid;
string fileName = to_string(generateUuid());

@DanielSWolf
Copy link
Copy Markdown
Owner

@argent0 Thanks for pointing me to this code. The line I originally wrote certainly doesn't make sense. It creates a new boost::uuids::random_generator, then assigns it to a new variable. This certainly isn't idiomatic C++. As @sh-dave noted, a simple variable declaration should work fine. Plus, it avoids the overhead of creating a new random generator for each random number.

My guess is that depending on the compiler, my original code may or may not invoke the move constructor, which seems to be missing at least from your version of Boost, leading to your compile error.

Could you change your pull request to use @sh-dave's approach instead, then tell me whether it still works for you?

argent0 added 2 commits July 19, 2018 14:29
This time explicitly writing the type.
@argent0
Copy link
Copy Markdown
Contributor Author

argent0 commented Jul 19, 2018

Hi, I applied @sh-dave suggestions and got it to compile and work.

Thanks for writing rhubarb.

PS: The Travis build was canceled. Maybe because I sent two commits in rapid succession.

@DanielSWolf DanielSWolf changed the title Removed static reference to boost uuid generator. Fix build error resulting from assigning boost::uuids::random_generator Jul 19, 2018
@DanielSWolf
Copy link
Copy Markdown
Owner

Thanks for the PR! Travis is happy now, too. ;-)

@DanielSWolf DanielSWolf merged commit e02de08 into DanielSWolf:master Jul 19, 2018
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

Successfully merging this pull request may close these issues.

3 participants