F2PY gives unresolved externals error with PRINT - gcc

I have some FORTRAN code that I want to compile with F2PY. The code is as follows:
C FILE: FTYPE.F
SUBROUTINE FOO(N)
INTEGER N
Cf2py integer optional,intent(in) :: n = 13
REAL A,X
COMMON /DATA/ A,X(3)
PRINT*, "abc"
END
C END OF FTYPE.F
When I run the following command from Powershell:
f2py -c .\ftype.f -m ftype --compiler=msvc
I get the following errors:
ftype.o : error LNK2019: unresolved external symbol _gfortran_st_write referenced in function foo_
ftype.o : error LNK2019: unresolved external symbol _gfortran_transfer_character_write referenced in function foo_
ftype.o : error LNK2019: unresolved external symbol _gfortran_st_write_done referenced in function foo_
.\ftype.pyd : fatal error LNK1120: 3 unresolved externals
Based on other answers I have seen here, I feel that I may not be linking to a required library. Here is the entire output:
PS C:\Users\Brian\Desktop\F2PY> f2py -c .\ftype.f -m ftype --compiler=msvc
C:\Users\Brian\Desktop\F2PY>call "C:\Anaconda2\Scripts\\..\python.exe" "C:\Anaconda2\Scripts\\f2py.py" -c .\ftype.f -m ftype --compiler=msvc
running build
running config_cc
unifing config_cc, config, build_clib, build_ext, build commands --compiler options
commands have different --compiler options: ['mingw32', 'msvc'], using first in list as default
running config_fc
unifing config_fc, config, build_clib, build_ext, build commands --fcompiler options
running build_src
build_src
building extension "ftype" sources
f2py options: []
f2py:> c:\users\brian\appdata\local\temp\tmpra_1ng\src.win-amd64-2.7\ftypemodule.c
creating c:\users\brian\appdata\local\temp\tmpra_1ng\src.win-amd64-2.7
Reading fortran codes...
Reading file '.\\ftype.f' (format:fix,strict)
Post-processing...
Block: ftype
Block: foo
Post-processing (stage 2)...
Building modules...
Building module "ftype"...
Constructing wrapper function "foo"...
foo([n])
Constructing COMMON block support for "data"...
a,x
Wrote C/API module "ftype" to file "c:\users\brian\appdata\local\temp\tmpra_1ng\src.win-amd64-2.7\ftypemodule.c"
Fortran 77 wrappers are saved to "c:\users\brian\appdata\local\temp\tmpra_1ng\src.win-amd64-2.7\ftype-f2pywrappers.f"
adding 'c:\users\brian\appdata\local\temp\tmpra_1ng\src.win-amd64-2.7\fortranobject.c' to sources.
adding 'c:\users\brian\appdata\local\temp\tmpra_1ng\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\tmpra_1ng\src.win-amd64-2.7
copying C:\Anaconda2\lib\site-packages\numpy\f2py\src\fortranobject.h -> c:\users\brian\appdata\local\temp\tmpra_1ng\src.win-amd64-2.7
adding 'c:\users\brian\appdata\local\temp\tmpra_1ng\src.win-amd64-2.7\ftype-f2pywrappers.f' to sources.
build_src: building npy-pkg config files
running build_ext
customize MSVCCompiler
customize MSVCCompiler using build_ext
customize GnuFCompiler
Could not locate executable g77
Could not locate executable f77
customize IntelVisualFCompiler
Found executable C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2018.3.210\windows\bin\intel64\ifort.exe
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 'ftype' extension
compiling C sources
creating c:\users\brian\appdata\local\temp\tmpra_1ng\Release
creating c:\users\brian\appdata\local\temp\tmpra_1ng\Release\users
creating c:\users\brian\appdata\local\temp\tmpra_1ng\Release\users\brian
creating c:\users\brian\appdata\local\temp\tmpra_1ng\Release\users\brian\appdata
creating c:\users\brian\appdata\local\temp\tmpra_1ng\Release\users\brian\appdata\local
creating c:\users\brian\appdata\local\temp\tmpra_1ng\Release\users\brian\appdata\local\temp
creating c:\users\brian\appdata\local\temp\tmpra_1ng\Release\users\brian\appdata\local\temp\tmpra_1ng
creating c:\users\brian\appdata\local\temp\tmpra_1ng\Release\users\brian\appdata\local\temp\tmpra_1ng\src.win-amd64-2.7
C:\Users\Brian\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -Ic:\users\brian\appdata\local\temp\tmpra_1ng\src.win-amd64-2.7 -IC:\Anaconda2\lib\site-packages\numpy\core\include -IC:\Anaconda2\include -IC:\Anaconda2\PC /Tcc:\users\brian\appdata\local\temp\tmpra_1ng\src.win-amd64-2.7\ftypemodule.c /Foc:\users\brian\appdata\local\temp\tmpra_1ng\Release\users\brian\appdata\local\temp\tmpra_1ng\src.win-amd64-2.7\ftypemodule.obj
C:\Users\Brian\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -Ic:\users\brian\appdata\local\temp\tmpra_1ng\src.win-amd64-2.7 -IC:\Anaconda2\lib\site-packages\numpy\core\include -IC:\Anaconda2\include -IC:\Anaconda2\PC /Tcc:\users\brian\appdata\local\temp\tmpra_1ng\src.win-amd64-2.7\fortranobject.c /Foc:\users\brian\appdata\local\temp\tmpra_1ng\Release\users\brian\appdata\local\temp\tmpra_1ng\src.win-amd64-2.7\fortranobject.obj
compiling Fortran sources
Fortran f77 compiler: C:\cygwin64\bin\gfortran.exe -Wall -g -ffixed-form -fno-second-underscore -O0
Fortran f90 compiler: C:\cygwin64\bin\gfortran.exe -Wall -g -fno-second-underscore -O0
Fortran fix compiler: C:\cygwin64\bin\gfortran.exe -Wall -g -ffixed-form -fno-second-underscore -Wall -g -fno-second-underscore -O0
compile options: '-Ic:\users\brian\appdata\local\temp\tmpra_1ng\src.win-amd64-2.7 -IC:\Anaconda2\lib\site-packages\numpy\core\include -IC:\Anaconda2\include -IC:\Anaconda2\PC -c'
gfortran.exe:f77: .\ftype.f
gfortran.exe:f77: c:\users\brian\appdata\local\temp\tmpra_1ng\src.win-amd64-2.7\ftype-f2pywrappers.f
C:\Users\Brian\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\link.exe /DLL /nologo /INCREMENTAL:NO /LIBPATH:C:\cygwin64\lib\gcc\x86_64-pc-cygwin\6.4.0 /LIBPATH:C:\Anaconda2\libs /LIBPATH:C:\Anaconda2\PCbuild\amd64 /LIBPATH:C:\Anaconda2\PC\VS9.0\amd64 /LIBPATH:C:\Anaconda2\libs /LIBPATH:C:\Anaconda2\PCbuild\amd64 /LIBPATH:C:\Anaconda2\PC\VS9.0\amd64 /EXPORT:initftype c:\users\brian\appdata\local\temp\tmpra_1ng\Release\users\brian\appdata\local\temp\tmpra_1ng\src.win-amd64-2.7\ftypemodule.obj c:\users\brian\appdata\local\temp\tmpra_1ng\Release\users\brian\appdata\local\temp\tmpra_1ng\src.win-amd64-2.7\fortranobject.obj c:\users\brian\appdata\local\temp\tmpra_1ng\Release\ftype.o c:\users\brian\appdata\local\temp\tmpra_1ng\Release\users\brian\appdata\local\temp\tmpra_1ng\src.win-amd64-2.7\ftype-f2pywrappers.o /OUT:.\ftype.pyd /IMPLIB:c:\users\brian\appdata\local\temp\tmpra_1ng\Release\users\brian\appdata\local\temp\tmpra_1ng\src.win-amd64-2.7\ftype.lib /MANIFESTFILE:c:\users\brian\appdata\local\temp\tmpra_1ng\Release\users\brian\appdata\local\temp\tmpra_1ng\src.win-amd64-2.7\ftype.pyd.manifest
ftypemodule.obj : warning LNK4197: export 'initftype' specified multiple times; using first specification
Creating library c:\users\brian\appdata\local\temp\tmpra_1ng\Release\users\brian\appdata\local\temp\tmpra_1ng\src.win-amd64-2.7\ftype.lib and object c:\users\brian\appdata\local\temp\tmpra_1ng\Release\users\brian\appdata\local\temp\tmpra_1ng\src.win-amd64-2.7\ftype.exp
ftype.o : error LNK2019: unresolved external symbol _gfortran_st_write referenced in function foo_
ftype.o : error LNK2019: unresolved external symbol _gfortran_transfer_character_write referenced in function foo_
ftype.o : error LNK2019: unresolved external symbol _gfortran_st_write_done referenced in function foo_
.\ftype.pyd : fatal error LNK1120: 3 unresolved externals
error: Command "C:\Users\Brian\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\link.exe /DLL /nologo /INCREMENTAL:NO /LIBPATH:C:\cygwin64\lib\gcc\x86_64-pc-cygwin\6.4.0 /LIBPATH:C:\Anaconda2\libs /LIBPATH:C:\Anaconda2\PCbuild\amd64 /LIBPATH:C:\Anaconda2\PC\VS9.0\amd64 /LIBPATH:C:\Anaconda2\libs /LIBPATH:C:\Anaconda2\PCbuild\amd64 /LIBPATH:C:\Anaconda2\PC\VS9.0\amd64 /EXPORT:initftype c:\users\brian\appdata\local\temp\tmpra_1ng\Release\users\brian\appdata\local\temp\tmpra_1ng\src.win-amd64-2.7\ftypemodule.obj c:\users\brian\appdata\local\temp\tmpra_1ng\Release\users\brian\appdata\local\temp\tmpra_1ng\src.win-amd64-2.7\fortranobject.obj c:\users\brian\appdata\local\temp\tmpra_1ng\Release\ftype.o c:\users\brian\appdata\local\temp\tmpra_1ng\Release\users\brian\appdata\local\temp\tmpra_1ng\src.win-amd64-2.7\ftype-f2pywrappers.o /OUT:.\ftype.pyd /IMPLIB:c:\users\brian\appdata\local\temp\tmpra_1ng\Release\users\brian\appdata\local\temp\tmpra_1ng\src.win-amd64-2.7\ftype.lib /MANIFESTFILE:c:\users\brian\appdata\local\temp\tmpra_1ng\Release\users\brian\appdata\local\temp\tmpra_1ng\src.win-amd64-2.7\ftype.pyd.manifest" failed with exit status 1120
When I comment the PRINT statement in the FORTRAN code, there is no error, and the code compiles.
I am using GNU Fortran (GCC) 6.4.0. I am using Python 2.7.14 :: Anaconda custom (64-bit). I think I am using Visual C++ for Python. My operating system is Windows 10.
Thanks for the help!

I found a solution that works for me, based on the comments above.
I installed MinGW, using the following instructions and settings for Windows
f2py import Fortran code in Python
I ran the following command in PowerShell:
f2py -c ftype.f -m ftype --compiler=mingw32
I ran the following command in python:
import ftype
ftype.foo(5)
I got the following output:
abc
Below is the entire trace, if you are curious. Overall, I think having all the tools from one place (MinGW) might have helped, as in Iguananaut's comment above (Thank you!).
Thank you all for the help!
PS C:\Users\Brian\Desktop\F2PY> f2py -c ftype.f -m ftype --compiler=mingw32
C:\Users\Brian\Desktop\F2PY>call "C:\Anaconda2\Scripts\\..\python.exe" "C:\Anaconda2\Scripts\\f2py.py" -c ftype.f -m ftype --compiler=mingw32
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 "ftype" sources
f2py options: []
f2py:> c:\users\brian\appdata\local\temp\tmpt0zwdl\src.win-amd64-2.7\ftypemodule.c
creating c:\users\brian\appdata\local\temp\tmpt0zwdl\src.win-amd64-2.7
Reading fortran codes...
Reading file 'ftype.f' (format:fix,strict)
Post-processing...
Block: ftype
Block: foo
Post-processing (stage 2)...
Building modules...
Building module "ftype"...
Constructing wrapper function "foo"...
foo([n])
Constructing COMMON block support for "data"...
a,x
Wrote C/API module "ftype" to file "c:\users\brian\appdata\local\temp\tmpt0zwdl\src.win-amd64-2.7\ftypemodule.c"
Fortran 77 wrappers are saved to "c:\users\brian\appdata\local\temp\tmpt0zwdl\src.win-amd64-2.7\ftype-f2pywrappers.f"
adding 'c:\users\brian\appdata\local\temp\tmpt0zwdl\src.win-amd64-2.7\fortranobject.c' to sources.
adding 'c:\users\brian\appdata\local\temp\tmpt0zwdl\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\tmpt0zwdl\src.win-amd64-2.7
copying C:\Anaconda2\lib\site-packages\numpy\f2py\src\fortranobject.h -> c:\users\brian\appdata\local\temp\tmpt0zwdl\src.win-amd64-2.7
adding 'c:\users\brian\appdata\local\temp\tmpt0zwdl\src.win-amd64-2.7\ftype-f2pywrappers.f' 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:\mingw\mingw64\bin\gfortran.exe
customize Gnu95FCompiler
customize Gnu95FCompiler using build_ext
building 'ftype' extension
compiling C sources
C compiler: gcc -g -DDEBUG -DMS_WIN64 -O0 -Wall -Wstrict-prototypes
creating c:\users\brian\appdata\local\temp\tmpt0zwdl\Release
creating c:\users\brian\appdata\local\temp\tmpt0zwdl\Release\users
creating c:\users\brian\appdata\local\temp\tmpt0zwdl\Release\users\brian
creating c:\users\brian\appdata\local\temp\tmpt0zwdl\Release\users\brian\appdata
creating c:\users\brian\appdata\local\temp\tmpt0zwdl\Release\users\brian\appdata\local
creating c:\users\brian\appdata\local\temp\tmpt0zwdl\Release\users\brian\appdata\local\temp
creating c:\users\brian\appdata\local\temp\tmpt0zwdl\Release\users\brian\appdata\local\temp\tmpt0zwdl
creating c:\users\brian\appdata\local\temp\tmpt0zwdl\Release\users\brian\appdata\local\temp\tmpt0zwdl\src.win-amd64-2.7
compile options: '-DNPY_MINGW_USE_CUSTOM_MSVCR -D__MSVCRT_VERSION__=0x1500 -Ic:\users\brian\appdata\local\temp\tmpt0zwdl\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\tmpt0zwdl\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\tmpt0zwdl\src.win-amd64-2.7\ftypemodule.c -o c:\users\brian\appdata\local\temp\tmpt0zwdl\Release\users\brian\appdata\local\temp\tmpt0zwdl\src.win-amd64-2.7\ftypemodule.o
gcc -g -DDEBUG -DMS_WIN64 -O0 -Wall -Wstrict-prototypes -DNPY_MINGW_USE_CUSTOM_MSVCR -D__MSVCRT_VERSION__=0x1500 -Ic:\users\brian\appdata\local\temp\tmpt0zwdl\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\tmpt0zwdl\src.win-amd64-2.7\fortranobject.c -o c:\users\brian\appdata\local\temp\tmpt0zwdl\Release\users\brian\appdata\local\temp\tmpt0zwdl\src.win-amd64-2.7\fortranobject.o
compiling Fortran sources
Fortran f77 compiler: C:\mingw\mingw64\bin\gfortran.exe -Wall -g -ffixed-form -fno-second-underscore -O0
Fortran f90 compiler: C:\mingw\mingw64\bin\gfortran.exe -Wall -g -fno-second-underscore -O0
Fortran fix compiler: C:\mingw\mingw64\bin\gfortran.exe -Wall -g -ffixed-form -fno-second-underscore -Wall -g -fno-second-underscore -O0
compile options: '-Ic:\users\brian\appdata\local\temp\tmpt0zwdl\src.win-amd64-2.7 -IC:\Anaconda2\lib\site-packages\numpy\core\include -IC:\Anaconda2\include -IC:\Anaconda2\PC -c'
gfortran.exe:f77: ftype.f
gfortran.exe:f77: c:\users\brian\appdata\local\temp\tmpt0zwdl\src.win-amd64-2.7\ftype-f2pywrappers.f
C:\mingw\mingw64\bin\gfortran.exe -Wall -g -Wall -g -shared c:\users\brian\appdata\local\temp\tmpt0zwdl\Release\users\brian\appdata\local\temp\tmpt0zwdl\src.win-amd64-2.7\ftypemodule.o c:\users\brian\appdata\local\temp\tmpt0zwdl\Release\users\brian\appdata\local\temp\tmpt0zwdl\src.win-amd64-2.7\fortranobject.o c:\users\brian\appdata\local\temp\tmpt0zwdl\Release\ftype.o c:\users\brian\appdata\local\temp\tmpt0zwdl\Release\users\brian\appdata\local\temp\tmpt0zwdl\src.win-amd64-2.7\ftype-f2pywrappers.o -LC:\mingw\mingw64\lib\gcc\x86_64-w64-mingw32\8.1.0 -LC:\Anaconda2\libs -LC:\Anaconda2\PCbuild\amd64 -LC:\Anaconda2\PC\VS9.0\amd64 -lpython27 -lgfortran -o .\ftype.pyd
Removing build directory c:\users\brian\appdata\local\temp\tmpt0zwdl
PS C:\Users\Brian\Desktop\F2PY> python
Python 2.7.14 |Anaconda custom (64-bit)| (default, Oct 15 2017, 03:34:40) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import ftype
>>> ftype.foo(5)
abc

Related

Gcc offload compilation options

I'm trying to build the simplest OpenMP or OpenACC C++ program with GPU offload using gcc-10, CUDA 11 on Ubuntu 18.04 and this CMakeLists.txt file (or OpenMP version):
cmake_minimum_required(VERSION 3.18)
project(hello VERSION 0.1.0)
find_package(OpenACC REQUIRED)
add_executable(hello main.cpp)
target_compile_options(hello PRIVATE -O3 -fopenacc -foffload=nvptx-none)
target_link_libraries (hello OpenACC::OpenACC_CXX)
The build fails with:
[build] [100%] Linking CXX executable hello
[build] /usr/local/bin/cmake -E cmake_link_script CMakeFiles/hello.dir/link.txt --verbose=1
[build] /usr/bin/g++-10 -O3 -DNDEBUG -fopenacc CMakeFiles/hello.dir/main.cpp.o -o hello
[build] ptxas fatal : Value 'sm_30' is not defined for option 'gpu-name'
[build] nvptx-as: ptxas returned 255 exit status
[build] mkoffload: fatal error: /usr/bin/x86_64-linux-gnu-accel-nvptx-none-gcc-10 returned 1 exit status
[build] compilation terminated.
I suspect that a flag defining GPU architecture is missing, but I can't find relevant documentation. Offloading Support in GCC: Compilation options don't have Nvidia example and when I try my best guess -foffload="-arch=sm_75" or -foffload=nvidia-"-arch=sm_75", I get:
[build] [ 50%] Building CXX object CMakeFiles/hello.dir/main.cpp.o
[build] /usr/local/bin/cmake -E time /usr/bin/g++-10 -DFMT_LOCALE -O3 -DNDEBUG -O3 -fopenacc -foffload=nvptx-none -foffload=\"-arch=sm_75\" -std=gnu++2a -o CMakeFiles/hello.dir/main.cpp.o -c /home/paul/st/hello/main.cpp
[build] g++-10: fatal error: GCC is not configured to support "-arch as offload target
[build] compilation terminated.
Any clues or relevant links will be highly appreciated.

How to use NDK wth gcc on Android?

I need to compile OpenCV 2 to test some things and it can only be built with gcc. I tried downloading the oldest NDK in Android Studio which is version 16, however it still tries to use clang. How can I force it to use gcc?
Error on version 16:
ERROR: /home/user/AndroidStudioProjects/opencv2builder/app/src/main/cpp/CMakeLists.txt : C/C++ debug|x86 : CMake Error at /home/user/Android/Sdk/cmake/3.10.2.4988404/share/cmake-3.10/Modules/CMakeTestCCompiler.cmake:52 (message):
The C compiler
"/home/user/Android/Sdk/ndk/16.1.4479499/toolchains/llvm/prebuilt/linux-x86_64/bin/clang"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: /home/user/AndroidStudioProjects/opencv2builder/app/.cxx/cmake/debug/x86/CMakeFiles/CMakeTmp
Run Build Command:"/home/user/Android/Sdk/cmake/3.10.2.4988404/bin/ninja" "cmTC_ed369"
[1/2] Building C object CMakeFiles/cmTC_ed369.dir/testCCompiler.c.o
FAILED: CMakeFiles/cmTC_ed369.dir/testCCompiler.c.o
/home/user/Android/Sdk/ndk/16.1.4479499/toolchains/llvm/prebuilt/linux-x86_64/bin/clang --target=i686-none-linux-android --gcc-toolchain=/home/user/Android/Sdk/ndk/16.1.4479499/toolchains/x86-4.9/prebuilt/linux-x86_64 --sysroot=/home/user/Android/Sdk/ndk/16.1.4479499/sysroot -isystem /home/user/Android/Sdk/ndk/16.1.4479499/sysroot/usr/include/i686-linux-android -D__ANDROID_API__=16 -g -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -mstackrealign -Wa,--noexecstack -Wformat -Werror=format-security -fPIE -o CMakeFiles/cmTC_ed369.dir/testCCompiler.c.o -c testCCompiler.c
/home/user/Android/Sdk/ndk/16.1.4479499/toolchains/llvm/prebuilt/linux-x86_64/bin/clang: error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory
ninja: build stopped: subcommand failed.
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt
Affected Modules: app

Compile C++ code containing OpenMP with manually built gcc compiler

I've downloaded from github and built gcc. After that I've tried to compile a code with OpenMP:
../GCC/build/gcc/xgcc -B./../GCC/build/gcc/ -I./../GCC/build/x86_64-unknown-linux-gnu/libgomp -Wno-write-strings -O3 -Wall -fopenmp -lpng -o mandelbrot-omp mandelbrot-omp.cpp​
Then I got the following error message:
xgcc: error: libgomp.spec: No such file or directory​
I've checked and found out that libgomp directory contains the libgomp.spec file. The directory is included with -I option. What's wrong?

Clang boost header not found

I am trying to compile a Python PCL module which builds some C++ source. I am getting this error:
$ python setup.py install
running install
running build
running build_py
running build_ext
skipping 'pcl/_pcl.cpp' Cython extension (up-to-date)
building 'pcl._pcl' extension
/usr/bin/clang -fno-strict-aliasing -fno-common -dynamic -g -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Library/Python/2.7/site-packages/numpy/core/include -I/usr/local/Cellar/pcl/HEAD/include/pcl-1.8 -I/usr/local/Cellar/eigen/3.2.3/include/eigen3 -I/usr/local/Cellar/pcl/HEAD/include/pcl-1.8 -I/usr/local/Cellar/flann/1.8.4/include -I/usr/local/Cellar/pcl/HEAD/include/pcl-1.8 -I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c pcl/_pcl.cpp -o build/temp.macosx-10.6-intel-2.7/pcl/_pcl.o
pcl/_pcl.cpp:244:10: fatal error: 'boost/smart_ptr/shared_ptr.hpp' file not
found
#include "boost/smart_ptr/shared_ptr.hpp"
^
1 error generated.
error: command '/usr/bin/clang'
For whatever reason clang isn't looking in /usr/local/include where it most definitely would find the boost headers. As you can see it is linking all the other dependencies fine. What can I add that so clang will find boost?
On OSX 10.10, nothing fancy happening anywhere. Boost was probably installed by homebrew, but the files are all in /usr/local/include/boost as I'd expect.
Check the output of /usr/bin/clang++ -v some_test_file.cpp but chances are /usr/local/include isn't in the standard search path of the compiler.
You'll need to add -I/usr/local/include to CXXFLAGS or CPPFLAGS or whatever appropriate place in your build script or environment. It seems the python build script is failing to properly detect Boost.
If the above is not true (and /usr/local/include does show up in the output), make sure /usr/local/include/boost/smart_ptr/shared_ptr.hpp exists.

How to install PyGSL? (Windows 7, 64 bit, Python 2.7, GSL 1.15)

I'm trying to install PyGSL on my computer (64 bit Windows 7), with Python 2.7 and GSL 1.15 installed. I'm pretty much stuck and I would love for some extra help. GSL installed fine, but its the wrapper that's the problem. For some reason I can't build pygsl. Apparently gcc is the problem (got the same problem on another windows machine). Or it could be that pygsl appears to be using a file named AMD64 while my computer is x86. I would love to use the windows binary for pygsl, but it only exists for python 2.5, and my project needs 2.6 or higher. I've used both the windows binary for GSL and built it from source, but I get the same problem either way. I tried copying dlls from GSL into pygsl but that didn't work. Some forums mentioned a file called gsl.dll but I can't seem to find it. I've also tried to use Cygwin and to compile with minGW32 to no avail.
cmds I ran:
python setup.py install
python setup.py build
python setup.py build_ext -i
python setup.py build --compiler=mingw32
Any ideas?? Thanks.
Cheers,
Bereket
Got the same message in Cygwin as in the windows cmd prompt. Error message:
$ /cygdrive/c/Python27/python.exe setup.py build_ext -i
numpy
Forcing DISTUTILS_USE_SDK=1
Building testing ufuncs!
running build_ext
building 'errno' extension
C compiler: gcc -g -DDEBUG -DMS_WIN64 -mno-cygwin -O0 -Wall -Wstrict-prototypes
compile options: '-DSWIG_COBJECT_TYPES=1 -DGSL_RANGE_CHECK=1 -DDEBUG=1 -DNUMERIC=0 -DPYGSL_GSL_MAJOR_VERSION=1 -DPYGSL_GSL_MINOR_VERSION=15 -UNDEBUG -IC:\Users\Bereket\gsl-1.15\include -IInclude -I. -IC:\Python27\lib\site-packages\numpy\core\include -IC:\Python27\include -IC:\Python27\PC -c'
gcc -g -DDEBUG -DMS_WIN64 -mno-cygwin -O0 -Wall -Wstrict-prototypes -DSWIG_COBJECT_TYPES=1 -DGSL_RANGE_CHECK=1 -DDEBUG=1 -DNUMERIC=0 -DPYGSL_GSL_MAJOR_VERSION=1 -DPYGSL_GSL_MINOR_VERSION=15 -UNDEBUG -IC:\Users\Bereket\gsl-1.15\include -IInclude -I. -IC:\Python27\lib\site-packages\numpy\core\include -IC:\Python27\include -IC:\Python27\PC -c src/init/errorno.c -o build\temp.win-amd64-2.7\Release\src\init\errorno.o
Found executable C:\cygwin\bin\gcc.exe
gcc -g -mno-cygwin -shared build\temp.win-amd64-2.7\Release\src\init\errorno.o -LC:\Users\Bereket\gsl-1.15\lib -LC:\Python27\libs -LC:\Python27\PCbuild\amd64 -lgsl -lgslcblas -lm -lpython27 -lmsvcr90 -o C:\Python27\Lib\pygsl-0.9.5\pygsl\errno.pyd
build\temp.win-amd64-2.7\Release\src\init\errorno.o: In function `add_errno':
/cygdrive/c/Python27/Lib/pygsl-0.9.5/src/init/errorno.c:14: undefined reference to `__imp__PyInt_FromLong'
/cygdrive/c/Python27/Lib/pygsl-0.9.5/src/init/errorno.c:20: undefined reference to `__imp__PyDict_SetItemString'
build\temp.win-amd64-2.7\Release\src\init\errorno.o: In function `initerrno':
/cygdrive/c/Python27/Lib/pygsl-0.9.5/src/init/errorno.c:37: undefined reference to `__imp__Py_InitModule4_64'
/cygdrive/c/Python27/Lib/pygsl-0.9.5/src/init/errorno.c:40: undefined reference to `__imp__PyModule_GetDict'
collect2: ld returned 1 exit status
error: Command "gcc -g -mno-cygwin -shared build\temp.win-amd64-2.7\Release\src\init\errorno.o -LC:\Users\Bereket\gsl-1.15\lib -LC:\Python27\libs -LC:\Python27\PCbuild\amd64 -lgsl -lgslcblas -lm -lpython27 -lmsvcr90 -o C:\Python27\Lib\pygsl-0.9.5\pygsl\errno.pyd" failed with exit status 1
I'm pretty sure now that my GSL install with Cygwin failed / had unresolved dependencies. I'm now trying to install it with visual studio 2010. Here are some good sites for doing that:
Instructions
Alt Method
Installing the Python 2.7 compiler for Windows is a good place to start
http://www.microsoft.com/en-gb/download/details.aspx?id=44266
Running python setup.py build_ext --inplace does the trick for me.
If this doesn't work let me know. You might need to add an environment variable.
Is your Python 32 or 64? To check open Python and do
import sys
sys.versions

Resources