Author Topic: How to add compiler information  (Read 2186 times)

Offline Psyclone

  • Single posting newcomer
  • *
  • Posts: 2
How to add compiler information
« on: June 22, 2022, 10:09:58 pm »
Greetings, I have successfully compiled a program at the command but would like to compile it in code blocks. The following is the command line I used...

g++ -Wall -D__WINDOWS_DS__ -o audioprobe audioprobe.cpp RtAudio.cpp -lole32 -lwinmm -ldsound

Where do I enter this information in codeblocks to get the project to compile?

Thanks in advance, sorry if its an obvious or nonsensical question.

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: How to add compiler information
« Reply #1 on: June 23, 2022, 01:29:35 am »
you have
precompiler defines:
Code
-D__WINDOWS_DS__
compiler flags:
Code
-Wall
and linker libraries
Code
-lole32 -lwinmm -ldsound

Pre compiler commands:
Project->Build options->Select the project name on the left->compiler settings->#defines
add "__WINDOWS_DS__" without the -D

Compiler commands:
Project->Build options->Select the project name on the left->compiler settings->compiler flags
search for Wall in the list
or
Project->Build options->Select the project name on the left->compiler settings->other compiler flags
add "-Wall"

Linker libraries
Project->Build options->Select the project name on the left->Linker settings->link libraries
press the "Add" button at the bottom and enter the libraries without "-l" so for your example
Code
ole32
winmm
dsound
for each library you have to press the add button

if you have a problem: https://wiki.codeblocks.org/index.php?title=FAQ-Compiling_(general)#Q:_How_do_I_report_a_compilation_problem_on_the_forums.3F

hope this helped

Offline Psyclone

  • Single posting newcomer
  • *
  • Posts: 2
Re: How to add compiler information
« Reply #2 on: June 23, 2022, 02:13:26 am »
Thanks so much.

One more question, I'm guessing this is how it works...

if I write a #defines  __WINDOWS_DS__  at the top of a file it will add the following code to the file. 

The "#if defined" below is asking if I wrote the "#defines" above? Thanks again for you help.

CODE....
#if defined(__WINDOWS_DS__) // Windows DirectSound API

// Modified by Robin Davies, October 2005
// - Improvements to DirectX pointer chasing.
// - Bug fix for non-power-of-two Asio granularity used by Edirol PCR-A30.
// - Auto-call CoInitialize for DSOUND and ASIO platforms.
// Various revisions for RtAudio 4.0 by Gary Scavone, April 2007
// Changed device query structure for RtAudio 4.0.7, January 2010

#include <windows.h>
#include <process.h>
#include <mmsystem.h>
#include <mmreg.h>
#include <dsound.h>
#include <assert.h>
#include <algorithm>

#if defined(__MINGW32__)
  // missing from latest mingw winapi
#define WAVE_FORMAT_96M08 0x00010000 /* 96 kHz, Mono, 8-bit */
#define WAVE_FORMAT_96S08 0x00020000 /* 96 kHz, Stereo, 8-bit */
#define WAVE_FORMAT_96M16 0x00040000 /* 96 kHz, Mono, 16-bit */
#define WAVE_FORMAT_96S16 0x00080000 /* 96 kHz, Stereo, 16-bit */
#endif

#define MINIMUM_DEVICE_BUFFER_SIZE 32768

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1553
Re: How to add compiler information
« Reply #3 on: June 23, 2022, 10:05:51 am »
If you add __WINDOWS_DS__ to the project, it will be defined in every compilation command.
If you define it in a file, it will be defined only during current compilation command.

Read about preprocessing elsewhere, this is OT here.