~/pset1/mario/ $ make mario
clang -ggdb3 -O0 -std=c11 -Wall -Werror -Wextra -Wno-sign-compare -Wno-unused-parameter -Wno-unused-variable -Wshadow mario.c -lcrypt -lcs50 -lm -o mario
mario.c:6:1: error: expected identifier or '('
{
^
1 error generated.
make: *** [<builtin>: mario] Error 1
~/pset1/mario/ $
This error message means you are missing a bracket ")" or "(" in line 6 of your source code.
mario.c:6:1: refers to the address or the location of the error.
Related
I have variable CC_OPTIONS has value set like below
-arch arm64 -mcpu=abc1 -c --debug -O2 -static -fstack-protector -ffreestanding -nostartfiles -std=c11
I wanted to extract -mcpu=abc1 from CC_OPTIONS
Tried below approach, but getting more than what i wanted.
string(REGEX REPLACE ".*mcpu=(.*)\ .*" "\\1" CPU_TYPE "${CC_OPTIONS}")
any suggestions?
If you use if(MATCHES) you can get character groups of the match using CMAKE_MATCH_<n>
set(MY_VAR "-arch arm64 -mcpu=abc1 -c --debug -O2 -static -fstack-protector -ffreestanding -nostartfiles -std=c11")
if (MY_VAR MATCHES "^([^ ]+ +)*(-mcpu=[^ ]+)( +[^ ]+)*$")
message(STATUS "Found match: ${CMAKE_MATCH_2}")
else()
message(FATAL_ERROR "mismatch")
endif()
Like that:
cmake_minimum_required (VERSION 2.8.11)
project (HELLO)
set(CC_OPTIONS "-arch arm64 -mcpu=abc1 -c --debug -O2 -static -fstack-protector -ffreestanding -nostartfiles -std=c11")
message(${CC_OPTIONS})
string(REGEX MATCH "\\-mcpu=[^ $]+" CPU_TYPE ${CC_OPTIONS})
message(${CPU_TYPE})
Example:
$ cmake .
-arch arm64 -mcpu=abc1 -c --debug -O2 -static -fstack-protector -ffreestanding -nostartfiles -std=c11
-mcpu=abc1
-- Configuring done
-- Generating done
-- Build files have been written to: /home/ja/cmake
I am trying to run the calculator example for Hexagon DSP SDK following the instructions in file:///C:/Qualcomm/Hexagon_SDK/3.2/docs/calculator_android.html
In the command line I have setup the sdk in the following way:
setup_sdk_env.cmd
I have cleaned and built the android module successfully
make tree V=android_Debug [CDSP_FLAG = 1]
But I have an error when trying to do it for the hexagon module.
make tree V=hexagon_Debug_dynamic [CDSP_FLAG = 1]
This is what I get:
C:\Qualcomm\Hexagon_SDK\3.2\examples\common\calculator>make tree V=hexagon_Debug_dynamic CDSP=1
making C:\Qualcomm\Hexagon_SDK\3.2/test/common/test_util
El sistema no puede encontrar la ruta especificada.
make[1]: *** [hexagon_Debug_dynamic/test_utils.o] Error 1
ERROR making C:\Qualcomm\Hexagon_SDK\3.2/test/common/test_util
make[1]: Entering directory `C:/Qualcomm/Hexagon_SDK/3.2/test/common/test_util'
"C:/Qualcomm/Hexagon_SDK/3.2/Tools/bin/hexagon-clang" -mv60 -c -v -G0 -g -O0 -Wall -Werror -Wno-cast-align -Wpointer-arith -Wno-missing-braces -Wno-strict-aliasing -fno-exceptions -fno-strict-aliasing -fno-zero-initialized-in-bss -fdata-sections -mllvm -disable-hsdr -fpic -D__V_DYNAMIC__ -Wstrict-prototypes -Wnested-externs -D__FILENAME__=\"test_utils.c\" -D_DEBUG -Iinc -Isrc -IC:\Qualcomm\Hexagon_SDK\3.2/incs -IC:\Qualcomm\Hexagon_SDK\3.2/incs/stddef -Ihexagon_Debug_dynamic -o hexagon_Debug_dynamic/test_utils.o src/test_utils.c
make[1]: Leaving directory `C:/Qualcomm/Hexagon_SDK/3.2/test/common/test_util'
make: *** [MAKE_D_7_LIBDIR] Error 1
Note my computer is Spanish, "El sistema no puede encontrar la ruta especificada." means that the system was not able to find the specified path.
When you make the calculator and specify 'tree' the calculator's dependencies are also built. One of which is test_utils.
Could be a number of things
tools are missing (compiler)
test_utils are missing
something else...
Next step is to run the command listed in make output by itself from the test_util directory to get more information on what is missing. (C:\Qualcomm\Hexagon_SDK\3.2/test/common/test_util)
"C:/Qualcomm/Hexagon_SDK/3.2/Tools/bin/hexagon-clang" -mv60 -c -v -G0 -g -O0 -Wall -Werror -Wno-cast-align -Wpointer-arith -Wno-missing-braces -Wno-strict-aliasing -fno-exceptions -fno-strict-aliasing -fno-zero-initialized-in-bss -fdata-sections -mllvm -disable-hsdr -fpic -D__V_DYNAMIC__ -Wstrict-prototypes -Wnested-externs -D__FILENAME__=\"test_utils.c\" -D_DEBUG -Iinc -Isrc -IC:\Qualcomm\Hexagon_SDK\3.2/incs -IC:\Qualcomm\Hexagon_SDK\3.2/incs/stddef -Ihexagon_Debug_dynamic -o hexagon_Debug_dynamic/test_utils.o src/test_utils.c
check that clang exists
check that test_utils directory and required files below it exist
From the research I have done, the problem seems to be with clang. If that is the case, how would I fix this on a Mac? Would switching to Ubuntu/Linux be a better option?
I'm not sure if it is relevant, but my professor is having us code using C syntax using g++ and saving our files as '.cpp' before we dive into C++.
Warning:
clang: warning: argument unused during compilation: '-ansi'
[-Wunused-command-line-argument]
Makefile:
CC = g++
calendar: main.o calendar.o appt.o day.o time.o
$(CC) main.o calendar.o appt.o day.o time.o -g -ansi -Wall -o calendar.out
%.o: %.cpp
$(CC) -Wall -c $<
You are correct in believing that this warning is issued by clang++ in these
circumstances and not by g++, and that you see it on your Mac because g++ is
really clang++.
The GCC option -ansi is meaningful for compilation and not meaningful
for linkage. Clang is warning you because you are passing it in your linkage recipe:
$(CC) main.o calendar.o appt.o day.o time.o -g -ansi -Wall -o calendar.out
where it is ineffective, and not passing it to your compilation recipe:
$(CC) -Wall -c $<
The wording of the diagnostic is misleading since it is provoked here
precisely by the absence of compilation. Nevertheless, it does
draw attention to a mistake on your part. Remove -ansi from your linkage recipe and add it to your compilation recipe.
Hi all please provide me solution for this i want to execute objective using command line
1)
command : gcc -o filename 'gnustep-config --objc-flags' 'gnustep-config --base-libs' -o filename.m
error :
gcc: gnustep-config: No such file or directory
gcc:gnustep-config: No such file or directory
cc1obj: error: unrecognized command line option "-fobjc-flags"
cc1obj: error: unrecognized command line option "-fbase-libs"
2)
command : gcc -o filename 'gnustep-config --objc-flags' -lgnustep-base filename.m
error :
gcc: gnustep-config: No such file or directory
cc1obj: error: unrecognized command line option "-fobjc-flags"
When i used "-lgnustep-base" one of my error resolved but what about gnustep-config --objc-flags package...
Please provide me solution ......
hey I found the solution !!!!
just type the command "gnustep-config --objc-flags" in command prompt...
You will get o/p like : " /-MMD -MP -DGNUSTEP -DGNUSTEP_BASE_LIBRARY=1 -DGNU_GUI_LIBRARY=1 -DGNU_RUNTIME=1 -DGNUSTEP_BASE_LIBRARY=1 -D_REENTRANT -fPIC -Wall -DGSWARN -DGSDIAGNOSE -Wno-import -g -O2 -fno-strict-aliasing -fexceptions -fobjc-exceptions -D_NATIVE_OBJC_EXCEPTIONS -fgnu-runtime -fconstant-string-class=NSConstantString -I. -I/root/GNUstep/Library/Headers -I/usr/local/include/GNUstep -I/usr/include/GNUstep "
so now you need to copy all this and placed it to the command prompt like this:
"gcc -MMD -MP -DGNUSTEP -DGNUSTEP_BASE_LIBRARY=1 -DGNU_GUI_LIBRARY=1 -DGNU_RUNTIME=1 -DGNUSTEP_BASE_LIBRARY=1 -D_REENTRANT -fPIC -Wall -DGSWARN -DGSDIAGNOSE -Wno-import -g -O2 -fno-strict-aliasing -fexceptions -fobjc-exceptions -D_NATIVE_OBJC_EXCEPTIONS -fgnu-runtime -fconstant-string-class=NSConstantString -I. -I/root/GNUstep/Library/Headers -I/usr/local/include/GNUstep -I/usr/include/GNUstep -o filename -lgnustep-base filename.m "
type all command without any space.......
I've very simple example, and can't correctly build it, I was using next arguments:
g++ -lpq -libpqxx -Wall -o "pg" "pg.cpp" (in dir: /home/user)
/usr/lib/gcc/i586-suse-linux/4.5/../../../../i586-suse-linux/bin/ld: cannot find -lpq
collect2: ld returned 1 exit status
or
returned 1 exit status g++ -libpqxx -Wall -o "pg" "pg.cpp"
(in dir: /home/user)
/usr/lib/gcc/i586-suse-linux/4.5/../../../../i586-suse-linux/bin/ld:
cannot find -libpqxx collect2: ld
but everywere had error.
libpqxx succ installed
#lisuse-home:~> locate libpqxx | grep /lib/
/usr/lib/libpqxx-3.1.so
/usr/lib/libpqxx.la
/usr/lib/libpqxx.so
/usr/lib/pkgconfig/libpqxx.pc
g++ filename.cpp -o target -lpqxx
-lpqxx should take care of -lpq. If for some reason it does not find pq, find pq and put it in the same directory as pqxx.
compiling g++ -libpqxx-3.1 -Wall -c "%f"
building g++ -Wall -o "%e" /usr/lib/libpqxx-3.1.so "%f"