Strange characters present in gcc compilation output message on console - gcc

When I build a C code using gcc, Makefile as below on a Ubuntu 10.04-x32 bit system, under bash shell. The gcc output message has some unwanted characters in the output message(see below: â).
test#dualboot-desktop:~/test/opencv$ make
cc -L/usr/local/lib -I/usr/local/include/opencv2 -lopencv_imgproc -lopencv_highgui -lopencv_video -lopencv_calib3d test1.c -o test_opencv
test1.c: In function âmainâ:
test1.c:13: error: too few arguments to function âcvLoadImageâ
test1.c:21: error: expected â;â before âcvMoveWindowâ
make: *** [test_opencv] Error 1
They jumble up the actual message sometimes and get pesky.
What is the cause of that? Anything wrong in my user settings on ubunti
How can I fix that?

If you set LC_LANG to something that ends in UTF8 but your terminal is having problems (or is not configured to handle) UTF8, then you run into trouble.
Either configure your terminal or set LC_LANG=en_GB.

Same problem with application "Terminal" under linux mint.
Solution:
Terminal (4th menu tab), zurücksetzen/reset, (2nd menu choice from below).
The annoying symbol was a single quote '.
To make it permanent, choose Einstellungen/Settings (2nd menu tab, last choice), then advanced, then Zeichensatz/Character set, change it to "UTF-8" (was some strange ISO, not even 8859-1, in my case)

Related

Makefile error "Missing separator. Stop." in old Crystal project that compiled fine last time I tried (a few years) [duplicate]

This is my makefile:
all:ll
ll:ll.c
gcc -c -Wall -Werror -02 c.c ll.c -o ll $# $<
clean :
\rm -fr ll
When I try to make clean or make make, I get this error:
:makefile:4: *** missing separator. Stop.
How can I fix it?
make defines a tab is required to start each recipe. All actions of every rule are identified by tabs. If you prefer to prefix your recipes with a character other than tab, you can set the .RECIPEPREFIX variable to an alternate character.
To check, I use the command cat -e -t -v makefile_name.
It shows the presence of tabs with ^I and line endings with $. Both are vital to ensure that dependencies end properly and tabs mark the action for the rules so that they are easily identifiable to the make utility.
Example:
Kaizen ~/so_test $ cat -e -t -v mk.t
all:ll$ ## here the $ is end of line ...
$
ll:ll.c $
^Igcc -c -Wall -Werror -02 c.c ll.c -o ll $# $<$
## the ^I above means a tab was there before the action part, so this line is ok .
$
clean :$
\rm -fr ll$
## see here there is no ^I which means , tab is not present ....
## in this case you need to open the file again and edit/ensure a tab
## starts the action part
On VS Code, just click the "Space: 4" on the downright corner and change it to tab when editing your Makefile.
By default, you should always write command after a Tab and not white space. This can be changed to another character with .RECIPEPREFIX variable.
This applies to gcc line (line #4) in your case. You need to insert tab before gcc.
Also replace \rm -fr ll with rm -fr ll. Insert tabs before this command too.
The solution for PyCharm would be to install a Makefile support plugin:
Open Preferences (cmd + ,)
Go to Plugins -> Marketplace
Search for Makefile support, install and restart the IDE.
This should fix the problem and provide a syntax for a makefile.
TLDR;
makefile syntax can be quirky
if you want a line of code to be interpreted as make code it must only be indented with spaces.
if you want a line of code to be interpreted as bash code it must only be indented with tabs
sometask:
ifeq ($FOO,bar) // this is make code. only spaces
echo "foobar" // this is bash code. only tabs
endif // again, this is make code. only spaces
technically its the leading indentation that dictates the interpreter.
Using .editorconfig to fix the tabs automagically:
root = true
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
[Makefile]
indent_style = tab
Its pretty old question but still I would like say about one more option using vi/vim editor to visualize the tabs. If you have vi/vim installed then open a Makefile (e.g. vim Makefile) and enter :set list. This will show number of tabs inserted as below,
%-linux: force$
^I#if [ "$(GCC_VERSION)" = "2.96" ] ; then \$
^I^Iecho ===== Generating build tree for legacy $# architecture =====; \$
^I^I$(CONFIGURE) $(CWD) $# legacy; \$
^Ielse \$
^I^Iecho ===== Generating build tree for $# architecture =====; \$
^I^I$(CONFIGURE) $(CWD) $#; \$
^Ifi$
^Icd build-$#;make$
You started line 4 with "space,space" instead of "tab" - nothing else.
When you created a Makefile in VSCode, You should set the Tab Size: 4.
If anyone of you are using a product from Intellij, the solution for this it's the following:
Go to Preferences > Editor > Code Style
here you need to select the file type related to your problem. But most probably you need to select Other File Types.
In the tab opened mark the checkbox for Use tab character and be careful, Tab size and Indent values must be 4.
The key point was "HARD TAB"
Check whether you used TAB instead of whitespace
Check your .vimrc for set tabstop=X
If you are using mcedit for makefile edit. you have to see the following mark.
This is because tab is replaced by spaces.
To disable this feature go to
gedit->edit->preferences->editor
and remove check for
"replace tab with space"
If you are here searching how to make the tabs and new lines you added understandable by vim you have to first enable tab in vim.
You can do it using :set noet i.e. (to switch from spaces to TAB) before you make your tab additions.
With this command your tabs will look like the other ones (i.e. ^I) and *** missing separator. Stop. error from make will go away :)
after you make changes you can switch back with :set et
Do yourself a favour and make this a permanent member of your .editorconfig, if your editor/IDE supports it (it probably does!)
[Makefile]
indent_style = tab
If you are editing your Makefile in eclipse:
Windows-> Preferences->General->Editor->Text Editors->Show Whitespace Characters -> Apply
Or use the shortcut shown below.
Tab will be represented by gray ">>" and Space will be represented by gray "." as in figure below.
If someone ever comes across this issue with
*** missing separator. Stop.
during the build, they should double-check their file system path to the sources, it should not contain special characters like "#"
e.g. path
/home/user/#my_sources/
might be invalid

How to include header directory in makefile [duplicate]

This question already has answers here:
Error running make: missing separator (did you mean TAB instead of 8 spaces?)
(2 answers)
Closed 5 years ago.
### Compiler arguments
#CC = gcc
gcc -I/usr/lib/jvm/jdk1.8.0_121/include/jni.h
CFLAGSNO = $(EXTRA_CC_ARGS) -Wall -g -I/usr/local/include -DCLASSNAME=$(CLASSNAME)
CFLAGS += $(CFLAGSNO)
When I tried entering this into makefile I was getting this error:
make TARGET=cooja clean
../../../platform/cooja/Makefile.cooja:74: *** missing separator (did you mean TAB instead of 8 spaces?). Stop.
Process returned error code 2
I am having problem with this line:
gcc -I/usr/lib/jvm/jdk1.8.0_121/include/jni.h
As per the instructions from other post I followed these instructions:
Fixing the issue
You can fix this by changing the Spaces to actual Tab characters. I used vim to repair my file. Simply open it:
$ vim makefile
And then run this command within:
:%s/^[ ]\+/^I/
This will substitute all the lines that begin with 1 or more Spaces with an actual Tab.
But still not working
How can I include this into makefile?
Does your editor use spaces instead of tabs?
GNU Make requires real tab characters in its Makefiles.
You can link the header with -I flag. for example -Icurl/, it will include all the header in that directory.
Sample way:
INCLUDE_DIR = app/curl/include
CFLAGS=-c -Wall -I$(INCLUDE_DIR )
Answer to your question:
ERROR: Makefile:8: *** missing separator (did you mean TAB instead of
8 spaces?). Stop.
This is the classical problem. Makefile accepts only tab indentation
with 4 space not 8. Change the setting of editor what you use to set the tab
width to 4, this will resolve your problem.

Ada Compilation Print full path

Simple question. I am compiling an ada program with gnat. The gcc command ends up looking like gcc -c -Ia -Ibunch -Iof -Iincludes -I- -o /some/object/file.o /some/source/file.adb however the error format consists of just file.adb:line:offset: problem.
Is there any way to get GNAT make or gcc to print the full path to the file in its errors, as specified on the command line? IE: to get /some/source/file.adb:line:offset: problem.
I know that with the -gnatv one could argue that it prints the full path, but I want something significantly less verbose than that.
you need -gnatef option:
-gnatef
Display full source path name in brief error messages.
gcc -gnatef -c %CD%\file.adb
C:\DATA\jff\data\python\stackoverflow\file.adb:1:01: "procedure" expected
https://gcc.gnu.org/onlinedocs/gcc-4.3.6/gnat_ugn_unw/Switches-for-gcc.html

unrecognized -a option `ck_size'

I am using GCC ver-4.6.4 (both in Mac and Linux Mint 15) to compile a code I do for research.
The command I am using is :
gfortran -O2 -fopenmp -Wl,-stack_size,1000000 <...Lots of files...> -o a.out
, where I omit the actual file names.
This code compiles OK in Mac, however I get the following error in Mint:
/usr/bin/ld: unrecognized -a option `ck_size'
collect2: error: ld returned 1 exit status
make[1]: *** [a.out] Error 1
In Mint, this will compile if I do not use any flags at all, therefore this problem is related to OpenMP.
However, I do need OpenMP and do not understand what it says in the error, because I do not have 'ck_size'. BTW, deleting -O2 doesn't help.
The problem is not related to OpenMP, it is related to your different OS's.
-stack_size is specific to Macintosh and refers to the maximal size of arrays on the stack. Linux changes the stack size via the terminal command ulimit (to check your Mint settings type, ulimit -a to see everything, the stack size can be seen with ulimit -s, see the ulimit man page for more information).
Thus, you need to scrap that whole -stack_size,100000 portion from your compiler flag, it means nothing in Linux.
You passed -Wl,-stack_size,1000000 to gfortran, which is passing on the option "-stack_size 1000000" to the linker ld. It is interpreting "st" as single letter options "-s" and "-t", then reading the next letter as an option "-a", and the rest of the word ("ck_size") as its parameter.
I could find no reference to a -stack_size option for ld. It looks like the option is --stack, so you need to put something like -Wl,--stack,1000000 instead.

MinGW gcc unrecognized command line option '-Wl'/'Wa'/'Wp'

In short, I have the most recent version of MinGW and I am attempting to pass options into the linker and the like.
For example, I wanted to change the stack size by:
gcc -Wl,--stack,[new size in bytes]
But it recognized neither -Wl nor --stack. And that applies for the other options too.
I'm able to compile my programs all well in good, it just seems as though I cannot use the various gcc options.
Is this an issue with MinGW, or am I overlooking something more?
I just confirmed in the documentation about passing arguments to linker, that you cannot have a space before the number, so it should be:
gcc -Wl,--stack,[new size in bytes]
Commas are changed into spaces, but a real space makes the next option gcc option, not linker option.

Resources