ich habe mir auf Windows einen Filesearch programmiert.
Da dieser möglichst auch auf Unix Rechnern laufen soll, benutze ich hierfür Boost-Libs.
Auf Windows funktioniert der Code einwandfrei, auf Debian leider nicht
Leider bin ich ein totaler Debian Anfänger und komme hier absolut nicht weiter!
Ich bin soweit mal den instructions auf der Boost-Seite gefolgt und hoffe ich habe die Header und Libs richtig "installiert".
Im Prinzip hab ich eigentlich die Paketverwaltung genommen und sämtliche Boost-libs etc installed... naja
Ich poste hier mal den Code und danach die Fehlermeldung und hoffe auf Hilfe:
Code: Alles auswählen
#include<boost/filesystem/operations.hpp>
#include<boost/filesystem.hpp>
#include<boost/utility.hpp>
#include<iostream>
#include<string>
#include <exception>
namespace bfs=boost::filesystem;
// Search for a file with the name 'filename' starting in directory 'dir_path',
// copy the path of the file in 'pfound' if found, and return true.
// Else return false.
bool find_file(const bfs::path & dir_path, const std::string & file_name, bfs::path & pfound)
{
if( !exists(dir_path) || !is_directory(dir_path) )
return false;
bfs::directory_iterator iter(dir_path), end_iter;
for(; iter!= end_iter; ++iter)
{
try{
if( bfs::is_directory(*iter) )
{
if( find_file(*iter, file_name, pfound) )
return true;
}
else if( iter->leaf() == file_name )
{
pfound = *iter;
std::cout<<pfound<<std::endl;
return true;
}
}
catch( bfs::filesystem_error &e ){
}
}
return false;
}
int main() {
bfs::path my_path("\\");
bfs::path temp_path("");
if (!find_file(my_path,"main.cpp", temp_path)) {
std::cout << "Konnte nicht gefunden werden!" << std::endl;
}
system("pause");
}
main.cpp:2:31: error: boost/filesystem.hpp: Datei oder Verzeichnis nicht gefunden
main.cpp: In function ‘bool find_file(const boost::filesystem::path&, const std::string&, boost ::filesystem::path&)’:
main.cpp:28: error: no match for ‘operator<<’ in ‘std::cout << pfound’
/usr/lib/gcc/x86_64-linux-gnu/4.1.2/../../../../include/c++/4.1.2/bits/ostream.tcc:67: note: ca ndidates are: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operato r<<(std::basic_ostream<_CharT, _Traits>& (*)(std::basic_ostream<_CharT, _Traits>&)) [with _Char T = char, _Traits = std::char_traits<char>]
/usr/lib/gcc/x86_64-linux-gnu/4.1.2/../../../../include/c++/4.1.2/bits/ostream.tcc:78: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operato r<<(std::basic_ios<_CharT, _Traits>& (*)(std::basic_ios<_CharT, _Traits>&)) [with _CharT = char , _Traits = std::char_traits<char>]
/usr/lib/gcc/x86_64-linux-gnu/4.1.2/../../../../include/c++/4.1.2/bits/ostream.tcc:90: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operato r<<(std::ios_base& (*)(std::ios_base&)) [with _CharT = char, _Traits = std::char_traits<char>]
/usr/lib/gcc/x86_64-linux-gnu/4.1.2/../../../../include/c++/4.1.2/bits/ostream.tcc:241: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operat or<<(long int) [with _CharT = char, _Traits = std::char_traits<char>]
/usr/lib/gcc/x86_64-linux-gnu/4.1.2/../../../../include/c++/4.1.2/bits/ostream.tcc:264: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operat or<<(long unsigned int) [with _CharT = char, _Traits = std::char_traits<char>]
/usr/lib/gcc/x86_64-linux-gnu/4.1.2/../../../../include/c++/4.1.2/bits/ostream.tcc:102: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operat or<<(bool) [with _CharT = char, _Traits = std::char_traits<char>]
/usr/lib/gcc/x86_64-linux-gnu/4.1.2/../../../../include/c++/4.1.2/bits/ostream.tcc:125: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operat or<<(short int) [with _CharT = char, _Traits = std::char_traits<char>]
/usr/lib/gcc/x86_64-linux-gnu/4.1.2/../../../../include/c++/4.1.2/bits/ostream.tcc:157: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operat or<<(short unsigned int) [with _CharT = char, _Traits = std::char_traits<char>]
/usr/lib/gcc/x86_64-linux-gnu/4.1.2/../../../../include/c++/4.1.2/bits/ostream.tcc:183: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operat or<<(int) [with _CharT = char, _Traits = std::char_traits<char>]
/usr/lib/gcc/x86_64-linux-gnu/4.1.2/../../../../include/c++/4.1.2/bits/ostream.tcc:215: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operat or<<(unsigned int) [with _CharT = char, _Traits = std::char_traits<char>]
/usr/lib/gcc/x86_64-linux-gnu/4.1.2/../../../../include/c++/4.1.2/bits/ostream.tcc:288: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operat or<<(long long int) [with _CharT = char, _Traits = std::char_traits<char>]
/usr/lib/gcc/x86_64-linux-gnu/4.1.2/../../../../include/c++/4.1.2/bits/ostream.tcc:311: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operat or<<(long long unsigned int) [with _CharT = char, _Traits = std::char_traits<char>]
/usr/lib/gcc/x86_64-linux-gnu/4.1.2/../../../../include/c++/4.1.2/bits/ostream.tcc:361: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operat or<<(double) [with _CharT = char, _Traits = std::char_traits<char>]
/usr/lib/gcc/x86_64-linux-gnu/4.1.2/../../../../include/c++/4.1.2/bits/ostream.tcc:335: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operat or<<(float) [with _CharT = char, _Traits = std::char_traits<char>]
/usr/lib/gcc/x86_64-linux-gnu/4.1.2/../../../../include/c++/4.1.2/bits/ostream.tcc:384: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operat or<<(long double) [with _CharT = char, _Traits = std::char_traits<char>]
/usr/lib/gcc/x86_64-linux-gnu/4.1.2/../../../../include/c++/4.1.2/bits/ostream.tcc:407: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operat or<<(const void*) [with _CharT = char, _Traits = std::char_traits<char>]
/usr/lib/gcc/x86_64-linux-gnu/4.1.2/../../../../include/c++/4.1.2/bits/ostream.tcc:430: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operat or<<(std::basic_streambuf<_CharT, _Traits>*) [with _CharT = char, _Traits = std::char_traits<ch ar>]
main.cpp:32: error: expected type-specifier
main.cpp:32: error: expected unqualified-id before ‘&’ token
main.cpp:32: error: expected `)' before ‘&’ token
main.cpp:32: error: expected `{' before ‘&’ token
main.cpp:32: error: ‘e’ was not declared in this scope
main.cpp:32: error: expected `;' before ‘)’ token
Danke für eure Hilfe
mfg
geneticZ