can't find any solution for running f2py correctly on my windows 7 machine - f2py

Can someone pinpoint where I'm doing wrong, PLEASE? I'm so exhausted. I installed MinGW 4.7, python2.7.8, numpy 1.7.1 and scipy0.13.2 to an Anaconda (32bit) environment in Windows7.
Also, for user enviroment variables, I set
C_INCLUDE_PATH:
D:\Anaconda2\envs\arc103\MinGW\i686-w64-mingw32\include
Path (User variable):
C:\Program Files (x86)\Microsoft VS code\bin;D:\Anaconda2\Library\bin;D:\Anaconda2\envs\arc103\MinGW\bin
Tying the following commands in Anaconda Prompt
"f2py -c --help-fcompiler" outputs "... Fortran compilers found:
--fcompiler=gnu95 GNU Fortran 95 compiler (4.7.0) ...."
"f2py -c --help-compiler" outputs
"List of available compilers: ...", not specifically compilers found though.
Running "f2py -c fib1.f -m fib1" according to "NumPy v1.12.dev0 Manual" gives me lots of error as below:
D:\Anaconda2\envs\arc103\Scripts\gfortran.bat -Wall -Wall -shared c:\users\dkim1\appdata\local\temp\tmpvyedhg\Release\users\dkim1\appdata\local\temp\tmpvyedhg\src.win32-.7\fib1module.oc:\users\dkim1\appdata\local\temp\tmpvyedhg\Release\users\dkim1\appdata\local\temp\tmpvyedhg\src.win32-2.7\fortranobject.o c:\users\dkim1\appdata\local\temp\tmpvyedhg\Release\fib1.o -Ld:\anaconda2\envs\arc103\mingw\lib\gcc\i686-w64-mingw32\4.7.0 -LD:\Anaconda2\envs\arc103\libs -LD:\Anaconda2\envs\arc103\PCbuild -lpython27 -lgfortran -o .\fib1.pyd
c:\users\dkim1\appdata\local\temp\tmpvyedhg\Release\users\dkim1\appdata\local\temp\tmpvyedhg\src.win32-2.7\fib1module.o:fib1module.c:(.text+0x35): undefined reference to `__imp__PyNumber_Int'
c:\users\dkim1\appdata\local\temp\tmpvyedhg\Release\users\dkim1\appdata\local\temp\tmpvyedhg\src.win32-2.7\fib1module.o:fib1module.c:(.text+0x68): undefined reference to `__imp__PyComplex_Type'
c:\users\dkim1\appdata\local\temp\tmpvyedhg\Release\users\dkim1\appdata\local\temp\tmpvyedhg\src.win32-2.7\fib1module.o:fib1module.c:(.text+0x79): undefined reference to `__imp__PyType_IsSubtype'
c:\users\dkim1\appdata\local\temp\tmpvyedhg\Release\users\dkim1\appdata\local\temp\tmpvyedhg\src.win32-2.7\fib1module.o:fib1module.c:(.text+0x93): undefined reference to `__imp__PyErr_Occurred'
... (Thousands of "undefined reference to" errors I didn't put it here) ...
collect2.exe: error: ld returned 1 exit statuserror: Command "D:\Anaconda2\envs\arc103\Scripts\gfortran.bat -Wall -Wall -shared c:\users\dkim1\appdata\local\temp\tmpvyedhg\Release\users\dkim1\appdata\local\temp\tmpvyedhg\src.win32-2.7\fib1module.o
c:\users\dkim1\appdata\local\temp\tmpvyedhg\Release\users\dkim1\appdata\local\temp\tmpvyedhg\src.win32-2.7\fortranobject.o
c:\users\dkim1\appdata\local\temp\tmpvyedhg\Release\fib1.o -Ld:\anaconda2\envs\arc103\mingw\lib\gcc\i686-w64-mingw32\4.7.0 -LD:\Anaconda2\envs\arc103\libs
-LD:\Anaconda2\envs\arc103\PCbuild -lpython27 -lgfortran -o .\fib1.pyd" failed with exit status 1
Sorry for the mess. I have spent almost a few months finding out the fix, but it's too hard for me and all gone to no avail. It would be hugely appreciated if you can help me out. Thanks.

Since this is a couple month old, I am not sure if these tips will still help, but I found when building a Fortran to Python module on Win 10, that only compiling for 32bit worked, and you need to use a signature file, i.e. something along the lines of:
f2py.py -c cuncsd.pyf cuncsd.f
Instead of using the i686-w64-mingw32 toolchain I used a straight mingw32 one (to reduce the risk that I accidentally end up with anything 64bit).
I also found that you need to install a special Visual Studio for Python instance as described here:
Microsoft Visual C++ Compiler for Python 3.4
If you are using Python 2.7 this VSC version should do the trick for you, only newer version (3.5, 3.6) are left out at this time.
For reference here is my complete f2py invocation on the console that I ended up using (neither python nor f2py were on the execution PATH):
python C:\Python34\Scripts\f2py.py -c cuncsd.pyf --opt="-frecursive -fmax-stack-var-size=66560" cuncsd.f -llapack -lrefblas -ltmglib
This particular module depends on 32 bit LAPCK shared libraries that I compiled previously, and we found it even works on XP systems.
I later went back and tried to compile this for 64 bit, but eventually gave up, when I always encountered ld errors. I think going forward for Windows 10 it will be much easier to use the embedded Ubuntu to execute and extend Python.
(See How to enable Bash in Windows 10 developer preview? and Getting PyCharm to recognize python on the windows linux subsystem (bash on windows))

Related

Perl to mysql connectivity on Windows 10

I have a process that works in the production environment, that I need to get working on my local Windows 10 environment. It is a Perl script that calls mySql stored procedures.
I have installed ActivePerl 5.26.3 (64-Bit) from Active State. When I attempt to execute the script I get an error:
Can't locate DBD/mysql.pm (you may need to install the DBD::mysql module)...
So, I went to https://metacpan.org/release/DBD-mysql and found instructions that indicated I needed to do the following:
perl -MCPAN -e shell
install DBD::mysql
But, when I type the first command I get a message stating:
It looks like you don't have a C compiler and make utility installed. Trying to install dmake and the MinGW gcc compiler using the Perl Package Manager. This may take several minutes....
Then it goes thru what appears to be a successful installation. So I type in the second command. It scrolls by for a while, but ends with:
Failed during this command
DVEEDEN/DBD-mysql-4.050.tar.gz: writemakefile NO 'C:\Perl64\bin\perl.exe MakeFile.PL INSTALLDIRS=site' returned status 512
Not sure how to proceed.
For ActivePerl, use their package manager PPM.
Or, use Strawberry Perl for a more unixy experience. It comes with all the stuff to compile and install modules.
No matter which Perl you use, on Windows or elsewhere, modules typically need to be compiled the same. Mixing compilers (such as Visual Studio and gcc) or options can lead to incompatible binaries. The same might happen across Perl versions too. That means to use the same Perl (and compilation method) for everything in your project).
The cpan utility doesn't figure out those things for you. It does whatever it's configured to do.
For what it's worth, the cpan method to install modules can be simpler:
$ cpan DBD::mysql

Octave not compiling, confused by build error

I'm a modest user of Linux; but I appear to have hit a wall here when building Octave.
I need to use Octave 4.0.0 on (64-bit) Ubuntu 14.04, and it seems the only option for me (so far) is to build from source (as the repos apparently don't offer anything prebuilt for this version yet). Anyway, I do
./configure
make
...and then get this:
/usr/bin/ld: /usr/local/lib/libGraphicsMagick.a(magick_libGraphicsMagick_la-analyze.o): relocation R_X86_64_32 against `.gomp_critical_user_GM_GetImageDepthCallBack' can not be used when making a shared object; recompile with -fPIC
/usr/local/lib/libGraphicsMagick.a: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
I figured this was because my graphicsmagick install wasn't build with -fPIC. So I downloaded graphicsmagick and did
./configure --with-shared
and built out a new graphicsmagick (make install). Still the same error. So I tried to "force it" by doing the following to graphicsmagick:
./configure CCSHARED="-fPIC" CXXFLAGS="-fPIC"
This time I did a search within the generated Makefile and found -fPIC was, indeed, added to the CXXFLAGS. But after making and install the new graphicsmagick, I still get the same error.
This seems like a build chain problem that I've caused. Any thoughts?
Try with:
./configure --enable-shared --disable-static

no mpicxx when compiling examples for NVIDIA CUDA 5

I installed the driver and toolkit for CUDA 5 in 64-bit RHEL 6.3 successfully.
However, when I tried compiling the CUDA 5 examples, I got the error message:
make[1]: Leaving directory `/root/NVIDIA_CUDA-5.0_Samples/0_Simple/cppIntegration'
which: no mpicxx
How can I fix this for the CUDA 5 examples to compile?
In order to build the simpleMPI example, you need some kind of MPI installed on your system. You can get around this and build most of the samples by doing:
make -k
this will attempt to go past errors in the make process and build all targets that can be built.
If you prefer, you can delete this directory:
/root/NVIDIA_CUDA-5.0_Samples/0_Simple/simpleMPI
perhaps with the following command, as root:
rm -Rf /root/NVIDIA_CUDA-5.0_Samples/0_Simple/simpleMPI
and relaunch your make. Personally I think the make -k option is simpler.
(the message about cppIntegration is just the last target that got successfully built)

LLVM bitcode does not find function

I went forward and compiled an existing c code via llvm-gcc -emit-llvm -c to llvm bitcode. The c program consisted of four modules which I built to one big bitcode each via llvm-ld. Then I tried to merge these 4 bitcode files to one via llvm-ld GE.bc GA.bc SD.bc SH.bc -o prog which works without complaint.
Trying to execute the bitcode though it complains:
LLVM ERROR: Program used external function 'myFunction' which could not be resolved!
The thing is myFunction should be defined in SD.bc and used also in GA.bc.
But it's not to find in SD.bc - does llvm-ld skip all definitions that are not used!?
My OS is Linux and I use llvm version 2.6.
As a note llvm is on version 2.9 with 3.0 approaching. You should really upgrade.

compile basic mysql c code with xcode

Anyone manage to write code that uses the mysqlclient library? I can get compiling working but not linking :(
XCode produces the following output:
Build TestMysql of project TestMysql with configuration Debug
Ld build/Debug/TestMysql normal x86_64
cd /Users/jacob/Documents/cocoa/TestMysql
setenv MACOSX_DEPLOYMENT_TARGET 10.5
/Developer/usr/bin/gcc-4.2 -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.5.sdk
-L/Users/jacob/Documents/cocoa/TestMysql/build/Debug -L/usr/local/mysql/lib
-L/usr/local/mysql-5.1.38-osx10.5-x86_64/lib
-F/Users/jacob/Documents/cocoa/TestMysql/build/Debug -filelist /Users/jacob/Documents/cocoa/TestMysql/build/TestMysql.build/Debug/TestMysql.build/Objects-normal/x86_64/TestMysql.LinkFileList
-mmacosx-version-min=10.5 -lm -lz -lmysqlclient -lmygcc "
" -framework CoreFoundation -o /Users/jacob/Documents/cocoa/TestMysql/build/Debug/TestMysql
i686-apple-darwin10-gcc-4.2.1:
: No such file or directory
Command /Developer/usr/bin/gcc-4.2 failed with exit code 1
And yes I already know about the mysql/cocoa framework, im writing code that must compile on os/x and linux. Ironically it only took me 20 minutes to work out how to write a make file to compile and link and run objective-c / mysql code, but xcode is soo much more complicated.
I believe the "" string is causing you grief -- especially since the error message's filename is the empty string.
Alternate methodology:
Have you considered just using the Makefile you made in XCode?
File->New Project->Other->External Build System.
Apple docs on this method: http://bit.ly/dYNuR
Ok, its an xcode bug. Under the screen to add linker options with the + and - buttons, somehow there was an extra link option with a CR or LF in it. Don't ask me how it got there I don't know! (:
That comment about the weird "" helped me solve it (eventually).
I know this is an old post but for anyone that has the same issue...
Make sure you install into the /usr/local by first setting the make files:
sudo cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=/usr/local
Then, 'make install' will put everything in the right directories. Next, in Xcode, you have to right click a folder in the project, say add existing framework, change the drop down to pick dylibs, finally choose libmysql.dylib.
The libmysql.dylib is a shared library that xcode needs to look at for the function names.