I downloaded Boost 1.54 and ran bootstrap.bat mingw
. Then I tried to run the program below. I am getting the error you see below. I have tried copying my boost folder into the mingw include folder and I have tried linking my file to the boost/stage/lib
folder, but I have not been successful. I see a lot of questions similar to this question, but none of them explain how to get the link the boost folder to the file.
Do I have to copy the boost folder to a different directory? Do I have to change my path variable? How can I get the boost library to link to my code?
Code
#include <boost/filesystem.hpp>
#include <iostream>
using namespace std;
using namespace boost::filesystem;
int main()
{
boost::filesystem::directory_iterator iterator(string("."));
for(; iterator != boost::filesystem::directory_iterator(); ++iterator)
{
cout << (iterator->path().filename()) << endl;
}
boost::filesystem::path full_path( boost::filesystem::current_path() );
std::cout << "Current path is : " << full_path << std::endl;
return 0;
}
Error
C:\Users\212340~1\AppData\Local\Temp\ccZA7umT.o:playground.cc:(.text+0xa4): undefined reference to `boost::filesystem::path::filename() const'
C:\Users\212340~1\AppData\Local\Temp\ccZA7umT.o:playground.cc:(.text+0x244): undefined reference to `boost::system::generic_category()'
C:\Users\212340~1\AppData\Local\Temp\ccZA7umT.o:playground.cc:(.text+0x24e): undefined reference to `boost::system::generic_category()'
C:\Users\212340~1\AppData\Local\Temp\ccZA7umT.o:playground.cc:(.text+0x258): undefined reference to `boost::system::system_category()'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: C:\Users\212340~1\AppData\Local\Temp\ccZA7umT.o: bad reloc address 0x1b in section `.text$_ZNK5boost6system10error_code7messageEv[__ZNK5boost6system10error_code7messageEv]'
collect2.exe: error: ld returned 1 exit status
[Finished in 21.0s with exit code 1]