How do I build a .so file in f2py without errors? - fortran
I am trying to build an extension module for the following FORTRAN module:
module mod
integer i
integer :: x(4)
real, dimension(2,3) :: a
real, allocatable, dimension(:,:) :: b
contains
subroutine foo
integer k
print*, "i=",i
print*, "x=[",x,"]"
print*, "a=["
print*, "[",a(1,1),",",a(1,2),",",a(1,3),"]"
print*, "[",a(2,1),",",a(2,2),",",a(2,3),"]"
print*, "]"
print*, "Setting a(1,2)=a(1,2)+3"
a(1,2) = a(1,2)+3
end subroutine foo
end module mod
I ran the following in Windows Powershell:
f2py -c -m moddata moddata.f90
But I got the following output, with many errors:
call "C:\Anaconda2\Scripts\\..\python.exe" "C:\Anaconda2\Scripts\\f2py.py" -c -m moddata moddata.f90
running build
running config_cc
unifing config_cc, config, build_clib, build_ext, build commands --compiler options
running config_fc
unifing config_fc, config, build_clib, build_ext, build commands --fcompiler options
running build_src
build_src
building extension "moddata" sources
f2py options: []
f2py:> c:\users\brian\appdata\local\temp\tmpokkt7l\src.win-amd64-2.7\moddatamodule.c
creating c:\users\brian\appdata\local\temp\tmpokkt7l\src.win-amd64-2.7
Reading fortran codes...
Reading file 'moddata.f90' (format:free)
Post-processing...
Block: moddata
Block: mod
Block: foo
Post-processing (stage 2)...
Block: moddata
Block: unknown_interface
Block: mod
Block: foo
Building modules...
Building module "moddata"...
Constructing F90 module support for "mod"...
Variables: i x b a
getarrdims:warning: assumed shape array, using 0 instead of ':'
getarrdims:warning: assumed shape array, using 0 instead of ':'
Constructing wrapper function "mod.foo"...
foo()
Wrote C/API module "moddata" to file "c:\users\brian\appdata\local\temp\tmpokkt7l\src.win-amd64-2.7\moddatamodule.c"
Fortran 90 wrappers are saved to "c:\users\brian\appdata\local\temp\tmpokkt7l\src.win-amd64-2.7\moddata-f2pywrappers2.f90"
adding 'c:\users\brian\appdata\local\temp\tmpokkt7l\src.win-amd64-2.7\fortranobject.c' to sources.
adding 'c:\users\brian\appdata\local\temp\tmpokkt7l\src.win-amd64-2.7' to include_dirs.
copying C:\Anaconda2\lib\site-packages\numpy\f2py\src\fortranobject.c -> c:\users\brian\appdata\local\temp\tmpokkt7l\src.win-amd64-2.7
copying C:\Anaconda2\lib\site-packages\numpy\f2py\src\fortranobject.h -> c:\users\brian\appdata\local\temp\tmpokkt7l\src.win-amd64-2.7
adding 'c:\users\brian\appdata\local\temp\tmpokkt7l\src.win-amd64-2.7\moddata-f2pywrappers2.f90' to sources.
build_src: building npy-pkg config files
running build_ext
Cannot build msvcr library: "msvcr90d.dll" not found
customize Mingw32CCompiler
customize Mingw32CCompiler using build_ext
customize GnuFCompiler
Could not locate executable g77
Could not locate executable f77
customize IntelVisualFCompiler
Could not locate executable ifort
Could not locate executable ifl
customize AbsoftFCompiler
Could not locate executable f90
customize CompaqVisualFCompiler
Found executable C:\cygwin64\bin\DF.exe
customize IntelItaniumVisualFCompiler
Could not locate executable efl
customize Gnu95FCompiler
Found executable C:\cygwin64\bin\gfortran.exe
customize Gnu95FCompiler
customize Gnu95FCompiler using build_ext
building 'moddata' extension
compiling C sources
C compiler: gcc -g -DDEBUG -DMS_WIN64 -O0 -Wall -Wstrict-prototypes
creating c:\users\brian\appdata\local\temp\tmpokkt7l\Release
creating c:\users\brian\appdata\local\temp\tmpokkt7l\Release\users
creating c:\users\brian\appdata\local\temp\tmpokkt7l\Release\users\brian
creating c:\users\brian\appdata\local\temp\tmpokkt7l\Release\users\brian\appdata
creating c:\users\brian\appdata\local\temp\tmpokkt7l\Release\users\brian\appdata\local
creating c:\users\brian\appdata\local\temp\tmpokkt7l\Release\users\brian\appdata\local\temp
creating c:\users\brian\appdata\local\temp\tmpokkt7l\Release\users\brian\appdata\local\temp\tmpokkt7l
creating c:\users\brian\appdata\local\temp\tmpokkt7l\Release\users\brian\appdata\local\temp\tmpokkt7l\src.win-amd64-2.7
compile options: '-DNPY_MINGW_USE_CUSTOM_MSVCR -D__MSVCRT_VERSION__=0x1500 -Ic:\users\brian\appdata\local\temp\tmpokkt7l\src.win-amd64-2.7 -IC:\Anaconda2\lib\site-packages\numpy\core\include -IC:\Anaconda2\include -IC:\Anaconda2\PC -c'
gcc -g -DDEBUG -DMS_WIN64 -O0 -Wall -Wstrict-prototypes -DNPY_MINGW_USE_CUSTOM_MSVCR -D__MSVCRT_VERSION__=0x1500 -Ic:\users\brian\appdata\local\temp\tmpokkt7l\src.win-amd64-2.7 -IC:\Anaconda2\lib\site-packages\numpy\core\include -IC:\Anaconda2\include -IC:\Anaconda2\PC -c c:\users\brian\appdata\local\temp\tmpokkt7l\src.win-amd64-2.7\moddatamodule.c -o c:\users\brian\appdata\local\temp\tmpokkt7l\Release\users\brian\appdata\local\temp\tmpokkt7l\src.win-amd64-2.7\moddatamodule.o
In file included from C:\Anaconda2\include/Python.h:58:0,
from c:\users\brian\appdata\local\temp\tmpokkt7l\src.win-amd64-2.7\moddatamodule.c:17:
C:\Anaconda2\include/pyport.h:171:33: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'Py_uintptr_t'
typedef unsigned PY_LONG_LONG Py_uintptr_t;
^~~~~~~~~~~~
In file included from C:\Anaconda2\include/Python.h:8:0,
from c:\users\brian\appdata\local\temp\tmpokkt7l\src.win-amd64-2.7\moddatamodule.c:17:
C:\Anaconda2\include/pyconfig.h:314:23: error: unknown type name '__int64'
# define PY_LONG_LONG __int64
^
C:\Anaconda2\include/pyport.h:172:9: note: in expansion of macro 'PY_LONG_LONG'
typedef PY_LONG_LONG Py_intptr_t;
^~~~~~~~~~~~
In file included from C:\Anaconda2\include/Python.h:58:0,
from c:\users\brian\appdata\local\temp\tmpokkt7l\src.win-amd64-2.7\moddatamodule.c:17:
C:\Anaconda2\include/pyport.h:895:2: error: #error "LONG_BIT definition appears wrong for platform (bad gcc/glibc config?)."
#error "LONG_BIT definition appears wrong for platform (bad gcc/glibc config?)."
^~~~~
In file included from C:\Anaconda2\include/Python.h:86:0,
from c:\users\brian\appdata\local\temp\tmpokkt7l\src.win-amd64-2.7\moddatamodule.c:17:
C:\Anaconda2\include/intobject.h:46:35: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'PyInt_AsUnsignedLongLongMask'
PyAPI_FUNC(unsigned PY_LONG_LONG) PyInt_AsUnsignedLongLongMask(PyObject *);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from C:\Anaconda2\include/Python.h:88:0,
from c:\users\brian\appdata\local\temp\tmpokkt7l\src.win-amd64-2.7\moddatamodule.c:17:
C:\Anaconda2\include/longobject.h:50:1: warning: parameter names (without types) in function declaration
PyAPI_FUNC(PyObject *) PyLong_FromLongLong(PY_LONG_LONG);
^~~~~~~~~~
In file included from C:\Anaconda2\include/Python.h:58:0,
from c:\users\brian\appdata\local\temp\tmpokkt7l\src.win-amd64-2.7\moddatamodule.c:17:
C:\Anaconda2\include/pyconfig.h:314:23: error: unknown type name '__int64'
# define PY_LONG_LONG __int64
^
C:\Anaconda2\include/pyport.h:802:34: note: in definition of macro 'PyAPI_FUNC'
# define PyAPI_FUNC(RTYPE) RTYPE
^~~~~
C:\Anaconda2\include/longobject.h:52:12: note: in expansion of macro 'PY_LONG_LONG'
PyAPI_FUNC(PY_LONG_LONG) PyLong_AsLongLong(PyObject *);
^~~~~~~~~~~~
In file included from C:\Anaconda2\include/Python.h:88:0,
from c:\users\brian\appdata\local\temp\tmpokkt7l\src.win-amd64-2.7\moddatamodule.c:17:
C:\Anaconda2\include/longobject.h:53:35: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'PyLong_AsUnsignedLongLong'
PyAPI_FUNC(unsigned PY_LONG_LONG) PyLong_AsUnsignedLongLong(PyObject *);
^~~~~~~~~~~~~~~~~~~~~~~~~
C:\Anaconda2\include/longobject.h:54:35: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'PyLong_AsUnsignedLongLongMask'
PyAPI_FUNC(unsigned PY_LONG_LONG) PyLong_AsUnsignedLongLongMask(PyObject *);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from C:\Anaconda2\include/Python.h:58:0,
from c:\users\brian\appdata\local\temp\tmpokkt7l\src.win-amd64-2.7\moddatamodule.c:17:
C:\Anaconda2\include/pyconfig.h:314:23: error: unknown type name '__int64'
# define PY_LONG_LONG __int64
^
C:\Anaconda2\include/pyport.h:802:34: note: in definition of macro 'PyAPI_FUNC'
# define PyAPI_FUNC(RTYPE) RTYPE
^~~~~
C:\Anaconda2\include/longobject.h:55:12: note: in expansion of macro 'PY_LONG_LONG'
PyAPI_FUNC(PY_LONG_LONG) PyLong_AsLongLongAndOverflow(PyObject *, int *);
^~~~~~~~~~~~
In file included from C:\Anaconda2\lib\site-packages\numpy\core\include/numpy/ndarraytypes.h:4:0,
from C:\Anaconda2\lib\site-packages\numpy\core\include/numpy/ndarrayobject.h:18,
from C:\Anaconda2\lib\site-packages\numpy\core\include/numpy/arrayobject.h:4,
from c:\users\brian\appdata\local\temp\tmpokkt7l\src.win-amd64-2.7\fortranobject.h:13,
from c:\users\brian\appdata\local\temp\tmpokkt7l\src.win-amd64-2.7\moddatamodule.c:18:
C:\Anaconda2\lib\site-packages\numpy\core\include/numpy/npy_common.h:221:9: error: unknown type name 'Py_uintptr_t'
typedef Py_uintptr_t npy_uintp;
^~~~~~~~~~~~
In file included from C:\Anaconda2\include/Python.h:8:0,
from c:\users\brian\appdata\local\temp\tmpokkt7l\src.win-amd64-2.7\moddatamodule.c:17:
C:\Anaconda2\include/pyconfig.h:314:23: error: unknown type name '__int64'
# define PY_LONG_LONG __int64
^
C:\Anaconda2\lib\site-packages\numpy\core\include/numpy/npy_common.h:311:9: note: in expansion of macro 'PY_LONG_LONG'
typedef PY_LONG_LONG npy_longlong;
^~~~~~~~~~~~
In file included from C:\Anaconda2\lib\site-packages\numpy\core\include/numpy/ndarraytypes.h:4:0,
from C:\Anaconda2\lib\site-packages\numpy\core\include/numpy/ndarrayobject.h:18,
from C:\Anaconda2\lib\site-packages\numpy\core\include/numpy/arrayobject.h:4,
from c:\users\brian\appdata\local\temp\tmpokkt7l\src.win-amd64-2.7\fortranobject.h:13,
from c:\users\brian\appdata\local\temp\tmpokkt7l\src.win-amd64-2.7\moddatamodule.c:18:
C:\Anaconda2\lib\site-packages\numpy\core\include/numpy/npy_common.h:312:31: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'npy_ulonglong'
typedef unsigned PY_LONG_LONG npy_ulonglong;
^~~~~~~~~~~~~
In file included from C:\Anaconda2\lib\site-packages\numpy\core\include/numpy/ndarraytypes.h:4:0,
from C:\Anaconda2\lib\site-packages\numpy\core\include/numpy/ndarrayobject.h:18,
from C:\Anaconda2\lib\site-packages\numpy\core\include/numpy/arrayobject.h:4,
from c:\users\brian\appdata\local\temp\tmpokkt7l\src.win-amd64-2.7\fortranobject.h:13,
from c:\users\brian\appdata\local\temp\tmpokkt7l\src.win-amd64-2.7\moddatamodule.c:18:
C:\Anaconda2\lib\site-packages\numpy\core\include/numpy/npy_common.h:614:17: error: unknown type name 'npy_ulonglong'
typedef npy_ulonglong npy_uint64;
^~~~~~~~~~~~~
In file included from C:\Anaconda2\lib\site-packages\numpy\core\include/numpy/ndarraytypes.h:1809:0,
from C:\Anaconda2\lib\site-packages\numpy\core\include/numpy/ndarrayobject.h:18,
from C:\Anaconda2\lib\site-packages\numpy\core\include/numpy/arrayobject.h:4,
from c:\users\brian\appdata\local\temp\tmpokkt7l\src.win-amd64-2.7\fortranobject.h:13,
from c:\users\brian\appdata\local\temp\tmpokkt7l\src.win-amd64-2.7\moddatamodule.c:18:
C:\Anaconda2\lib\site-packages\numpy\core\include/numpy/npy_1_7_deprecated_api.h:15:2: warning: #warning "Using deprecated NumPy API, disable it by " "#defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]
#warning "Using deprecated NumPy API, disable it by " \
^~~~~~~
error: Command "gcc -g -DDEBUG -DMS_WIN64 -O0 -Wall -Wstrict-prototypes -DNPY_MINGW_USE_CUSTOM_MSVCR -D__MSVCRT_VERSION__=0x1500 -Ic:\users\brian\appdata\local\temp\tmpokkt7l\src.win-amd64-2.7 -IC:\Anaconda2\lib\site-packages\numpy\core\include -IC:\Anaconda2\include -IC:\Anaconda2\PC -c c:\users\brian\appdata\local\temp\tmpokkt7l\src.win-amd64-2.7\moddatamodule.c -o c:\users\brian\appdata\local\temp\tmpokkt7l\Release\users\brian\appdata\local\temp\tmpokkt7l\src.win-amd64-2.7\moddatamodule.o" failed with exit status 1
My FORTRAN compiler is GNU Fortran (GCC) 6.4.0.
My C compiler is gcc (GCC) 6.4.0.
I am using Numpy V1.13.3.
I am using f2py V2.
Could you let me know how to resolve the errors?
Thank you!
Related
after compiling gcc 5.4.0 what header folders to export
I have compiled gcc 5.4.0 (make, make install into non root folder) and have exported it to anther machine of the same base distro. however when I try to compile a hello world on the 2nd machine I get an error for stdio.h and that cascades to cstdio etc. for gcc I used configure --prefix=/home/mybin --bindir=/home/mybin/bin --libdir=/home/mybin/lib etc for all available folders as per --help. On the gcc compile machine it seems the source folder /home/tmp/gcc-5.4.0/libstdc++-v3/include was installed into the --includedir=/home/mybin/include folder with all the sub directories. Searching for stdio.h on the 5.4.0 compiling machine I get several folders that contain a version of stdio.h. /home/tmp/gcc-5.4.0/libstdc++-v3/include/tr1/stdio.h /home/tmp/gcc-5.4.0/libstdc++-v3/include/c_compatibility/stdio.h /home/tmp/gcc-5.4.0/fixincludes/tests/base/rtldef/stdio.h /home/tmp/gcc-5.4.0/fixincludes/tests/base/stdio.h /home/tmp/gcc-5.4.0/libssp/ssp/stdio.h /home/tmp/gcc-5.4.0/gcc/testsuite/gcc.dg/cpp/usr/include/stdio.h and the search of the --prefix=/home/mybin/ returns /home/mybin/lib/gcc/x86_64-unknown-linux-gnu/5.4.0/include/ssp/stdio.h /home/mybin/include/c++/5.4.0/tr1/stdio.h /home/mybin/include/c_compatibility/stdio.h So I copied the ``--prefix=/home/mybin/` folder to the new machine and tried to use gcc -Wall -I/home/mybin/include/c_compatibility /home/myuser/test.c -o /home/myuser/hello this gives In file included from /home/myuser/test.c:3:0: /home/mybin/include/c_compatibility/stdio.h:29:18: fatal error: cstdio: No such file or directory BUT I do have /home/mybin/include/c++/5.4.0/tr1/cstdio /home/mybin/include/c++/5.4.0/cstdio /home/mybin/include/c_std/cstdio /home/mybin/include/c/cstdio so updated to gcc -Wall -I/home/mybin/include/c_compatibility -I/home/mybin/include/c_std /home/myuser/test.c -o /home/myuser/hello In file included from /home/mybin/include/bits/c++config.h:482:0, from /home/mybin/include/c_std/cstdio:44, from /home/mybin/include/c_compatibility/stdio.h:29, from /home/myuser/test.c:3: /home/mybin/include/bits/os_defines.h:39:22: fatal error: features.h: No such file or directory compilation terminated. BUT I do have /home/mybin/include/c++/5.4.0/parallel/features.h gcc -Wall -I/home/mybin/include/c_compatibility -I/home/mybin/include/c_std /home/myuser/test.c -o /home/myuser/hello In file included from /home/mybin/include/bits/c++config.h:482:0, from /home/mybin/include/c_std/cstdio:44, from /home/mybin/include/c_compatibility/stdio.h:29, from /home/myuser/test.c:3: /home/mybin/include/bits/os_defines.h:39:22: fatal error: features.h: No such file or directory compilation terminated. gcc -Wall -I/home/mybin/include/c_compatibility -I/home/mybin/include/c_std -I/home/mybin/include/c++/5.4.0/parallel /home/myuser/test.c -o /home/myuser/hello In file included from /home/mybin/include/bits/c++config.h:482:0, from /home/mybin/include/c_std/cstdio:44, from /home/mybin/include/c_compatibility/stdio.h:29, from /home/myuser/_test.c:3: /home/mybin/include/bits/os_defines.h:44:19: error: missing binary operator before token "(" #if __GLIBC_PREREQ(2,15) && defined(_GNU_SOURCE) ^ In file included from /home/mybin/include/c_compatibility/stdio.h:29:0, from /home/myuser/_test.c:3: /home/mybin/include/c_std/cstdio:96:1: error: unknown type name 'namespace' namespace std ^ /home/mybin/include/c_std/cstdio:97:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token { ^ /home/mybin/include/c_std/cstdio:155:1: error: unknown type name 'namespace' namespace __gnu_cxx ^ /home/mybin/include/c_std/cstdio:156:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token { ^ /home/mybin/include/c_std/cstdio:181:1: error: unknown type name 'namespace' namespace std ^ /home/mybin/include/c_std/cstdio:182:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token { ^ /home/myuser/_test.c:7:1: warning: return type defaults to 'int' [-Wimplicit-int] main() ^ /home/myuser/test.c: In function 'main': /home/myuser/test.c:9:5: warning: implicit declaration of function 'printf' [-Wimplicit-function-declaration] printf("Heh now"); ^ /home/myuser/_test.c:9:5: warning: incompatible implicit declaration of built-in function 'printf' /home/myuser/_test.c:9:5: note: include '<stdio.h>' or provide a declaration of 'printf' I have tried exporting LD config flags as well How do I know what folder to export and to other machines made from the same base image so I can compile with this version. Why are the includes not being found or getting confused? I am using centos7
Error including Boost Threading Library
I have a rather large codebase that includes libSVM and lp_solve libraries. I recently added the Boost Threading library to the code and I continue to get a compilation error that I can't seem to solve. First, I added the include statement for the threading library: #include <boost/thread.hpp> Second, I adjusted the makefile for compilation. The command used to compile the relevant file is: g++ -I./ -I../Eigen -I../Classification -I../Components -I../include -I../Individuals -I../Pruning -I../Pruning/AIS -I../Pruning/ACO -I../Pruning/GA -I../Pruning/PSO -I../Pruning/CFO -I../Random -I../Samplers -O2 -g -Wall -c -fmessage-length=0 -fopenmp -llpsolve55 -lsvm -lboost_thread -lboost_system -MMD -MP -MF"Samplers/OMPP_Sampler.d" -MT"Samplers/OMPP_Sampler.d" -o "Samplers/OMPP_Sampler.o" "../Samplers/OMPP_Sampler.cpp" The generated error is: In file included from /usr/local/include/boost/thread.hpp:24, from ../Samplers/OMPP_Sampler.cpp:15: /usr/local/include/boost/thread/future.hpp: In constructor ‘boost::packaged_task<R>::packaged_task(R (*)())’: /usr/local/include/boost/thread/future.hpp:3214: error: expected unqualified-id before numeric constant /usr/local/include/boost/thread/future.hpp:3214: error: expected ‘)’ before numeric constant /usr/local/include/boost/thread/future.hpp:3215: error: type/value mismatch at argument 1 in template parameter list for ‘template<class F, class R> struct boost::detail::task_shared_state’ /usr/local/include/boost/thread/future.hpp:3215: error: expected a type, got ‘0’ /usr/local/include/boost/thread/future.hpp:3215: error: invalid type in declaration before ‘;’ token I have dug through the Boost headers, tried to identify any re-definitions from my own code, etc. The Boost code causing the issue is as follows: explicit packaged_task(R(*f)()) { typedef R(*FR)(); typedef detail::task_shared_state<FR,R> task_shared_state_type; task= task_ptr(new task_shared_state_type(f)); future_obtained=false; } Thoughts on how I can resolve this issue?
qt #include <vector> error
I am trying to use std::vector in qt, but I seem to get some errors, When ever I include the vector header and compile the below code, I get a big list of errors but when I remove the vector header and compile the same code it works fine. #include <iostream> #include <vector> using namespace std; int main () { std::cout<<"Vector"<<std::endl; return 0; } Since there were lot of errors I decided to put them into a file and provide the link below. http://goo.gl/XOj0nV The beginning and the end of the build log: 12:03:19: Running steps for project vector... 12:03:19: Configuration unchanged, skipping qmake step. 12:03:19: Starting: "/usr/bin/make" g++ -c -pipe -g -Wall -W -fPIE -I../../Qt/5.3/gcc/mkspecs/linux-g++ -I../vector -I. -o main.o ../vector/ main.cpp In file included from ../vector/main.cpp:2:0: ./vector:1:1: error: stray '\177' in program ./vector:1:1: error: stray '\1' in program ./vector:1:1: error: stray '\1' in program ./vector:1:1: error: stray '\1' in program ./vector:1:8: warning: null character(s) ignored [enabled by default] ./vector:1:1: error: stray '\2' in program ./vector:1:18: warning: null character(s) ignored [enabled by default] ./vector:1:1: error: stray '\3' in program ./vector:1:20: warning: null character(s) ignored [enabled by default] ./vector:1:1: error: stray '\1' in program ./vector:1:22: warning: null character(s) ignored [enabled by default] ./vector:1:1: error: stray '\205' in program ./vector:1:1: error: stray '\4' in program ./vector:1:1: error: stray '\10' in program ./vector:1:30: warning: null character(s) ignored [enabled by default] [...] ./vector:115:880: warning: null character(s) ignored [enabled by default] ./vector:115:886: warning: null character(s) ignored [enabled by default] In file included from ../vector/main.cpp:2:0: File: /home/sanjayan/Documents/qt_vector_errors Page 76 of 76 ./vector:1:2: error: 'ELF' does not name a type In file included from ../vector/main.cpp:2:0: ./vector:28:655: error: 'j' does not name a type In file included from ../vector/main.cpp:2:0: ./vector:61:28: error: expected declaration before '}' token make: *** [main.o] Error 1 12:03:22: The process "/usr/bin/make" exited with code 2. Error while building/deploying project vector (kit: Desktop Qt 5.3 GCC 32bit) When executing step 'Make' 12:03:22: Elapsed time: 00:03. I hope the provided information's is sufficient for my query.
I had the same problem like you just now. I write a C++ program named vector.cc #include <iostream> #include <vector> using namespace std; int main() { cout << "hello" << endl; return 0; } Compilation can pass for the first time (use g++ vector.cc -o vector, creates an executable file named vector), and then any program include the sentence #include vector will face the problems as you said. The basic reason is the vector file, if the executable file (named "vector") is deleted, everything will be OK. I hope my answer can help you.
If that problem arises not on every host then probably difference in the compiler. Difference is likely in the header files directory scan order. Such error should not arise if standard headers directory scanned before others. As a workaround its enough to remove project target file manually befor building target. But this is not a programmers way (which are very lazy creatures). Programmers way - is to learn QMake to delete target file just before project sources compilations (but under this way link phase will be done permanently). For me (QMake 2.01a under Linux) this is achived by addition of following lines into project file: deltarget.commands = $$QMAKE_DEL_FILE $$TARGET QMAKE_EXTRA_TARGETS += deltarget PRE_TARGETDEPS += deltarget This declares target deltarget which becomes built before current project. This sample uses undeclared in QMake's manual variable QMAKE_DEL_FILE which used to remove files (its content of course platfrom-dependent).
Does not name a type_in make prossess
I've been trying to compile some codes in windows but I got this error: 'flann_index_t' does not name a type' where is this error come from? Can any one help me to fix this? g++ -I. -Iflann/src/cpp -c -o src/main.o src/main.cpp In file included from ./boost/asio/async_result.hpp:18, from ./boost/asio.hpp:20, from src/common.hpp:30, from src/main.cpp:9: ./boost/asio/detail/config.hpp:367:5: warning: #warning Please define _WIN32_WIN NT or _WIN32_WINDOWS appropriately. ./boost/asio/detail/config.hpp:368:5: warning: #warning For example, add -D_WIN3 2_WINNT=0x0501 to the compiler command line. ./boost/asio/detail/config.hpp:369:5: warning: #warning Assuming _WIN32_WINNT=0x 0501 (i.e. Windows XP target). In file included from src/common.hpp:50, from src/main.cpp:9: src/CBIR.hpp:32: error: 'flann_index_t' does not name a type ./flann/util/matrix.h: In function 'int cbir::main(int, char**)': ./flann/util/matrix.h:75: error: 'flann::uchar* flann::Matrix_::data' is protected src/main.cpp:39: error: within this context Makefile:43: recipe for target `src/main.o' failed make: *** [src/main.o] Error 1
Assuming you are using flann, then you need: #include <flann.h> in CBIR.hpp.
C++ SSE3 instruction set not enabled
I'm trying to work up some hidden markov code in c++ using the HMMlib library from http://www.cs.au.dk/~asand/?page_id=152 I am using an ubuntu 12.04, with gcc / g++ 4.6 My compile step instruction is: g++ -I/usr/local/boost_1_52_0 -I../ MAIN.cpp This produces the following error: In file included from ../HMMlib/allocator_traits.hpp:25:0, from ../HMMlib/hmm_table.hpp:25, from MAIN.cpp:1: /usr/lib/gcc/i686-linux-gnu/4.6/include/pmmintrin.h:32:3: error: #error "SSE3 instruction set not enabled" In file included from ../HMMlib/hmm_table.hpp:25:0, from MAIN.cpp:1: ../HMMlib/allocator_traits.hpp:50:33: error: ‘__m128d’ was not declared in this scope ../HMMlib/allocator_traits.hpp:50:40: error: template argument 2 is invalid ../HMMlib/allocator_traits.hpp:77:32: error: ‘__m128’ was not declared in this scope ../HMMlib/allocator_traits.hpp:77:38: error: template argument 2 is invalid In file included from ../HMMlib/hmm_table.hpp:26:0, from MAIN.cpp:1: ../HMMlib/operator_traits.hpp:112:32: error: ‘__m128d’ was not declared in this scope ../HMMlib/operator_traits.hpp:112:39: error: template argument 2 is invalid ../HMMlib/operator_traits.hpp:205:31: error: ‘__m128’ was not declared in this scope ../HMMlib/operator_traits.hpp:205:37: error: template argument 2 is invalid In file included from ../HMMlib/hmm_table.hpp:27:0, from MAIN.cpp:1: ../HMMlib/float_traits.hpp:37:13: error: ‘__m128’ does not name a type ../HMMlib/float_traits.hpp:43:13: error: ‘__m128d’ does not name a type In file included from ../HMMlib/hmm.hpp:34:0, from MAIN.cpp:3: ../HMMlib/sse_operator_traits.hpp:63:35: error: ‘__m128’ was not declared in this scope ../HMMlib/sse_operator_traits.hpp:63:41: error: template argument 2 is invalid ../HMMlib/sse_operator_traits.hpp:95:36: error: ‘__m128d’ was not declared in this scope ../HMMlib/sse_operator_traits.hpp:95:43: error: template argument 2 is invalid I have absolutely no idea what these errors mean, and how to resolve them
You have to enable the sse3 intrinsics of gcc with a command line option. Try compiling with g++ -msse3 -I/usr/local/boost_1_52_0 -I../ MAIN.cpp or selecting instruction set by processor g++ -march=core2 -I/usr/local/boost_1_52_0 -I../ MAIN.cpp Reply to your comment: -march=native selects the instruction set of the processor you are currently running. Note that -msse3 already selects its subsets -msse2 and -msse