Boost logo

Boost Users :

Subject: Re: [Boost-users] invalid conversion from 'bool
From: Eric Lin (kingdavid1_at_[hidden])
Date: 2011-07-19 02:09:33


________________________________
> Date: Tue, 19 Jul 2011 13:48:16 +0800
> From: tongari95_at_[hidden]
> To: boost-users_at_[hidden]
> Subject: Re: [Boost-users] invalid conversion from 'bool
>
> 2011/7/19 Eric Lin <kingdavid1_at_[hidden]<mailto:kingdavid1_at_[hidden]>>
>
> Dear Advanced c/g++ on boost programers:
>
> I have copied and testd a simple (Copy a file with Boost) program
> from page 372, Example10-10, book(C++ cookbook)
> but I got compile error
> -----------------------------
> eric_at_eric-laptop:~/cppcookbook/ch10$ g++ Example10-10.cpp
> Example10-10.cpp: In function ‘int main(int, char**)’:
> Example10-10.cpp:17:47: error: invalid conversion from ‘bool (*)(const
> std::string&)’ to ‘boost::enable_if_c<true, void>::type*’
> Example10-10.cpp:17:47: error: initializing argument 2 of
> ‘boost::filesystem3::path::path(const Source&, typename
> boost::enable_if<boost::filesystem3::path_traits::is_pathable<typename
> boost::decay<Source>::type> >::type*) [with Source = char*, typename
> boost::enable_if<boost::filesystem3::path_traits::is_pathable<typename
> boost::decay<Source>::type> >::type = void]’
> Example10-10.cpp:18:47: error: invalid conversion from ‘bool (*)(const
> std::string&)’ to ‘boost::enable_if_c<true, void>::type*’
> Example10-10.cpp:18:47: error: initializing argument 2 of
> ‘boost::filesystem3::path::path(const Source&, typename
> boost::enable_if<boost::filesystem3::path_traits::is_pathable<typename
> boost::decay<Source>::type> >::type*) [with Source = char*, typename
> boost::enable_if<boost::filesystem3::path_traits::is_pathable<typename
> boost::decay<Source>::type> >::type = void]’

> -----------------------------
> This is my program, you can download and test by your self from
> http://examples.oreilly.com/9780596007614/
> -----------------------------------------------------
> // Example 10-10. Copying a file with Boost
> #include <iostream>
> #include <string>
> #include <boost/filesystem/operations.hpp>
> #include <boost/filesystem/fstream.hpp>
> #include <boost/filesystem/path.hpp>
>
> using namespace std;
> using namespace boost::filesystem;
>
> int main(int argc, char** argv) {
>
> // Parameter checking...
>
> try {
> // Turn the args into absolute paths using native formatting
> path src = complete(path(argv[1], native));
> path dst = complete(path(argv[2], native));
> copy_file(src, dst);
> }
> catch (exception& e) {
> cerr << e.what() << endl;
> }
>
> return(EXIT_SUCCESS);
> }
> ----------------------------------------------------------------------------
> I ever check around web, there is some suggestion ask me to get rid
> native, but in my test/system, it only
> generate more errors.
> my boost version probably is 1.46.1
> and I am on g++ 4.5.2 and Ubuntu10.04/linuxKernel2.6.35-25
> Need and thanks your help a lot in advance, Eric
>
> Removing the "native" does work well for me, what are the errors you
> saw then?
> Link errors? You must link against the boost filesystem & system lib.

Thanks your reply, but how to (link against the boost filesystem & system lib)? I am on linux/g++
these are errors I got, after I eliminate native
----------------
eric_at_eric-laptop:~/cppcookbook/ch10$ g++ -lboost_system  Example10-10.cpp
/tmp/ccF2cJsO.o: In function `boost::filesystem3::path::codecvt()':
Example10-10.cpp:(.text._ZN5boost11filesystem34path7codecvtEv[boost::filesystem3::path::codecvt()]+0x7): undefined reference to `boost::filesystem3::path::wchar_t_codecvt_facet()'
/tmp/ccF2cJsO.o: In function `boost::filesystem3::complete(boost::filesystem3::path const&)':
Example10-10.cpp:(.text._ZN5boost11filesystem38completeERKNS0_4pathE[boost::filesystem3::complete(boost::filesystem3::path const&)]+0x2d): undefined reference to `boost::filesystem3::absolute(boost::filesystem3::path const&, boost::filesystem3::path const&)'
/tmp/ccF2cJsO.o: In function `boost::filesystem3::copy_file(boost::filesystem3::path const&, boost::filesystem3::path const&)':
Example10-10.cpp:(.text._ZN5boost11filesystem39copy_fileERKNS0_4pathES3_[boost::filesystem3::copy_file(boost::filesystem3::path const&, boost::filesystem3::path const&)]+0x24): undefined reference to `boost::filesystem3::detail::copy_file(boost::filesystem3::path const&, boost::filesystem3::path const&, boost::filesystem3::copy_option::enum_type, boost::system::error_code*)'
/tmp/ccF2cJsO.o: In function `boost::filesystem3::initial_path()':
Example10-10.cpp:(.text._ZN5boost11filesystem312initial_pathEv[boost::filesystem3::initial_path()]+0x18): undefined reference to `boost::filesystem3::detail::initial_path(boost::system::error_code*)'
collect2: ld returned 1 exit status
eric_at_eric-laptop:~/cppcookbook/ch10$
-------------------
looking to see any expert's help again and thank a lot in advance, Eric

>
>
> _______________________________________________ Boost-users mailing
> list Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
                                               


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net