【发布时间】:2015-02-21 05:28:16
【问题描述】:
我在使用 std :: ifstream 编译此应用程序时遇到问题,代码如下:
<code> Pallete get_default_pallete(Path const& fname) {
auto dname = get_dname("pal.PAL");
auto dir = fname.parent_path();
**std::ifstream f((dir/"pal.PAL"));**
ifbuf wr(f);
return read_pallete(wr, dname);
}</code>
这是控制台:
**** Build of configuration Default for project cc94-cc94 ****
**** Internal Builder is used for build ****
**** WARNING: The "Default" Configuration may not build ****
**** because it uses the "cdt.managedbuild.toolchain.gnu.mingw.base" ****
**** tool-chain that is unsupported on this system. ****
**** Attempting to build... ****
g++ -std=c++11 -IC:\cc94-cc94\inc -IC:\boost 1_57_0 -O2 -g -Wall -c -fmessage-length=0 -osrc\unmadspack.o ..\src\unmadspack.cpp
..\src\unmadspack.cpp: In function 'std::vector<std::vector<unsigned char> > get_descomprimir(ifbuf&)':
..\src\unmadspack.cpp:360:8: warning: unused variable 'hash_' [-Wunused-variable]
auto hash_ = read_uint16(read<2>(iheader));
^
..\src\unmadspack.cpp: In function 'Pallete get_default_pallete(const Path&)':
..\src\unmadspack.cpp:454:33: error: no matching function for call to 'std::basic_ifstream<char>::basic_ifstream(boost::filesystem::path)'
std::ifstream f((dir/"pal.PAL"));
^
..\src\unmadspack.cpp:454:33: note: candidates are:
In file included from ..\src\unmadspack.cpp:3:0:
C:/Archivos de programa/mingw-w64/i686-4.9.2-posix-dwarf-rt_v3-rev1/mingw32/i686-w64-mingw32/include/c++/fstream:486:7: note: std::basic_ifstream<_CharT, _Traits>::basic_ifstream(const string&, std::ios_base::openmode) [with _CharT = char; _Traits = std::char_traits<char>; std::string = std::basic_string<char>; std::ios_base::openmode = std::_Ios_Openmode]
basic_ifstream(const std::string& __s,
^
C:/Archivos de programa/mingw-w64/i686-4.9.2-posix-dwarf-rt_v3-rev1/mingw32/i686-w64-mingw32/include/c++/fstream:486:7: note: no known conversion for argument 1 from 'boost::filesystem::path' to 'const string& {aka const std::basic_string<char>&}'
C:/Archivos de programa/mingw-w64/i686-4.9.2-posix-dwarf-rt_v3-rev1/mingw32/i686-w64-mingw32/include/c++/fstream:470:7: note: std::basic_ifstream<_CharT, _Traits>::basic_ifstream(const char*, std::ios_base::openmode) [with _CharT = char; _Traits = std::char_traits<char>; std::ios_base::openmode = std::_Ios_Openmode]
basic_ifstream(const char* __s, ios_base::openmode __mode = ios_base::in)
^
C:/Archivos de programa/mingw-w64/i686-4.9.2-posix-dwarf-rt_v3-rev1/mingw32/i686-w64-mingw32/include/c++/fstream:470:7: note: no known conversion for argument 1 from 'boost::filesystem::path' to 'const char*'
C:/Archivos de programa/mingw-w64/i686-4.9.2-posix-dwarf-rt_v3-rev1/mingw32/i686-w64-mingw32/include/c++/fstream:456:7: note: std::basic_ifstream<_CharT, _Traits>::basic_ifstream() [with _CharT = char; _Traits = std::char_traits<char>]
basic_ifstream() : __istream_type(), _M_filebuf()
^
C:/Archivos de programa/mingw-w64/i686-4.9.2-posix-dwarf-rt_v3-rev1/mingw32/i686-w64-mingw32/include/c++/fstream:456:7: note: candidate expects 0 arguments, 1 provided
In file included from C:\boost 1_57_0/boost/filesystem/path_traits.hpp:23:0,
from C:\boost 1_57_0/boost/filesystem/path.hpp:25,
from C:\boost 1_57_0/boost/filesystem.hpp:16,
from ..\src\unmadspack.cpp:9:
C:\boost 1_57_0/boost/system/error_code.hpp: At global scope:
C:\boost 1_57_0/boost/system/error_code.hpp:221:36: warning: 'boost::system::posix_category' defined but not used [-Wunused-variable]
static const error_category & posix_category = generic_category();
^
C:\boost 1_57_0/boost/system/error_code.hpp:222:36: warning: 'boost::system::errno_ecat' defined but not used [-Wunused-variable]
static const error_category & errno_ecat = generic_category();
^
C:\boost 1_57_0/boost/system/error_code.hpp:223:36: warning: 'boost::system::native_ecat' defined but not used [-Wunused-variable]
static const error_category & native_ecat = system_category();
^
Build error occurred, build is stopped
Time consumed: 3515 ms.
好吧,如果我删除编译程序的方法会出现以下错误:
<code>**** Build of configuration Default for project cc94-cc94 ****
**** Internal Builder is used for build ****
**** WARNING: The "Default" Configuration may not build ****
**** because it uses the "cdt.managedbuild.toolchain.gnu.mingw.base" ****
**** tool-chain that is unsupported on this system. ****
**** Attempting to build... ****
g++ -std=c++11 -IC:\cc94-cc94\inc -IC:\boost 1_57_0 -O2 -g -Wall -c -fmessage-length=0 -osrc\unmadspack.o ..\src\unmadspack.cpp
..\src\unmadspack.cpp: In function 'std::vector<std::vector<unsigned char> > get_descomprimir(ifbuf&)':
..\src\unmadspack.cpp:360:8: warning: unused variable 'hash_' [-Wunused-variable]
auto hash_ = read_uint16(read<2>(iheader));
^
g++ -std=c++11 -LC:\boost 1_57_0\stage\lib -occ94-cc94 src\unmadspack.o src\test_format.o src\lodepng\lodepng.o
src\unmadspack.o: In function `convert':
C:/boost 1_57_0/boost/filesystem/path.hpp:852: undefined reference to `boost::filesystem::path::codecvt()'
C:/boost 1_57_0/boost/filesystem/path.hpp:852: undefined reference to `boost::filesystem::path_traits::convert(char const*, char const*, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >&, std::codecvt<wchar_t, char, int> const&)'
src\unmadspack.o: In function `exists':
C:/boost 1_57_0/boost/filesystem/operations.hpp:404: undefined reference to `boost::filesystem::detail::status(boost::filesystem::path const&, boost::system::error_code*)'
src\unmadspack.o: In function `convert':
C:/boost 1_57_0/boost/filesystem/path.hpp:844: undefined reference to `boost::filesystem::path::codecvt()'
C:/boost 1_57_0/boost/filesystem/path.hpp:844: undefined reference to `boost::filesystem::path_traits::convert(wchar_t const*, wchar_t const*, std::string&, std::codecvt<wchar_t, char, int> const&)'
src\unmadspack.o: In function `operator/':
C:/boost 1_57_0/boost/filesystem/path.hpp:695: undefined reference to `boost::filesystem::path::operator/=(boost::filesystem::path const&)'
src\unmadspack.o: In function `convert':
C:/boost 1_57_0/boost/filesystem/path.hpp:836: undefined reference to `boost::filesystem::path::codecvt()'
C:/boost 1_57_0/boost/filesystem/path.hpp:836: undefined reference to `boost::filesystem::path_traits::convert(char const*, char const*, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >&, std::codecvt<wchar_t, char, int> const&)'
C:/boost 1_57_0/boost/filesystem/path.hpp:844: undefined reference to `boost::filesystem::path::codecvt()'
C:/boost 1_57_0/boost/filesystem/path.hpp:844: undefined reference to `boost::filesystem::path_traits::convert(wchar_t const*, wchar_t const*, std::string&, std::codecvt<wchar_t, char, int> const&)'
C:/boost 1_57_0/boost/filesystem/path.hpp:836: undefined reference to `boost::filesystem::path::codecvt()'
C:/boost 1_57_0/boost/filesystem/path.hpp:836: undefined reference to `boost::filesystem::path_traits::convert(char const*, char const*, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >&, std::codecvt<wchar_t, char, int> const&)'
src\unmadspack.o: In function `extension':
C:/boost 1_57_0/boost/filesystem/convenience.hpp:36: undefined reference to `boost::filesystem::path::extension() const'
src\unmadspack.o: In function `convert':
C:/boost 1_57_0/boost/filesystem/path.hpp:852: undefined reference to `boost::filesystem::path::codecvt()'
C:/boost 1_57_0/boost/filesystem/path.hpp:852: undefined reference to `boost::filesystem::path_traits::convert(char const*, char const*, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >&, std::codecvt<wchar_t, char, int> const&)'
src\unmadspack.o: In function `operator/':
C:/boost 1_57_0/boost/filesystem/path.hpp:695: undefined reference to `boost::filesystem::path::operator/=(boost::filesystem::path const&)'
src\unmadspack.o: In function `exists':
C:/boost 1_57_0/boost/filesystem/operations.hpp:404: undefined reference to `boost::filesystem::detail::status(boost::filesystem::path const&, boost::system::error_code*)'
src\unmadspack.o: In function `convert':
C:/boost 1_57_0/boost/filesystem/path.hpp:836: undefined reference to `boost::filesystem::path::codecvt()'
C:/boost 1_57_0/boost/filesystem/path.hpp:836: undefined reference to `boost::filesystem::path_traits::convert(char const*, char const*, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >&, std::codecvt<wchar_t, char, int> const&)'
C:/boost 1_57_0/boost/filesystem/path.hpp:844: undefined reference to `boost::filesystem::path::codecvt()'
C:/boost 1_57_0/boost/filesystem/path.hpp:844: undefined reference to `boost::filesystem::path_traits::convert(wchar_t const*, wchar_t const*, std::string&, std::codecvt<wchar_t, char, int> const&)'
C:/boost 1_57_0/boost/filesystem/path.hpp:844: undefined reference to `boost::filesystem::path::codecvt()'
C:/boost 1_57_0/boost/filesystem/path.hpp:844: undefined reference to `boost::filesystem::path_traits::convert(wchar_t const*, wchar_t const*, std::string&, std::codecvt<wchar_t, char, int> const&)'
C:/boost 1_57_0/boost/filesystem/path.hpp:844: undefined reference to `boost::filesystem::path::codecvt()'
C:/boost 1_57_0/boost/filesystem/path.hpp:844: undefined reference to `boost::filesystem::path_traits::convert(wchar_t const*, wchar_t const*, std::string&, std::codecvt<wchar_t, char, int> const&)'
src\unmadspack.o: In function `ZN5boost10filesystem4path6appendIA6_cEERS1_RKT_':
C:/boost 1_57_0/boost/filesystem/path.hpp:768: undefined reference to `boost::filesystem::path::m_append_separator_if_needed()'
C:/boost 1_57_0/boost/filesystem/path.hpp:771: undefined reference to `boost::filesystem::path::m_erase_redundant_separator(unsigned int)'
src\unmadspack.o: In function `convert':
C:/boost 1_57_0/boost/filesystem/path.hpp:836: undefined reference to `boost::filesystem::path::codecvt()'
C:/boost 1_57_0/boost/filesystem/path.hpp:836: undefined reference to `boost::filesystem::path_traits::convert(char const*, char const*, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >&, std::codecvt<wchar_t, char, int> const&)'
src\unmadspack.o: In function `ZN5boost10filesystem4path6appendIA9_cEERS1_RKT_':
C:/boost 1_57_0/boost/filesystem/path.hpp:768: undefined reference to `boost::filesystem::path::m_append_separator_if_needed()'
C:/boost 1_57_0/boost/filesystem/path.hpp:771: undefined reference to `boost::filesystem::path::m_erase_redundant_separator(unsigned int)'
src\unmadspack.o: In function `convert':
C:/boost 1_57_0/boost/filesystem/path.hpp:836: undefined reference to `boost::filesystem::path::codecvt()'
C:/boost 1_57_0/boost/filesystem/path.hpp:836: undefined reference to `boost::filesystem::path_traits::convert(char const*, char const*, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >&, std::codecvt<wchar_t, char, int> const&)'
C:/boost 1_57_0/boost/filesystem/path.hpp:852: undefined reference to `boost::filesystem::path::codecvt()'
C:/boost 1_57_0/boost/filesystem/path.hpp:852: undefined reference to `boost::filesystem::path_traits::convert(char const*, char const*, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >&, std::codecvt<wchar_t, char, int> const&)'
src\unmadspack.o: In function `operator/':
C:/boost 1_57_0/boost/filesystem/path.hpp:695: undefined reference to `boost::filesystem::path::operator/=(boost::filesystem::path const&)'
src\unmadspack.o: In function `convert':
C:/boost 1_57_0/boost/filesystem/path.hpp:836: undefined reference to `boost::filesystem::path::codecvt()'
C:/boost 1_57_0/boost/filesystem/path.hpp:836: undefined reference to `boost::filesystem::path_traits::convert(char const*, char const*, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >&, std::codecvt<wchar_t, char, int> const&)'
src\unmadspack.o: In function `_static_initialization_and_destruction_0':
C:/boost 1_57_0/boost/system/error_code.hpp:221: undefined reference to `boost::system::generic_category()'
C:/boost 1_57_0/boost/system/error_code.hpp:222: undefined reference to `boost::system::generic_category()'
C:/boost 1_57_0/boost/system/error_code.hpp:223: undefined reference to `boost::system::system_category()'
collect2.exe: error: ld returned 1 exit status
Build error occurred, build is stopped
Time consumed: 8625 ms.
</code>
推测是我的eclipse配置不正确
http://i726.photobucket.com/albums/ww263/raulpuro/Dibujo_zps19df749d.jpg~original
http://i726.photobucket.com/albums/ww263/raulpuro/Dibujo2_zps7a4bc150.jpg~original
感谢您对 2 个错误中的任何一个的帮助。
问候。
【问题讨论】:
标签: c++