What does the gcc accent character mean/do? - gcc

I have the following gcc command taken from a tutorial to compile my simple mysql c test program.
gcc mysql_test.c `mysql_config --cflags --libs`
I am trying to understand what is happening here with mysql_config. But I cannot find any information by googling or searching SO for the use of accents (the lower case tilde character) in gcc commands. I don't see anything relevant in the gcc options index.
Can anyone explain this or describe what gcc process the accent is invoking?

The backticks here are for the shell, not for gcc. The shell executes the command inside the backticks and substitutes the output of the command. Presumably the msql_config command with those options produces the options you should pass to gcc.

Related

Automating GCC Compiler arguments to create easier compilations - Windows OS?

Goal
When I run the command:
gcc -ggdb -std=c99 -Wall -Werror hello.c -lcs50 -o test.exe from the root directory
I am able to build the test.exe file and when I run test.exe all is well (thanks to this post by Manohar Reddy Poreddy)
However all of those flags are a little bit cumbersome and I think it would great to condense them into a 'make' command or similar. How would I do this on windows?
Context
GCC, G++ and GDB all seem to be correctly linked (I used chocolatey which paths everything automatically)
Okay so I found what I was looking for.
I hope this answer can help others. Turns out the utility is called 'make' (no surprises). In your directory you essentially create a 'makefile' where you can include your command line arguments which saves on repeated typing in the command line for each compile.
Here is an excellent response on how to install 'make' for windows and was perfect for my use case as a Chocolatey user.
I also found this resource which helps newcomers begin to get their head round GCC which I highly recommend if you're coming into this like I was and felt completely out of your depth.

Force CMake to generate zsh friendly command lines

I have a CMake such that when I executed the build (make) in verbose mode, it prints commands such as:
/usr/bin/nvcc -forward-unknown-to-host-compiler -DBOOST_ALL_NO_LIB -DBOOST_CHRONO_DYN_LINK -DBOOST_PP_VARIADICS -DBOOST_TIMER_DYN_LINK -DBOOST_UNIT_TEST_FRAMEWORK_DYN_LINK --expt-relaxed-constexpr --extended-lambda -Xcudafe "--display_error_number --diag_suppress=implicit_return_from_non_void_function --diag_suppress=class_and_member_name_conflict" --generate-code=arch=compute_61,code=[compute_61,sm_61] -std=c++17 -x cu -c /home/correaa/prj/alf/boost/multi/adaptors/thrust/test/array.cu -o CMakeFiles/array.cu.x.dir/array.cu.o
presumably, this is a bash-compatible command because I have no problem running it in bash.
However it is not a valid zsh command (the shell I use) because it gives an error:
zsh: no matches found: --generate-code=arch=compute_61,code=[compute_61,sm_61]
I presume it is the square brackets that trip zsh [...].
First question is how can I correct manually this command to run on both zsh and bash?
Second question is, is there a way to for CMake to generate makefiles that contain commands that are compatible with zsh?

Opensmile installation on ubuntu

when giving the command:
./configure CXXFLAGS=‘‘-O2 -mfpmath=sse -march=native’’ CFLAGS=‘‘-O2 -mfpmath=sse -march=native’’
it shows me the following error:
configure: error: unrecognized option: `-mfpmath=sse'
Try `./configure --help' for more information
I used sse2 but yet it is not working. On opensmile installation guide it is written that this option is not supported by all compilers.
The shell supports "..." and '...' (plain ASCII quotes) to quote words that contain spaces.
Your command uses fancy directional Unicode quotation marks, but not the usual “...” double quote ones, but the ‘...’ single quote version, twice: ‘‘...’’.
The shell doesn't understand those quotes, which is why configure thinks you're trying to set CXXFLAGS=‘‘-O2 and -mfpmath=sse is parsed as a separate option.
Fix:
./configure CXXFLAGS='-O2 -mfpmath=sse -march=native' CFLAGS='-O2 -mfpmath=sse -march=native'

Eclipse CDT: pkg-config indexing

I`m developing a application using gtkmm with eclipse. While I could have setup gtkmm include paths and linking options manually, i decided to let pkg-config do the work because of the huge number of referenced projects. This was quite easy as adding the appropriate pkg-config command to the compiler invocation worked just fine because one can simply use the
`...`
shell substitution since eclipse will generate a makefile which is then executed.
Setting up the indexer right isnt that easy though. Instead of executing shell script in a interpreter, eclipse executes the compiler directly and pass command line arguments directly without substituting them before.
How can one execute shell script when executing the indexer?
The solution is to execute the bash interpreter with the -c flag directly instead of executing g++.
For the scenario described in the question the configurations are as followed:
Compiler invocation command
bash
Compiler invocation arguements
-c "g++ `pkg-config gtkmm-2.4 --cflags` -E -P -v -dD ${plugin_state_location}/specs.cpp"

Control GNU autotools make output

I am using GNU autoconf/automake. Is there any way I can control what make prints to stdout from configure.ac or Makefile.am? For example, suppress mv and cp commands being printed out to the screen, only print the name of the file being compiled by gcc rather than the whole command line, highlight gcc warnings in some way.
Is Prettify Automake what you want?
Edit: As of Automake 1.10b, silent-rules is built-in. Not the same code or style but similar in effect.
Modern Automake (after in 1.10b) supports --silent-rules which will suppress the full compile command. (eg, output is "CC foo" instead of "gcc -DHAVE_CONFIG_H ...") That may be all you need. You need to add "silent-rules" to AM_INIT_AUTOMAKE and pass --enable-silent-rules to configure (or put it in CONFIG_SITE) to enable the feature. See the automake docs for details.
I believe the easiest thing is to write a wrapper script which runs *make and parses the output. I believe I have seen this being done in Ubuntu somewhere ...

Resources