Author Topic: Struggling with boost and codeblocks. Any tips?  (Read 5424 times)

LByte

  • Guest
Struggling with boost and codeblocks. Any tips?
« on: August 06, 2013, 03:33:51 pm »
Hi all,

First post here, and I figured that this would be the most appropriate place to ask about my problem.

I am using GCC 4.6.3 MinGW G++ with CodeBlocks to compile some basic sample code for boost to make sure that the libraries are working.

The code that I am trying to compile is

#include <iostream>
#include <boost/filesystem.hpp>

using namespace boost::filesystem;

int main(int argc, char* argv[])
{
      if (argc < 2)
      {
        std::cout << "Usage: tut1 path\n";
        return 1;
      }
      std::cout << argv[1] << " " << file_size(argv[1]) << '\n';
      return 0;
}


The build log comes out as the following:


-------------- Build: Debug in BoostTest (compiler: GNU GCC Compiler)---------------

mingw32-g++.exe -fexceptions  -Wall -g    -IC:\Libraries\boost_1_54_0_build\include  -c "C:\Users\<redacted>\Documents\CodeBlocks Projects\BoostTest\main.cpp" -o obj\Debug\main.o
mingw32-g++.exe -LC:\Libraries\boost_1_54_0_build\lib -LC:\Libraries\boost_1_54_0\libs  -o bin\Debug\BoostTest.exe obj\Debug\main.o    -lboost_filesystem-sd -lboost_system-sd
obj\Debug\main.o: In function `_static_initialization_and_destruction_0':
C:/Libraries/boost_1_54_0_build/include/boost/system/error_code.hpp:222: undefined reference to `boost::system::generic_category()'
C:/Libraries/boost_1_54_0_build/include/boost/system/error_code.hpp:223: undefined reference to `boost::system::generic_category()'
C:/Libraries/boost_1_54_0_build/include/boost/system/error_code.hpp:224: undefined reference to `boost::system::system_category()'
obj\Debug\main.o: In function `ZN5boost10filesystem11path_traits7convertEPKcRSbIwSt11char_traitsIwESaIwEERKSt7codecvtIwciE':
C:/Libraries/boost_1_54_0_build/include/boost/filesystem/path_traits.hpp:113: 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&)'
obj\Debug\main.o: In function `ZN5boost10filesystem9file_sizeERKNS0_4pathE':
C:/Libraries/boost_1_54_0_build/include/boost/filesystem/operations.hpp:447: undefined reference to `boost::filesystem::detail::file_size(boost::filesystem::path const&, boost::system::error_code*)'
obj\Debug\main.o: In function `ZN5boost10filesystem4pathC1IPcEERKT_PNS_9enable_ifINS0_11path_traits11is_pathableINS_5decayIS4_E4typeEEEvE4typeE':
C:/Libraries/boost_1_54_0_build/include/boost/filesystem/path.hpp:139: undefined reference to `boost::filesystem::path::codecvt()'
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 1 seconds)
6 errors, 0 warnings (0 minutes, 1 seconds)



My .cbp file is setup as the following
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
   <FileVersion major="1" minor="6" />
   <Project>
      <Option title="BoostTest" />
      <Option pch_mode="2" />
      <Option compiler="gcc" />
      <Build>
         <Target title="Debug">
            <Option output="bin/Debug/BoostTest" prefix_auto="1" extension_auto="1" />
            <Option object_output="obj/Debug/" />
            <Option type="1" />
            <Option compiler="gcc" />
            <Compiler>
               <Add option="-g" />
               <Add directory="C:/Libraries/boost_1_54_0_build/include" />
            </Compiler>
            <Linker>
               <Add library="boost_regex-mt-d" />
               <Add directory="C:/Libraries/boost_1_54_0_build/lib" />
            </Linker>
         </Target>
         <Target title="Release">
            <Option output="bin/Release/BoostTest" prefix_auto="1" extension_auto="1" />
            <Option object_output="obj/Release/" />
            <Option type="1" />
            <Option compiler="gcc" />
            <Compiler>
               <Add option="-O2" />
               <Add directory="C:/Libraries/boost_1_54_0_build/include" />
            </Compiler>
            <Linker>
               <Add option="-s" />
               <Add library="boost_regex-mt" />
               <Add directory="C:/Libraries/boost_1_54_0_build/lib" />
            </Linker>
         </Target>
      </Build>
      <Compiler>
         <Add option="-Wall" />
         <Add option="-fexceptions" />
      </Compiler>
      <Unit filename="main.cpp" />
      <Extensions>
         <code_completion />
         <envvars />
         <debugger />
         <lib_finder disable_auto="1" />
      </Extensions>
   </Project>
</CodeBlocks_project_file>
« Last Edit: August 06, 2013, 03:42:24 pm by LByte »

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9723
Re: Struggling with boost and codeblocks. Any tips?
« Reply #1 on: August 07, 2013, 07:24:13 am »
Unrelated to CodeBlocks, therefore being locked.

Please respect our forum rules you agreed to when registering here. This is not a general programming forum. Try a c/c++ or boost related forum. We are not developing boost here at all.

Thank you.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ