I am new to makefiles. I created the following makefile:
CC=g++
DEBUG= -g
CFLAGS=-c -Wall -std=c++11 $(DEBUG)
all: hello
hello: ConsoleApplication1.o clock.o communication.o device_manager.o devices.o
$(CC) ConsoleApplication1.o clock.o communication.o device_manager.o devices.o
ConsoleApplication1.o: ConsoleApplication1.cpp
$(CC) $(CFGLAS) ConsoleApplication1.cpp
clock.o: clock.cpp clock.h
$(CC) $(CFGLAS) clock.cpp
communication.o: communication.cpp
$(CC) $(CFGLAS) communication.cpp
device_manager.o: device_manager.cpp
$(CC) $(CFGLAS) device_manager.cpp
devices.o: devices.cpp
$(CC) $(CFGLAS) devices.cpp
clean:
rm -rf *.o hello
I put the makefile in the directory of all the code files and run the command "make" from the command line.
I got many errors like:
ConsoleApplication1.cpp:494:30: error: ‘chrono’ is not a member of ‘std’
mytime::duration_timer_t timer;
^
ConsoleApplication1.cpp:494:30: error: ‘chrono’ is not a member of ‘std’
ConsoleApplication1.cpp:494:55: error: template argument 1 is invalid
mytime::duration_timer_t timer;
^
ConsoleApplication1.cpp:494:65: error: invalid type in declaration before ‘;’ token
mytime::duration_timer_t timer;
^
ConsoleApplication1.cpp:495:11: error: request for member ‘set_duration’ in ‘timer’, which is of non-class type ‘int’
timer.set_duration(std::chrono::seconds(120));
^
ConsoleApplication1.cpp:495:29: error: ‘std::chrono’ has not been declared
timer.set_duration(std::chrono::seconds(120));
^
ConsoleApplication1.cpp:496:16: error: request for member ‘start’ in ‘timer’, which is of non-class type ‘int’
for( timer.start(); not(timer.expired()); )
When I compile excactly the same file codes in codeBlocks it compiles, so I guess that I have some mistake in the make file.
I have one header file in my project name "general.h" which doesn't have a cpp file. Should I put it also in the makefile?
Your rules say $(CFGLAS), not $(CFLAGS).
That means -std=c++11 is never passed to the compiler, so C++11 features don't exist for you.
Pay more attention to detail!
You will also need to pass $(CFLAGS) to $(CC) in your hello rule, otherwise your compiler invocations will be out of sync and all hell may break loose.
While you compile your object files with -std=c++11 you link them without that flag. Have you tried adding -std=c++11 to hello rule?
I am trying to run a couple of fixed-formatted Fortran 90 files on a PC. They run flawlessly with gfortran version 4.1.1, but not with gfortran 4.1.2 or later (I tried). Here are all the things I've tried:
I tried using the tag "-std=legacy" in Cygwin with version 4.9.3 so the processor compiles the code as a Fortran 77 file. I had to work out some kinks, but eventually it began to work splendidly. Then the following error popped up:
Note: The following floating-point exceptions are signalling: IEEE_INVALID_FLAG IEEE_DIVIDE_BY_ZERO IEEE_OVERFLOW_FLAG IEEE_DENORMAL
I then moved on to plan B: trying to get gfortran 4.1.1 on my PC, on Cygwin.
Building gfortran 4.1.1 from source in Cygwin (since I can't find binary files anywhere online). Cygwin already has a package for gfortran, but only version 4.9.3. I used gcc-fortran-4.1.1.tar.bz2; basically I want to downgrade gfortran in Cygwin. the files in the tarball were lacking so I had to debug some things and add some files with some wget's (like the most current versions of config.guess and config.sub) to get it to configure (I also used autoconf, autoreconf, and automake). Long story short, I tried to run make and I got a long list of errors.
I have access to a Linux machine with gfortran 4.1.1 already on it (on which it works perfectly), and tried to make it there, but it gave a lot of errors as well, completely different from those from Cygwin. At the end are the errors, the first being those from Cygwin and the latter from Linux. I access the Linux computer remotely via SSH; the entire point of this endeavor is to run the codes on PC's (and/or Mac's) so that we don't have to transfer thousands of images and files back and forth.
I tried to download g95 onto Cygwin via the tarball g95-x86-cygwin-41.tgz found online. The INSTALL file said I just need to extract the files in the root directory, create a symbolic link somewhere, and it should work. I did and then I typed it in and nothing happened; no "-bash: ... No such file or directory" error or other errors, but simply nothing. No executable was created-nothing. I even mispelled --version and no error popped up.
J Double B#jdoubleb-PC /wexlerwork/autismcases_CTs/autismcases_23_VOID
$ g95 --versio
J Double B#jdoubleb-PC /wexlerwork/autismcases_CTs/autismcases_23_VOID
$ g95 --version
J Double B#jdoubleb-PC /wexlerwork/autismcases_CTs/autismcases_23_VOID
$ g95 --help
J Double B#jdoubleb-PC /wexlerwork/autismcases_CTs/autismcases_23_VOID
$ man g95
No manual entry for g95
J Double B#jdoubleb-PC /wexlerwork/autismcases_CTs/autismcases_23_VOID
$ g95 ver5.2_v3.5.f -o f05
J Double B#jdoubleb-PC /wexlerwork/autismcases_CTs/autismcases_23_VOID
I even tried the self-extracting files for gcc 4.1 from the following website: http://g95.org/downloads.shtml. I tried the HTTP link and it gave me the tarball I mentioned above. I tried the FTP link and it did nothing useful.
I tried g95 via MinGW and my Windows 7 command shell (from the Start menu). It was an executable, so it was nice to not have to build it. It downloaded and it works. However, there are a lot of errors. It didn't recognize all the comments beginning with 'c', so I changed them all to !'s. Then the compiler mentioned continuations. There are hundreds of continuations in the code, and only a limited amount are allowed per version and format type I think. Essentially the compiler processes Fortran 95 files (naturally-it's in the name), but the file is not a Fortran file. I tried to pass a "-std=legacy" or something similar, but apparently the only options are for Fortran 95, 2003, and 2008. It'd take forever to change a 7000-line and a 3000-line Fortran 77/90 file to Fortran 95 files, so I stopped. Well, I figured I'd give it a try.
I tried changing the extensions of the files to *.f90, but they were interpreted by my computer to be Fortran 95 files and it didn't work.
I'd rather not continue to try and change the codes so they work for some kind of compiler, but rather simply get gfortran 4.1.1 on my computer and have them running just like on the Linux computer. I'd also like to not have to build anything from source-executables for Fortran compilers are welcome. However, I'm not completely closed to the prospect.
Any help from anyone is welcome; thank you in advance for your consideration.
*FROM CYGWIN*
J Double B#jdoubleb-PC /gcc-4.1.1
$ make
cat: libgfortran/../gcc/BASE-VER: No such file or directory
makefile:2442: warning: overriding commands for target `.F90.o'
makefile:1059: warning: ignoring old commands for target `.F90.o'
makefile:2445: warning: overriding commands for target `.F90.obj'
makefile:1062: warning: ignoring old commands for target `.F90.obj'
makefile:2448: warning: overriding commands for target `.F90.lo'
makefile:1065: warning: ignoring old commands for target `.F90.lo'
C:/Users/jdoubleb/Documents/Academia/Cygwin_etal/bin/sh.exe libgfortran/mk-kinds-h.sh ' -I . -Wall -fno-repack-arrays -fno-underscoring ' > kinds.h || rm kinds.h
grep '^#' < kinds.h > kinds.inc
grep '^#' < libgfortran/c99_protos.h > c99_protos.inc
cp libgfortran/config/fpu-glibc.h fpu-target.h
C:/Ch/bin/make all-am
cat: libgfortran/../gcc/BASE-VER: No such file or directory
make[1]: Entering directory `C:/Users/jdoubleb/Documents/Academia/Cygwin_etal/gcc-4.1.1'
makefile:2442: warning: overriding commands for target `.F90.o'
makefile:1059: warning: ignoring old commands for target `.F90.o'
makefile:2445: warning: overriding commands for target `.F90.obj'
makefile:1062: warning: ignoring old commands for target `.F90.obj'
makefile:2448: warning: overriding commands for target `.F90.lo'
makefile:1065: warning: ignoring old commands for target `.F90.lo'
C:/Users/jdoubleb/Documents/Academia/Cygwin_etal/bin/sh.exe ./libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -Ilibgfortran -I. -iquotelibgfortran/io -Ilibgfortran/../gcc -Ilibgfortran/../gcc/config -I../.././gcc -D_GNU_SOURCE -std=gnu99 -Wall -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -Wextra -Wwrite-strings -std=gnu99 -g -O2 -Wunknown-pragmas -c -o compile_options.lo `test -f 'runtime/compile_options.c' || echo 'libgfortran/'`runtime/compile_options.c
libtool: compile: gcc -DHAVE_CONFIG_H -I. -Ilibgfortran -I. -iquotelibgfortran/io -Ilibgfortran/../gcc -Ilibgfortran/../gcc/config -I../.././gcc -D_GNU_SOURCE -std=gnu99 -Wall -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -Wextra -Wwrite-strings -std=gnu99 -g -O2 -Wunknown-pragmas -c libgfortran/runtime/compile_options.c -DDLL_EXPORT -DPIC -o .libs/compile_options.o
In file included from libgfortran/runtime/compile_options.c:32:0:
libgfortran/libgfortran.h:204:9: error: unknown type name ‘GFC_INTEGER_4’
typedef GFC_INTEGER_4 gfc_charlen_type;
^
libgfortran/libgfortran.h:254:51: error: unknown type name ‘GFC_INTEGER_4’
typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_INTEGER_4) gfc_array_i4;
^
libgfortran/libgfortran.h:245:3: note: in definition of macro ‘GFC_ARRAY_DESCRIPTOR’
type *data;\
^
libgfortran/libgfortran.h:255:51: error: unknown type name ‘GFC_INTEGER_8’
typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_INTEGER_8) gfc_array_i8;
^
libgfortran/libgfortran.h:245:3: note: in definition of macro ‘GFC_ARRAY_DESCRIPTOR’
type *data;\
^
libgfortran/libgfortran.h:259:51: error: unknown type name ‘GFC_REAL_4’
typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_REAL_4) gfc_array_r4;
^
libgfortran/libgfortran.h:245:3: note: in definition of macro ‘GFC_ARRAY_DESCRIPTOR’
type *data;\
^
libgfortran/libgfortran.h:260:51: error: unknown type name ‘GFC_REAL_8’
typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_REAL_8) gfc_array_r8;
^
libgfortran/libgfortran.h:245:3: note: in definition of macro ‘GFC_ARRAY_DESCRIPTOR’
type *data;\
^
libgfortran/libgfortran.h:267:51: error: unknown type name ‘GFC_COMPLEX_4’
typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_COMPLEX_4) gfc_array_c4;
^
libgfortran/libgfortran.h:245:3: note: in definition of macro ‘GFC_ARRAY_DESCRIPTOR’
type *data;\
^
libgfortran/libgfortran.h:268:51: error: unknown type name ‘GFC_COMPLEX_8’
typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_COMPLEX_8) gfc_array_c8;
^
libgfortran/libgfortran.h:245:3: note: in definition of macro ‘GFC_ARRAY_DESCRIPTOR’
type *data;\
^
libgfortran/libgfortran.h:275:51: error: unknown type name ‘GFC_LOGICAL_4’
typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_LOGICAL_4) gfc_array_l4;
^
libgfortran/libgfortran.h:245:3: note: in definition of macro ‘GFC_ARRAY_DESCRIPTOR’
type *data;\
^
libgfortran/libgfortran.h:276:51: error: unknown type name ‘GFC_LOGICAL_8’
typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_LOGICAL_8) gfc_array_l8;
^
libgfortran/libgfortran.h:245:3: note: in definition of macro ‘GFC_ARRAY_DESCRIPTOR’
type *data;\
^
libgfortran/libgfortran.h:456:51: error: expected ‘)’ before ‘char’
extern const char *gfc_itoa (GFC_INTEGER_LARGEST, char *, size_t);
^
In file included from libgfortran/runtime/compile_options.c:32:0:
libgfortran/libgfortran.h:457:16: error: ‘gfc_itoa’ undeclared here (not in a function)
internal_proto(gfc_itoa);
^
libgfortran/libgfortran.h:79:52: note: in definition of macro ‘sym_rename2’
#define sym_rename2(old, ulp, new) extern __typeof(old) old __asm__(#ulp #new)
^
libgfortran/libgfortran.h:77:30: note: in expansion of macro ‘sym_rename1’
#define sym_rename(old, new) sym_rename1(old, __USER_LABEL_PREFIX__, new)
^
libgfortran/libgfortran.h:120:28: note: in expansion of macro ‘sym_rename’
# define internal_proto(x) sym_rename(x, IPREFIX(x))
^
libgfortran/libgfortran.h:457:1: note: in expansion of macro ‘internal_proto’
internal_proto(gfc_itoa);
^
In file included from libgfortran/runtime/compile_options.c:32:0:
libgfortran/libgfortran.h:459:48: error: expected ‘)’ before ‘char’
extern const char *xtoa (GFC_UINTEGER_LARGEST, char *, size_t);
^
In file included from libgfortran/runtime/compile_options.c:32:0:
libgfortran/libgfortran.h:460:16: error: ‘xtoa’ undeclared here (not in a function)
internal_proto(xtoa);
^
libgfortran/libgfortran.h:79:52: note: in definition of macro ‘sym_rename2’
#define sym_rename2(old, ulp, new) extern __typeof(old) old __asm__(#ulp #new)
^
libgfortran/libgfortran.h:77:30: note: in expansion of macro ‘sym_rename1’
#define sym_rename(old, new) sym_rename1(old, __USER_LABEL_PREFIX__, new)
^
libgfortran/libgfortran.h:120:28: note: in expansion of macro ‘sym_rename’
# define internal_proto(x) sym_rename(x, IPREFIX(x))
^
libgfortran/libgfortran.h:460:1: note: in expansion of macro ‘internal_proto’
internal_proto(xtoa);
^
In file included from libgfortran/runtime/compile_options.c:32:0:
libgfortran/libgfortran.h:550:1: warning: parameter names (without types) in function declaration
extern void stop_numeric (GFC_INTEGER_4);
^
libgfortran/libgfortran.h:563:1: error: unknown type name ‘GFC_INTEGER_4’
GFC_INTEGER_4 *internal_pack_4 (gfc_array_i4 *);
^
libgfortran/libgfortran.h:566:1: error: unknown type name ‘GFC_INTEGER_8’
GFC_INTEGER_8 *internal_pack_8 (gfc_array_i8 *);
^
libgfortran/libgfortran.h:574:1: error: unknown type name ‘GFC_COMPLEX_4’
GFC_COMPLEX_4 *internal_pack_c4 (gfc_array_c4 *);
^
libgfortran/libgfortran.h:577:1: error: unknown type name ‘GFC_COMPLEX_8’
GFC_COMPLEX_8 *internal_pack_c8 (gfc_array_c8 *);
^
libgfortran/libgfortran.h:585:54: error: unknown type name ‘GFC_INTEGER_4’
extern void internal_unpack_4 (gfc_array_i4 *, const GFC_INTEGER_4 *);
^
libgfortran/libgfortran.h:588:54: error: unknown type name ‘GFC_INTEGER_8’
extern void internal_unpack_8 (gfc_array_i8 *, const GFC_INTEGER_8 *);
^
libgfortran/libgfortran.h:596:55: error: unknown type name ‘GFC_COMPLEX_4’
extern void internal_unpack_c4 (gfc_array_c4 *, const GFC_COMPLEX_4 *);
^
libgfortran/libgfortran.h:599:55: error: unknown type name ‘GFC_COMPLEX_8’
extern void internal_unpack_c8 (gfc_array_c8 *, const GFC_COMPLEX_8 *);
^
libgfortran/libgfortran.h:609:8: error: unknown type name ‘GFC_INTEGER_4’
extern GFC_INTEGER_4 compare_string (GFC_INTEGER_4, const char *,
^
libgfortran/libgfortran.h:609:53: error: expected ‘)’ before ‘const’
extern GFC_INTEGER_4 compare_string (GFC_INTEGER_4, const char *,
^
In file included from libgfortran/runtime/compile_options.c:32:0:
libgfortran/libgfortran.h:611:15: error: ‘compare_string’ undeclared here (not in a function)
iexport_proto(compare_string);
^
libgfortran/libgfortran.h:79:52: note: in definition of macro ‘sym_rename2’
#define sym_rename2(old, ulp, new) extern __typeof(old) old __asm__(#ulp #new)
^
libgfortran/libgfortran.h:77:30: note: in expansion of macro ‘sym_rename1’
#define sym_rename(old, new) sym_rename1(old, __USER_LABEL_PREFIX__, new)
^
libgfortran/libgfortran.h:139:26: note: in expansion of macro ‘sym_rename’
# define export_proto(x) sym_rename(x, PREFIX(x))
^
libgfortran/libgfortran.h:141:27: note: in expansion of macro ‘export_proto’
# define iexport_proto(x) export_proto(x)
^
libgfortran/libgfortran.h:611:1: note: in expansion of macro ‘iexport_proto’
iexport_proto(compare_string);
^
In file included from libgfortran/runtime/compile_options.c:32:0:
libgfortran/libgfortran.h:615:26: error: unknown type name ‘GFC_INTEGER_4’
extern void random_seed (GFC_INTEGER_4 * size, gfc_array_i4 * put,
^
In file included from libgfortran/runtime/compile_options.c:32:0:
libgfortran/libgfortran.h:617:15: error: ‘random_seed’ undeclared here (not in a function)
iexport_proto(random_seed);
^
libgfortran/libgfortran.h:79:52: note: in definition of macro ‘sym_rename2’
#define sym_rename2(old, ulp, new) extern __typeof(old) old __asm__(#ulp #new)
^
libgfortran/libgfortran.h:77:30: note: in expansion of macro ‘sym_rename1’
#define sym_rename(old, new) sym_rename1(old, __USER_LABEL_PREFIX__, new)
^
libgfortran/libgfortran.h:139:26: note: in expansion of macro ‘sym_rename’
# define export_proto(x) sym_rename(x, PREFIX(x))
^
libgfortran/libgfortran.h:141:27: note: in expansion of macro ‘export_proto’
# define iexport_proto(x) export_proto(x)
^
libgfortran/libgfortran.h:617:1: note: in expansion of macro ‘iexport_proto’
iexport_proto(random_seed);
^
In file included from libgfortran/runtime/compile_options.c:32:0:
libgfortran/libgfortran.h:621:8: error: unknown type name ‘GFC_REAL_4’
extern GFC_REAL_4 normalize_r4_i4 (GFC_UINTEGER_4, GFC_UINTEGER_4);
^
libgfortran/libgfortran.h:621:1: warning: parameter names (without types) in function declaration
extern GFC_REAL_4 normalize_r4_i4 (GFC_UINTEGER_4, GFC_UINTEGER_4);
^
libgfortran/libgfortran.h:624:8: error: unknown type name ‘GFC_REAL_8’
extern GFC_REAL_8 normalize_r8_i8 (GFC_UINTEGER_8, GFC_UINTEGER_8);
^
libgfortran/libgfortran.h:624:1: warning: parameter names (without types) in function declaration
extern GFC_REAL_8 normalize_r8_i8 (GFC_UINTEGER_8, GFC_UINTEGER_8);
^
libgfortran/runtime/compile_options.c:40:1: warning: parameter names (without types) in function declaration
extern void set_std (GFC_INTEGER_4, GFC_INTEGER_4, GFC_INTEGER_4);
^
libgfortran/runtime/compile_options.c:45:10: error: unknown type name ‘GFC_INTEGER_4’
set_std (GFC_INTEGER_4 warn_std, GFC_INTEGER_4 allow_std,
^
libgfortran/runtime/compile_options.c:45:34: error: unknown type name ‘GFC_INTEGER_4’
set_std (GFC_INTEGER_4 warn_std, GFC_INTEGER_4 allow_std,
^
libgfortran/runtime/compile_options.c:46:3: error: unknown type name ‘GFC_INTEGER_4’
GFC_INTEGER_4 pedantic)
^
libgfortran/runtime/compile_options.c: In function ‘set_record_marker’:
libgfortran/runtime/compile_options.c:89:19: error: ‘GFC_INTEGER_4’ undeclared (first use in this function)
if (sizeof (GFC_INTEGER_4) != sizeof (gfc_offset))
^
libgfortran/runtime/compile_options.c:89:19: note: each undeclared identifier is reported only once for each function it appears in
libgfortran/runtime/compile_options.c:94:19: error: ‘GFC_INTEGER_8’ undeclared (first use in this function)
if (sizeof (GFC_INTEGER_8) != sizeof (gfc_offset))
^
make[1]: *** [compile_options.lo] Error 1
make[1]: Leaving directory `C:/Users/jdoubleb/Documents/Academia/Cygwin_etal/gcc-4.1.1'
make: *** [all] Error 2
J Double B#jdoubleb-PC /gcc-4.1.1
*FROM LINUX*
[wexlerlab#AirWay~/Jeremiah/gcc-fortran-4.1.1/gcc-4.1.1 ]$ make
cat: libgfortran/../gcc/BASE-VER: No such file or directory
/bin/sh libgfortran/mk-sik-inc.sh 'gfortran -I . -Wall -fno-repack-arrays -fno-underscoring -g -O2' > selected_int_kind.inc || rm selected_int_kind.inc
/bin/sh libgfortran/mk-srk-inc.sh 'gfortran -I . -Wall -fno-repack-arrays -fno-underscoring -g -O2' > selected_real_kind.inc || rm selected_real_kind.inc
/bin/sh libgfortran/mk-kinds-h.sh 'gfortran -I . -Wall -fno-repack-arrays -fno-underscoring -g -O2' > kinds.h || rm kinds.h
grep '^#' < kinds.h > kinds.inc
grep '^#' < libgfortran/c99_protos.h > c99_protos.inc
cp libgfortran/config/fpu-glibc.h fpu-target.h
make all-am
cat: libgfortran/../gcc/BASE-VER: No such file or directory
make[1]: Entering directory `/home/wexlerlab/Jeremiah/gcc-fortran-4.1.1/gcc-4.1.1'
/bin/sh ./libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -Ilibgfortran -I. -iquotelibgfortran/io -Ilibgfortran/../gcc -Ilibgfortran/../gcc/config -I../.././gcc -D_GNU_SOURCE -std=gnu99 -Wall -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -Wextra -Wwrite-strings -c -o compile_options.lo `test -f 'runtime/compile_options.c' || echo 'libgfortran/'`runtime/compile_options.c
mkdir .libs
gcc -DHAVE_CONFIG_H -I. -Ilibgfortran -I. -iquotelibgfortran/io -Ilibgfortran/../gcc -Ilibgfortran/../gcc/config -I../.././gcc -D_GNU_SOURCE -std=gnu99 -Wall -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -Wextra -Wwrite-strings -c libgfortran/runtime/compile_options.c -fPIC -DPIC -o .libs/compile_options.o
gcc -DHAVE_CONFIG_H -I. -Ilibgfortran -I. -iquotelibgfortran/io -Ilibgfortran/../gcc -Ilibgfortran/../gcc/config -I../.././gcc -D_GNU_SOURCE -std=gnu99 -Wall -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -Wextra -Wwrite-strings -c libgfortran/runtime/compile_options.c -o compile_options.o >/dev/null 2>&1
/bin/sh ./libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -Ilibgfortran -I. -iquotelibgfortran/io -Ilibgfortran/../gcc -Ilibgfortran/../gcc/config -I../.././gcc -D_GNU_SOURCE -std=gnu99 -Wall -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -Wextra -Wwrite-strings -c -o environ.lo `test -f 'runtime/environ.c' || echo 'libgfortran/'`runtime/environ.c
gcc -DHAVE_CONFIG_H -I. -Ilibgfortran -I. -iquotelibgfortran/io -Ilibgfortran/../gcc -Ilibgfortran/../gcc/config -I../.././gcc -D_GNU_SOURCE -std=gnu99 -Wall -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -Wextra -Wwrite-strings -c libgfortran/runtime/environ.c -fPIC -DPIC -o .libs/environ.o
In file included from libgfortran/runtime/environ.c:37:
libgfortran/runtime/../io/io.h:36:18: error: gthr.h: No such file or directory
In file included from libgfortran/runtime/environ.c:37:
libgfortran/runtime/../io/io.h:504: error: expected specifier-qualifier-list before '__gthread_mutex_t'
libgfortran/runtime/../io/io.h:699: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'unit_lock'
libgfortran/runtime/../io/io.h:700: error: 'unit_lock' undeclared here (not in a function)
libgfortran/runtime/../io/io.h:700: warning: type defaults to 'int' in declaration of 'unit_lock'
libgfortran/runtime/../io/io.h: In function 'inc_waiting_locked':
libgfortran/runtime/../io/io.h:890: error: 'gfc_unit' has no member named 'waiting'
libgfortran/runtime/../io/io.h:890: error: incompatible type for argument 1 of '__sync_fetch_and_add'
libgfortran/runtime/../io/io.h: In function 'predec_waiting_locked':
libgfortran/runtime/../io/io.h:900: error: 'gfc_unit' has no member named 'waiting'
libgfortran/runtime/../io/io.h:900: error: incompatible type for argument 1 of '__sync_add_and_fetch'
libgfortran/runtime/../io/io.h:904: warning: control reaches end of non-void function
libgfortran/runtime/../io/io.h: In function 'dec_waiting_unlocked':
libgfortran/runtime/../io/io.h:910: error: 'gfc_unit' has no member named 'waiting'
libgfortran/runtime/../io/io.h:910: error: incompatible type for argument 1 of '__sync_fetch_and_add'
make[1]: *** [environ.lo] Error 1
make[1]: Leaving directory `/home/wexlerlab/Jeremiah/gcc-fortran-4.1.1/gcc-4.1.1'
make: *** [all] Error 2
[wexlerlab#AirWay~/Jeremiah/gcc-fortran-4.1.1/gcc-4.1.1 ]$ cd libgfortran/
[wexlerlab#AirWay~/Jeremiah/gcc-fortran-4.1.1/gcc-4.1.1/libgfortran ]$ automake
[wexlerlab#AirWay~/Jeremiah/gcc-fortran-4.1.1/gcc-4.1.1/libgfortran ]$ cd..
-bash: cd..: command not found
[wexlerlab#AirWay~/Jeremiah/gcc-fortran-4.1.1/gcc-4.1.1/libgfortran ]$ make
make: *** No targets specified and no makefile found. Stop.
[wexlerlab#AirWay~/Jeremiah/gcc-fortran-4.1.1/gcc-4.1.1/libgfortran ]$ cd ..
[wexlerlab#AirWay~/Jeremiah/gcc-fortran-4.1.1/gcc-4.1.1 ]$ make
cat: libgfortran/../gcc/BASE-VER: No such file or directory
cd . && /bin/sh ./config.status Makefile
config.status: creating Makefile
cat: libgfortran/../gcc/BASE-VER: No such file or directory
make all-am
cat: libgfortran/../gcc/BASE-VER: No such file or directory
make[1]: Entering directory `/home/wexlerlab/Jeremiah/gcc-fortran-4.1.1/gcc-4.1.1'
/bin/sh ./libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -Ilibgfortran -I. -iquotelibgfortran/io -Ilibgfortran/../gcc -Ilibgfortran/../gcc/config -I../.././gcc -D_GNU_SOURCE -std=gnu99 -Wall -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -Wextra -Wwrite-strings -c -o environ.lo `test -f 'runtime/environ.c' || echo 'libgfortran/'`runtime/environ.c
gcc -DHAVE_CONFIG_H -I. -Ilibgfortran -I. -iquotelibgfortran/io -Ilibgfortran/../gcc -Ilibgfortran/../gcc/config -I../.././gcc -D_GNU_SOURCE -std=gnu99 -Wall -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -Wextra -Wwrite-strings -c libgfortran/runtime/environ.c -fPIC -DPIC -o .libs/environ.o
In file included from libgfortran/runtime/environ.c:37:
libgfortran/runtime/../io/io.h:36:18: error: gthr.h: No such file or directory
In file included from libgfortran/runtime/environ.c:37:
libgfortran/runtime/../io/io.h:504: error: expected specifier-qualifier-list before '__gthread_mutex_t'
libgfortran/runtime/../io/io.h:699: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'unit_lock'
libgfortran/runtime/../io/io.h:700: error: 'unit_lock' undeclared here (not in a function)
libgfortran/runtime/../io/io.h:700: warning: type defaults to 'int' in declaration of 'unit_lock'
libgfortran/runtime/../io/io.h: In function 'inc_waiting_locked':
libgfortran/runtime/../io/io.h:890: error: 'gfc_unit' has no member named 'waiting'
libgfortran/runtime/../io/io.h:890: error: incompatible type for argument 1 of '__sync_fetch_and_add'
libgfortran/runtime/../io/io.h: In function 'predec_waiting_locked':
libgfortran/runtime/../io/io.h:900: error: 'gfc_unit' has no member named 'waiting'
libgfortran/runtime/../io/io.h:900: error: incompatible type for argument 1 of '__sync_add_and_fetch'
libgfortran/runtime/../io/io.h:904: warning: control reaches end of non-void function
libgfortran/runtime/../io/io.h: In function 'dec_waiting_unlocked':
libgfortran/runtime/../io/io.h:910: error: 'gfc_unit' has no member named 'waiting'
libgfortran/runtime/../io/io.h:910: error: incompatible type for argument 1 of '__sync_fetch_and_add'
make[1]: *** [environ.lo] Error 1
make[1]: Leaving directory `/home/wexlerlab/Jeremiah/gcc-fortran-4.1.1/gcc-4.1.1'
make: *** [all] Error 2
[wexlerlab#AirWay~/Jeremiah/gcc-fortran-4.1.1/gcc-4.1.1 ]$
I am compiling the C++ code using Android native library NDK but I am getting the following errors while trying to include the g729a.h file in g729_jni.cpp:
ERRORS:
Compile++ arm : g729_jni <= g729_jni.cpp
/usr/src/android-ndk-r8/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-g++ -MMD -MP -MF ./obj/local/armeabi/objs/g729_jni/g729_jni.o.d -fpic -ffunction-sections -funwind-tables -fstack-protector -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ -Wno-psabi -march=armv5te -mtune=xscale -msoft-float -fno-exceptions -fno-rtti -O2 -fomit-frame-pointer -fstrict-aliasing -funswitch-loops -finline-limit=300 -I/usr/src/android-ndk-r8/sources/cxx-stl/system/include -Ijni -DANDROID -O3 -Wa,--noexecstack -O2 -DNDEBUG -g -I/usr/src/android-ndk-r8/platforms/android-3/arch-arm/usr/include -c jni/g729_jni.cpp -o ./obj/local/armeabi/objs/g729_jni/g729_jni.o
In file included from jni/g729_jni.cpp:34:
jni/g729/g729a.h:70: error: 'UWord8' has not been declared
jni/g729/g729a.h:126: error: 'UWord8' has not been declared
jni/g729_jni.cpp: In function 'jint Java_org_sipdroid_codecs_G729_open(JNIEnv*, _jobject*)':
jni/g729_jni.cpp:72: error: 'UWord8' was not declared in this scope
jni/g729_jni.cpp: In function 'jint Java_org_sipdroid_codecs_G729_encode(JNIEnv*, _jobject*, _jshortArray*, jint, _jbyteArray*, jint)':
jni/g729_jni.cpp:111: error: 'UWord8' was not declared in this scope
jni/g729_jni.cpp:111: error: expected ';' before 'serial'
jni/g729_jni.cpp:125: error: 'serial' was not declared in this scope
jni/g729_jni.cpp: In function 'jint Java_org_sipdroid_codecs_G729_decode(JNIEnv*, _jobject*, _jbyteArray*, _jshortArray*, jint)':
jni/g729_jni.cpp:156: error: cannot convert 'unsigned char*' to 'int*' for argument '2' to 'void g729a_dec_process(void*, int*, Word16*, Flag)'
make: *** [obj/local/armeabi/objs/g729_jni/g729_jni.o] Error 1
I googled to try and find the reason behind this error. As C++ is case sensitive, if we make a mistake in upper and lower case, then this kind of error occurs. But I didn't make this kind of mistakes.
If you have any idea or suggestion then please guide me through that.
Thanks
UPDATE:
[root#localhost sipdroid-read-only]# /usr/src/android-ndk-r8/ndk-build V=1 APP_ABI=armeabi APP_PROJECT_PATH=. obj/local/armeabi/objs/g729_jni/g729_jni.o
make: `obj/local/armeabi/objs/g729_jni/g729_jni.o' is up to date.
Make sure your typedef.h is similar to http://siphon.googlecode.com/svn/trunk/g729a/Headers/typedef.h
Here are the steps I made to reproduce your problem:
svn checkout http://sipdroid.googlecode.com/svn/trunk/ sipdroid
cd sipdroid
sed "s/^SILK/include $(CLEAR_VARS)\\nSILK/" -i jni/Android.mk
(note that Android.mk needed a fix after line 89).
svn checkout http://siphon.googlecode.com/svn/trunk/ ../siphon
cp -d ../siphon/g729a/Headers/ jni/g729
wget http://pastie.org/pastes/4737332/download -O jni/g729/g729a.h
wget "http://sipdroid.googlecode.com/issues/attachment?aid=7963991223373796529&name=g729_jni.cpp&token=KHEZCoq6ZYSuV_VhsV8fC3uwsSs%3A1348058591979" -O jni/g729_jni.cpp
sed -e "s/g722_jni/g729_jni/" -i jni/Android.mk
ndk-build.cmd V=1 APP_ABI=armeabi APP_PROJECT_PATH=. obj/local/armeabi/objs/g729_jni/g729_jni.o
... and your file compiles with a small warning. What have you done differently?
I am trying to compile my code using libboost library, by putting #include <boost/python.hpp> in my C++ code. Could somebody please help me the right command to run this, especially to include and link the library. I'm pretty basic in this.
The command used(but not working):
g++ try.cpp -L /usr/lib/libboost_python.so -o try
EDIT:
The tested code:
#include <boost/python.hpp>
#include <iostream>
int main()
{
std::cout << "Yes, it works :-)" << std::endl;
return 0;
}
Error messages:
from try.cpp:1:
/usr/include/boost/python/enum.hpp:31: error: expected ‘;’ before ‘*’ token
/usr/include/boost/python/enum.hpp:32: error: expected ‘;’ before ‘(’ token
/usr/include/boost/python/enum.hpp:33: error: ‘PyObject’ has not been declared
/usr/include/boost/python/enum.hpp:52: error: expected constructor, destructor, or type conversion before ‘*’ token
/usr/include/boost/python/enum.hpp:67: error: ‘void* boost::python::enum_<T>::convertible_from_python’ is not a static member of ‘struct boost::python::enum_<T>’
/usr/include/boost/python/enum.hpp:67: error: template definition of non-template ‘ void* boost::python::enum_<T>::convertible_from_python’
/usr/include/boost/python/enum.hpp:67: error: ‘PyObject’ was not declared in this scope
/usr/include/boost/python/enum.hpp:67: error: ‘obj’ was not declared in this scope
/usr/include/boost/python/enum.hpp:80: error: variable or field ‘construct’ declared void
/usr/include/boost/python/enum.hpp:80: error: ‘PyObject’ was not declared in this scope
/usr/include/boost/python/enum.hpp:80: error: ‘obj’ was not declared in this scope
/usr/include/boost/python/enum.hpp:80: error: expected primary-expression before ‘*’ token
/usr/include/boost/python/enum.hpp:80: error: ‘data’ was not declared in this scope
Another thing is that when I compile g++ -Wall thread_one.cpp -o thread_one -lboost_thread, that works in order to use boost_thread library.
Try this:
g++ try.cpp -o try -lboost_python
It'd be good style to also add -W -Wall -Wextra -pedantic to your compiler invocation (so that your next SO question can be more specific :-)). Also, -O2 or -O3 for optimization is probably a very good idea, especially with Boost. Finally, splitting the building up into separate stages makes recompiling faster when you have multiple files:
g++ -c -o try.o try.cpp -W -Wall -Wextra -pedantic -O2
g++ -o try try.o -s -lboost_python
Finally, it is working. The command used is as below:
g++ -I/usr/include/python2.6 try.cpp -o try -lboost_python -lpython2.6
I have a big project with a bunch of .cc files that have mostly c code and some c++ code. I want to use a vector in this program since I need an unbounded data type that is simple to make 2d (in other words I don't want to use an array or a list).
The problem is that when I run my make after including the vector class I get errors that I didn't get before. The only line that makes any difference is #include <vector>. I did not write the make files (and there are about 4 or 5 of them) but to the best of my knowledge it is using the GNU compiler. I have no vector objects instantiated, already included using namespace std; and the error goes away when I comment out the include directive for vector. On another file in this project however I used the queue library and it didn't have any problem with it. The problem happens when I include it in a .h file, it has no problem with .cc files, but since I will need to instantiate a vector object in the .h file I don't have the commodity of only using .cc files for this. Can someone give me any help for this problem?
Here is the output copied pasted from bash for the part that leads up to the error:
g++ -g -Wall -m32 -Wshadow -I../bin -I../filesys -I../userprog -I../threads -I../machine
-DUSER_PROGRAM -DFILESYS_NEEDED -DFILESYS_STUB -DHOST_i386 -DCHANGED -c ../threads/main.cc
g++ -g -Wall -m32 -Wshadow -I../bin -I../filesys -I../userprog -I../threads -I../machine
-DUSER_PROGRAM -DFILESYS_NEEDED -DFILESYS_STUB -DHOST_i386 -DCHANGED -c ../threads
/scheduler.cc
g++ -g -Wall -m32 -Wshadow -I../bin -I../filesys -I../userprog -I../threads -I../machine
-DUSER_PROGRAM -DFILESYS_NEEDED -DFILESYS_STUB -DHOST_i386 -DCHANGED -c ../threads/synch.cc
g++ -g -Wall -m32 -Wshadow -I../bin -I../filesys -I../userprog -I../threads -I../machine
-DUSER_PROGRAM -DFILESYS_NEEDED -DFILESYS_STUB -DHOST_i386 -DCHANGED -c ../threads
/system.cc
g++ -g -Wall -m32 -Wshadow -I../bin -I../filesys -I../userprog -I../threads -I../machine
-DUSER_PROGRAM -DFILESYS_NEEDED -DFILESYS_STUB -DHOST_i386 -DCHANGED -c ../threads
/thread.cc
g++ -g -Wall -m32 -Wshadow -I../bin -I../filesys -I../userprog -I../threads -I../machine
-DUSER_PROGRAM -DFILESYS_NEEDED -DFILESYS_STUB -DHOST_i386 -DCHANGED -c ../threads
/threadtest.cc
g++ -g -Wall -m32 -Wshadow -I../bin -I../filesys -I../userprog -I../threads -I../machine
-DUSER_PROGRAM -DFILESYS_NEEDED -DFILESYS_STUB -DHOST_i386 -DCHANGED -c ../machine
/interrupt.cc
g++ -g -Wall -m32 -Wshadow -I../bin -I../filesys -I../userprog -I../threads -I../machine
-DUSER_PROGRAM -DFILESYS_NEEDED -DFILESYS_STUB -DHOST_i386 -DCHANGED -c ../machine
/sysdep.cc
In file included from /usr/include/c++/4.4/vector:61,
from ../threads/system.h:19,
from ../machine/sysdep.cc:77:
/usr/include/c++/4.4/bits/stl_algobase.h:232:56: error: macro "min" passed 3 arguments,
but takes just 2
/usr/include/c++/4.4/bits/stl_algobase.h:253:56: error: macro "max" passed 3 arguments,
but takes just 2
In file included from /usr/include/c++/4.4/vector:61,
from ../threads/system.h:19,
from ../machine/sysdep.cc:77:
/usr/include/c++/4.4/bits/stl_algobase.h:186: error: expected unqualified-id before ‘const’
/usr/include/c++/4.4/bits/stl_algobase.h:186: error: expected ‘)’ before ‘const’
/usr/include/c++/4.4/bits/stl_algobase.h:186: error: expected ‘)’ before ‘const’
/usr/include/c++/4.4/bits/stl_algobase.h:186: error: expected ‘)’ before ‘const’
/usr/include/c++/4.4/bits/stl_algobase.h:186: error: expected initializer before ‘const’
/usr/include/c++/4.4/bits/stl_algobase.h:209: error: expected unqualified-id before ‘const’
/usr/include/c++/4.4/bits/stl_algobase.h:209: error: expected ‘)’ before ‘const’
/usr/include/c++/4.4/bits/stl_algobase.h:209: error: expected ‘)’ before ‘const’
/usr/include/c++/4.4/bits/stl_algobase.h:209: error: expected ‘)’ before ‘const’
/usr/include/c++/4.4/bits/stl_algobase.h:209: error: expected initializer before ‘const’
/usr/include/c++/4.4/bits/stl_algobase.h:232: error: ‘std::min’ declared as an ‘inline’
variable
/usr/include/c++/4.4/bits/stl_algobase.h:232: error: template declaration of ‘const _Tp&
std::min’
/usr/include/c++/4.4/bits/stl_algobase.h:235: error: expected primary-expression before
‘if’
/usr/include/c++/4.4/bits/stl_algobase.h:235: error: expected ‘}’ before ‘if’
/usr/include/c++/4.4/bits/stl_algobase.h:237: error: expected unqualified-id before
‘return’
/usr/include/c++/4.4/bits/stl_algobase.h:253: error: ‘max’ declared as an ‘inline’ variable
/usr/include/c++/4.4/bits/stl_algobase.h:253: error: template declaration of ‘const _Tp&
max’
/usr/include/c++/4.4/bits/stl_algobase.h:256: error: expected primary-expression before
‘if’
/usr/include/c++/4.4/bits/stl_algobase.h:256: error: expected ‘}’ before ‘if’
/usr/include/c++/4.4/bits/stl_algobase.h:258: error: expected unqualified-id before
‘return’
/usr/include/c++/4.4/bits/stl_algobase.h:259: error: expected declaration before ‘}’ token
make[1]: *** [sysdep.o] Error 1
make[1]: Leaving directory `/home/f85/njvanbal/workspace/nachos2/userprog'
make: *** [all] Error 2
Always best to look back to the first error first; in your case:
/usr/include/c++/4.4/bits/stl_algobase.h:232:56: error: macro "min" passed 3 arguments,
but takes just 2
/usr/include/c++/4.4/bits/stl_algobase.h:253:56: error: macro "max" passed 3 arguments,
but takes just 2
Looks like you have defined a macro (or maybe a function) called min and max in your own code. The #include for vector apparently also defines a macro for min and max and the compiler is getting confused. Change the name of your min and max macros.