User forums > Using Code::Blocks

Global Variable editor

<< < (2/3) > >>

sodev:
Basically the internet is full of crap used by lazy/dumb people who want everything for free. Keeping documentation up-to-date is quite a time consuming task and people blindly copy-pasting everything without trying to understand what they do doesn't help either. All your examples are easy to explain once you understand how global variables work.

A global variable is a structured element with multiple fields, the syntax $(#foo) references the base field, the only required element. The syntax $(#foo.bar) references the bar field. Some fields have a default value that gets appended to the base field if the field is empty, currently i don't know if this applies to all predefined fields but i know for sure it applies to include and lib, and surprise, their default value is actually their name. This information should be somewhere in the documentation because i'm sure i didn't dig that out of the source code, but it's been so long ago i gathered this, i can't remember.

With this information, and the knowledge of the layout of the boost source tree, your results can be easily explained. A boost source tree looks like this if you put the compiled libraries only in the stage area (the folder libs contains the sources but usually NOT the compiled libraries):

--- Code: ---root
+- boost   <- Headers reside inside here
|- stage
 |- lib  <- Libraries reside inside here

--- End code ---

Because of the way how boost headers get included your resulting directories must be:

--- Code: ---include: root
lib: root/stage/lib

--- End code ---

Applied to your examples:


--- Quote from: SelfTeachingC++ on May 26, 2020, 09:24:40 pm ---BASE:C:\Users\MyComputer\Desktop\boost_1_7_0
INCLUDE:C:\Users\MyComputer\Desktop\boost_1_7_0\boost
LIB:C:\Users\MyComputer\Desktop\boost_1_7_0\libs

and my build options menu should under search directories be:
compiler tab  $(#boost.include)
linker tab      $(#boost.lib)

--- End quote ---
Results into:

--- Code: ---include: root/boost
lib: root/libs

--- End code ---


--- Quote ---BASE:C:\Users\MyComputer\Desktop\boost_1_7_0\boost
INCLUDE:C:\Users\MyComputer\Desktop\boost_1_7_0
 
compiler tab  $(#boost.include)
linker tab      $(#boost.lib)

--- End quote ---
Results into:

--- Code: ---include: root
lib: root/boost/lib

--- End code ---


--- Quote ---BASE:C:\Users\MyComputer\Desktop\boost_1_7_0\
INCLUDE:C:\Users\MyComputer\Desktop\boost_1_7_0\boost

compiler tab  $(#boost)
linker tab      $(#boost.lib)

--- End quote ---
Results into:

--- Code: ---include: root
lib: root/lib

--- End code ---

TL;DR
Correct configuration for the default layout i mentioned earlier (referencing the variable itself saves you from specifying the root directory multiple times and makes it easier to update):

--- Quote ---Variable name: boost

BASE: C:\Users\MyComputer\Desktop\boost_1_7_0
INCLUDE: $(#boost)
LIB: $(#boost)\stage\lib

--- End quote ---

SelfTeachingC++:

--- Quote from: stahta01 on May 26, 2020, 10:56:32 pm ---

That include is likely wrong!


--- End quote ---

I don’t doubt what you’re saying but from what I’ve seen it doesn’t matter. That include works on my machine If I don’t put .include on the compiler tab.

I 100% appreciate any response that doesn’t just tell me to do my research, learn how to use the IDE and read the documents. Thank you. Many are very quick to dismiss people here as not having done their due diligence.

SelfTeachingC++:

--- Quote from: sodev on May 26, 2020, 11:35:08 pm ---Basically the internet is full of crap used by lazy/dumb people who want everything for free. Keeping documentation up-to-date is quite a time consuming task and people blindly copy-pasting everything without trying to understand what they do doesn't help either. All your examples are easy to explain once you understand how global variables work.

--- End quote ---

Yes. The internet is full of dumb lazy people who want everything for free, but there are a number of us that put in a lot of time and effort to learn and only turn to the forums when really stuck. Then we get plowed over by people that just want to shout and point at the stupid lazy person wanting everything handed to them, regardless of whether that’s what we want or not. I apologize for my rant but it seems to have gotten me somewhere because this next part you say:


--- Quote from: sodev on May 26, 2020, 11:35:08 pm ---A global variable is a structured element with multiple fields, the syntax $(#foo) references the base field, the only required element. The syntax $(#foo.bar) references the bar field. Some fields have a default value that gets appended to the base field if the field is empty, currently i don't know if this applies to all predefined fields but i know for sure it applies to include and lib, and surprise, their default value is actually their name. This information should be somewhere in the documentation because i'm sure i didn't dig that out of the source code, but it's been so long ago i gathered this, i can't remember.

--- End quote ---

Contains some information I already knew and also information I find nowhere in the manual, I’ve seen nowhere in the wiki, in the forums, or in any of the research I’ve done and is potentially VERY helpful and I appreciate it greatly.

As for my examples and your explanation of them, that is exactly how I understand global variables with an added caveat. The variable ends up just appending the path right? So where I have the include going to root, as long as I amend the path to the file structure in the #include directive after the variable it should still work right? The part I MAY have been missing and now will try keeping in mind tomorrow is that you said blank fields are appended with a default value if not filled in. I was not understanding that, nor did I read that anywhere. Blind maybe or maybe it wasn’t in the manuals I read.

BlueHazzard:
You can help to improve the wiki and the manuals. The login to the wiki should be your forum login.
Any help is greatly welcome!

SelfTeachingC++:
As soon as I figure out exactly how to work global variables I plan to update it, but I want to make sure it's right. Every time I go in, think I understand and follow the manual, nothing works except what I've listed above, half of which apparently shouldn't work. There's something I'm missing there, some setting, some critical piece of information that may have been in an old manual that is just taken for granted by those that have been using Codeblocks for a while.

As another example, if I follow the manual, the wiki, what is written above, and how I understand this, using a file structure like this:

C:\Users\MyComputer\Desktop\Libxml2\libxml2-2.9.3-win32-x86_64  <--root
C:\Users\MyComputer\Desktop\Libxml2\libxml2-2.9.3-win32-x86_64\include\libxml2\libxml <---headers in this folder
C:\Users\MyComputer\Desktop\Libxml2\libxml2-2.9.3-win32-x86_64\lib <---libraries in this folder

the variable name libxml

BASE:C:\Users\MyComputer\Desktop\Libxml2\libxml2-2.9.3-win32-x86_64
INCLUDE:C:\Users\MyComputer\Desktop\Libxml2\libxml2-2.9.3-win32-x86_64
LIB:C:\Users\MyComputer\Desktop\Libxml2\libxml2-2.9.3-win32-x86_64

and my build options menu:
compiler tab  $(#libxml.include)
linker tab      $(#libxml.lib)

and include directive
#include <libxml\libxml2\libxml\xmlmemory.h>

the compiler should find that file, yet "No such file or directory". So there is either something very wrong with my setup, very wrong with my understanding, some piece of critical information that I am missing, or likely all three.  Again, I don't just want my problem fixed. I want to learn exactly what is going on here so I can do this in the future with other libraries without all the trial and error.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version