Author Topic: Bit confusing - compiler settings from two places  (Read 3401 times)

Offline smallB

  • Almost regular
  • **
  • Posts: 193
Bit confusing - compiler settings from two places
« on: October 31, 2012, 06:22:31 pm »
Guys, I have mention this previously, but I would like to expand little on the topic of compiler settings which can be set from two different places:
a) Settings/Compiler
b) Project/Build Options

I personally really find it very, very confusing. On top of that I believe that there is a bug, unless (and this is very possible) I do not fully understand its workings.
OK, I've installed successfully boost library.
1. I've set new global variable:
see attachment "global_var.png"
2. I've set in Settings/Compiler Settings  on the Search Directories tab, on the Compiler tab: $(#boost.include) and on the linker tab $(#boost.lib)
3. On tab called Linker Settings (the one before Search Directories) I've provided path for the test library
see attachment "Linker Settings.png"

I've tried to run simple test case:
#define BOOST_TEST_MODULE MyTest
#include <boost/test/unit_test.hpp>

BOOST_AUTO_TEST_CASE(MyTest)
{
   // To simplify this example test, let's suppose we'll test 'float'.
   // Some test are stupid, but all should pass.
   float x = 9.5f;

   BOOST_CHECK(x != 0.0f);
   BOOST_CHECK_EQUAL((int)x, 9);
   BOOST_CHECK_CLOSE(x, 9.5f, 0.0001f); // Checks differ no more then 0.0001%
}

I'm getting error:
C:\...\Test.cpp|2|fatal error: boost/test/unit_test.hpp: No such file or directory|

This is already confusing because I've specified the path in tab Search Directories (point no. 2). Anyway, it seems like I have to specify it second time in: Project/Build Options, so I did it, but here simply adding $(#boost.include) doesn't work. It must be just $(#boost). Why:
a) do I have to specify it second time
b) the "include" part must be omitted?

OK, now it finds this directory, but here I'm running into new problem:
undefined reference to `cpp_main(int, char**)
I knew that this is something to do with library not being found (even though I've set all libraries, see point no.3). So what I have to do? In order for this to work I need to provide this path second time in: Project/Build Options on the Linker Settings tab. Why? I've already provided this path once.
So the issues in a nutshell I see:
a) There seem to be need to set identical settings for linker and compiler in two places, via Settings/Compiler and Project/Build Option
b) Settings those options just via Settings/Compiler seems not working, and I believe those settings are global settings, and unless those are overwritten by settings specified in Project/Build Options, the global settings should be used. But they are not used.
I strongly believe that the current situation is at best problematic and confusing, and there are much better way to resolve the issue of having separate settings for different projects.
Regards


[attachment deleted by admin]

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Bit confusing - compiler settings from two places
« Reply #1 on: November 01, 2012, 07:10:31 am »
Your GCV field boost.include is wrong. is has to point to $(#boost.base) in your GCV settings.

Obviously you didn't read the help to GCV, right?

Finally: Global compiler settings are there for settings that apply to all of your projects. So if you intent for the rest of your live that you need boost in all projects you are doping, leave it there. If not, use project and target settings. IF this is confusing to you I suspect that you also didn't read the C::B manual and the WiKi, where the build process is explained in detail, including why it is as it is.

PLEASE do read more. We are not here to repeat the same stuff a million times. We simply don't have resources for that or we can cease development. Sorry.
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

Offline smallB

  • Almost regular
  • **
  • Posts: 193
Re: Bit confusing - compiler settings from two places
« Reply #2 on: November 01, 2012, 10:00:17 am »
Hi
Thank you for your reply. Will read more. Really don't mean to be a nuisance.
« Last Edit: November 01, 2012, 10:03:49 am by smallB »