Author Topic: Global Variable editor  (Read 16541 times)

Offline Дмитро

  • Multiple posting newcomer
  • *
  • Posts: 107
Global Variable editor
« on: December 05, 2015, 08:10:57 pm »
Global Variable editor




Hello!

   I am clicking on the buttons took picture something Global Variable editor


  Please, please detail what the setting is and what role it plays.

Змінні.bmp




Yes, I really do not understand. What are these things? Why? What are they?
« Last Edit: December 05, 2015, 09:35:24 pm by Дмитро »

Offline pirx67

  • Multiple posting newcomer
  • *
  • Posts: 40
Re: Global Variable editor
« Reply #1 on: December 05, 2015, 11:53:05 pm »
Hi,

please click on the "Help" button on of the "Global Variable Editor" dialog. This will take you to the wiki where the purpose
of the global variables is explained (see link http://wiki.codeblocks.org/index.php?title=Global_compiler_variables).

You need that if you want to make use of 3rd party libraries (like wxWidgets) in a way that makes it possible to build your project
on another computer / Code::Blocks installation.

Also if you use Code::Blocks keep in mind that you should always create a project for developing your program because
Code::Blocks uses a project as kind of container to administer all settings, paths, dependencies and so on.

Greets,
    pirx67

PS.: Please try to make your questions more explicit and and specific.

Offline cacb

  • Lives here!
  • ****
  • Posts: 536
Re: Global Variable editor
« Reply #2 on: December 06, 2015, 09:03:09 am »
Global Variable editor
Yes, I really do not understand. What are these things? Why? What are they?

Hi,

The global variable editor allows you to define sets of Code::Blocks "global variables". Global variables are defined for each Code::Blocks installation, independent from the projects. The global variables are referenced/used in Code::Blocks project files.

For example, if you have a C++ library 'abc' with header files and .lib/.a files in
Header files  C:\somewhere\abc\include
library files  C:\somewhere\abc\lib

Then you can define a global variable 'ABC' in the global variable editor as follows
BASE:   ABC   C:\somewhere\abc

Then in your project, using the 'abc' library, you can specify the include and lib paths as $(#ABC.include) and $(#ABC.lib). See the Wiki for more details. The main idea is that you refer to global variables this way in C::B project files, instead of the file paths directly. Then you can easily move the project from one computer to another without editing the project, even when the file paths are different.

The idea of global variables is very powerful, and one of the main strong points of Code::Blocks. The editor itself is unfortunately not very intuitive, and it is easy to make mistakes. I have also found that the only way to make sure the variables are properly saved is to exit Code::Blocks (a bug if you ask me). I therefore recommend to exit/restart Code::Blocks after editing global variables.

Offline SelfTeachingC++

  • Multiple posting newcomer
  • *
  • Posts: 11
Re: Global Variable editor
« Reply #3 on: May 26, 2020, 09:24:40 pm »
Something is terribly wrong with all of this. Nothing works as it should. Everywhere I go, the explanation is a link to the manual, or the wiki (which is just a copy and paste of the manual, gee helpful)...and I follow it but nothing that works is what is written. Let's take boost for example, since that one is asked about most often. I've killed countless hours just trying to access the property tree library only to find out it won't work for what I need, but let's talk about it anyway.

Given the information here, and in the wiki, and in the manual, my boost global variable should be (my install folder is on my desktop...and yes I made sure to build it)

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)

then the include directive
#include <boost\property_tree\ptree.hpp>

BUT THAT DOESN'T WORK

It generates a No such file or directory error.

What actually works for me for property_tree is:

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)

then #include <boost\property_tree\ptree.hpp>

OR

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)

then #include <boost\property_tree\ptree.hpp>

I KNOW, I KNOW, I KNOW that property tree is header only. Don't get me started on things that need linking to a library and that lib field. I just left it because it works with it there. I'm not going to take it out to see if it still works because I'd bet money that even though it's not needed, it wouldn't work without it.

Then, with other libraries having similar file structures, no combination seems to work at all let alone the combination it's supposed to be, making the manual and the wiki COMPLETE NONSENSE.

If there's a setting somewhere else that makes this work the way the manual says, please someone tell me. Maybe there's an explanation somewhere other than the manual as to exactly what "BASE" and "INCLUDE" actually mean instead of what they intuitively mean or what the manual says they mean. If there were, it would help me immensely.

In contrast if all someone has to say is, "learn how to use your compiler", "look at the manual", or "do your research", save your breath. I already know it's coming. If you can find an original insult, you might give me a good laugh. I've spent countless hours reading about the compiler, the IDE, the library and every version of the codeblocks manual and copy/paste job to wiki I can find and trying every combination of paths I can just to try to figure out how the damn thing works and in the end there's absolutely no rhyme or reason to it.

 >:(

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
Re: Global Variable editor
« Reply #4 on: May 26, 2020, 10:56:32 pm »
Code
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

That include is likely wrong!
I use
Code
INCLUDE:C:\Users\MyComputer\Desktop\boost_1_7_0

No idea about the LIB path; I only use boost header files.

Edit: The BASE is correct.

Tim S.


« Last Edit: May 26, 2020, 10:58:10 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline sodev

  • Regular
  • ***
  • Posts: 497
Re: Global Variable editor
« Reply #5 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.

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

Because of the way how boost headers get included your resulting directories must be:
Code
include: root
lib: root/stage/lib

Applied to your examples:

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)
Results into:
Code
include: root/boost
lib: root/libs

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)
Results into:
Code
include: root
lib: root/boost/lib

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)
Results into:
Code
include: root
lib: root/lib

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

Offline SelfTeachingC++

  • Multiple posting newcomer
  • *
  • Posts: 11
Re: Global Variable editor
« Reply #6 on: May 27, 2020, 01:39:12 am »


That include is likely wrong!


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.

« Last Edit: May 27, 2020, 03:59:08 pm by SelfTeachingC++ »

Offline SelfTeachingC++

  • Multiple posting newcomer
  • *
  • Posts: 11
Re: Global Variable editor
« Reply #7 on: May 27, 2020, 02:04:46 am »
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.

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:

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.

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.

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: Global Variable editor
« Reply #8 on: May 27, 2020, 08:21:30 am »
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!

Offline SelfTeachingC++

  • Multiple posting newcomer
  • *
  • Posts: 11
Re: Global Variable editor
« Reply #9 on: May 27, 2020, 01:24:19 pm »
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.
« Last Edit: May 27, 2020, 03:41:43 pm by SelfTeachingC++ »

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
Re: Global Variable editor
« Reply #10 on: May 27, 2020, 05:59:45 pm »
Code
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 above will result in
$(#libxml.lib) being "C:\Users\MyComputer\Desktop\Libxml2\libxml2-2.9.3-win32-x86_64"
$(#libxml.include) being "C:\Users\MyComputer\Desktop\Libxml2\libxml2-2.9.3-win32-x86_64"

What you likely would want is
Code
BASE:C:\Users\MyComputer\Desktop\Libxml2\libxml2-2.9.3-win32-x86_64
INCLUDE:
LIB:

Which will result in
$(#libxml.lib) being "C:\Users\MyComputer\Desktop\Libxml2\libxml2-2.9.3-win32-x86_64\lib"
$(#libxml.include) being "C:\Users\MyComputer\Desktop\Libxml2\libxml2-2.9.3-win32-x86_64\include"

Edit: And most software would include include <libxml\xmlmemory.h> or <xmlmemory.h> instead of <libxml\libxml2\libxml\xmlmemory.h>

Edit2: The slash was wrong! And most software would include <libxml/xmlmemory.h> or <xmlmemory.h>

Tim S.


« Last Edit: May 28, 2020, 09:32:12 am by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline SelfTeachingC++

  • Multiple posting newcomer
  • *
  • Posts: 11
Re: Global Variable editor
« Reply #11 on: June 01, 2020, 04:47:03 pm »
Well, it seems I'm just not going to understand this because that doesn't work for me either. shrug.

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
Re: Global Variable editor
« Reply #12 on: June 01, 2020, 05:02:59 pm »
Well, it seems I'm just not going to understand this because that doesn't work for me either. shrug.

If you learn to read and understand the CB build log you likely will be able to figure it out!
NOTE: Just looking at build messages you will never figure it out.

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org