0

I must say, I'm new to using Boost libs, but I have used them for a few of my projects, and have been super pleased with them. Now, I would like to get all files with certain extension in one of my folders, so, looking it up online, I found this>How to get list of files with a specific extension in a given folder I'm using Code Blocks on Windows 7.

I have done everything it seemed required, and when I try to compile it, I get three errors>

C:\boost_1_58_0\boost\system\error_code.hpp|221|undefined reference to boost::system::generic_category()'| C:\boost_1_58_0\boost\system\error_code.hpp|222|undefined reference to boost::system::generic_category()'| C:\boost_1_58_0\boost\system\error_code.hpp|223|undefined reference to `boost::system::system_category()'|

I was looking it up online, and found that, besides pointing my "Search directories (compiler and linker) to boost installation, I need to point it directly to boost system lib somehow.

I tried -lboost_system in my Linker settings, but that didn't solve it.

I'm hardly an expert here, so I'm asking you guys if you can help me.

Does anyone have any ideas?

Community
  • 1
  • 1
Rorschach
  • 734
  • 2
  • 7
  • 22
  • Make sure the link step is being invoked with a path to the Boost libraries (`-L path/to/boost/libs`). I'm not familiar with CodeBlocks, so you'll have to figure out how to get it to display the linker invocation command. Of course, also make sure that the library you're trying to link to (`boost_system`) actually exists in the specified location. – Praetorian Jun 08 '15 at 16:14
  • Hello, I currently have> -LC:\boost_1_58_0\libs\system but that doesn't help. That folder exists, definitely. – Rorschach Jun 08 '15 at 16:22
  • Okay, but what about the library `libboost_system` itself? I'm willing to bet that the path above is wrong. The library is most likely in `C:\boost_1_58_0\stage\lib`. Search your Boost tree for the library file, if it doesn't exist you'll need to build Boost. – Praetorian Jun 08 '15 at 16:27
  • http://s29.postimg.org/mk9g08o47/Capture.png This is what the search gave me. Can you tell me what to include in linker settings? I guess one is for debug, and one is for release build? – Rorschach Jun 08 '15 at 16:33
  • 2
    Those are the Visual Studio versions of those libraries, notice the vc110 in the name? You'll need to build Boost using gcc. – Praetorian Jun 08 '15 at 16:36
  • Well, It was the easiest way, to build Boost with VS. I thought it wouldn't make any difference which compiler I used to build it. I will now rebuild with gcc and then try again – Rorschach Jun 08 '15 at 20:14
  • [These instructions](https://stackoverflow.com/a/13257930/241631) should get you going. Forget about additional command line options for now, once you get a successful build using the default options, you can go about tweaking them as you like. – Praetorian Jun 08 '15 at 22:32
  • OK, I have successfully built Boost with MinGW GCC compiler that came along with C::B. I have placed search directories in my projects build options, and now, I guess I need to add some linker settings? My search now looks like this. http://s8.postimg.org/vv5cwsh1x/Capture.png – Rorschach Jun 08 '15 at 23:33
  • So you need `-L C:/boost_1_58_0/stage` and -lboost_system-mgw47-mt-1_58`. The variant with `-d` in the name is the debug library that you want to link to for debug builds. – Praetorian Jun 09 '15 at 03:57
  • Thank you so much! I added the stuff you said, plus I had to add `libboost_filesystem-mgw47-mt-d-1_58` for filesystem stuff, and it compiles beautifully. Again, thank you @Praetorian!!! – Rorschach Jun 09 '15 at 07:49

1 Answers1

1

You need to provide the path where your lib is with the -L option of GCC.

Check this section of Boost documentation

Nielk
  • 760
  • 1
  • 6
  • 22
  • My boost directory is directly on C: C:\boost_1_58_0\ So, i did> C:\boost_1_58_0\libs\system\test\system (in that folder there is a system.sln) but, that gives me permission denied. – Rorschach Jun 08 '15 at 16:16
  • So did you check that in your gcc link command you have -LC:\ ? Can you provide the full gcc link command ? – Nielk Jun 08 '15 at 16:18
  • -LC:\boost_1_58_0\libs\system I have that on my linker settings/link libraries window. – Rorschach Jun 08 '15 at 16:23
  • How did you install boost ? Parts of it are header-only, which means you just have to include the headers in your project without any setup, but boost system has some binaries. That means you have to compile it first. If all went well during installation, you should have somewhere a file called libboost_system.dll – Nielk Jun 08 '15 at 16:39
  • @user3735245 are you sure you installed boost? – Abhinav Gauniyal Jun 08 '15 at 16:58
  • Yes, I am sure. I built it with VS, and now I wanted to use it with gcc, so I guess that was a problem. I will now try to build with gcc and see what happens. – Rorschach Jun 08 '15 at 20:33