adrienlucca.wordpress.com adrienlucca.wordpress.com - 3 months ago 15
C++ Question

Code::Blocks where are "compile switches"?

I have a problem of terminology here, that would be super nice if you can help, I am not sure what this means.

On the tetgen website, the instructions to compile the tetgen library on Windows are as follows:


To create a library do the following minimum steps:


  • Create a Win32 static library called
    library
    .

  • Add all source files into this project.

  • Add the symbol
    TETLIBRARY
    to compile switches.

  • Build the project.




I don't understand this statement:


Add the symbol
TETLIBRARY
to compile switches.


Could you please tell me how to do that, and what "compile switches" refers to?

Answer

In this case, "compile switches" is referring to preprocessor definitions that direct what gets compiled. To add the TETLIBRARY definition in Codeblocks, there are a couple ways:

1) You can insert it directly into the code, using this line:

#define TETLIBRARY

In general this needs to be placed appropriately, such that it is defined prior to all references across files. (In this case, sticking it at the top of the .h file would work.)

2) The preferred way, when the preprocessor definition is used to direct compilation, is to include it in your project configuration. In Codeblocks, you would follow these steps: a) Right-click on the project you created in the Projects tab. b) Click on "Build Options...". c) With the debug or release target selected, click on the "#defines" tab. d) In the blank space, enter

TETLIBRARY

e) Repeat steps c and d for the other build target, if desired.