I am having trouble installing the FFTW library on Windows. I am following instructions from the following link:
http://www.fftw.org/fftw3_doc/Installation-on-non_002dUnix-systems.html#Installation-on-non_002dUnix-systems
1)
After downloading minGW 64-bit, I was wondering how I would access the "kernel" and "simd-support" directory to compile the c files as recommended.
2)
As I am unfamiliar with this library, is there a better way of installing the library using the command line?
As written in this link, under the subtitle "building FFTW3 under minGW":
http://www.fftw.org/install/windows.html
when I run the following commmand:
./configure --with-our-malloc16 --with-windows-f77-mangling --enable-shared --disable-static --enable-threads --with-combined-threads --enable-portable-binary --enable-sse2 --with-incoming-stack-boundary=2
I get:
'.' is not recognized as an internal or external command
any help would be much appreciated
For FFTW 3.3.10, I installed Cygwin with the mingw64-gcc package. From within the Cygwin command window, I set the following two variables:
export CC=x86_64-w64-mingw32-gcc.exe
export AR=x86_64-w64-mingw32-ar.exe
Next, I added "#define FFTW_DLL" to the fftw3.h header before building. I configured the build with the following command:
./configure --prefix=/cygdrive/c/fftw-build --with-our-malloc16 --with-windows-f77-mangling --enable-shared --disable-static --enable-threads --with-combined-threads --enable-sse2 --enable-avx --enable-avx2 --enable-avx512 --enable-avx-128-fma --with-incoming-stack-boundary=2 -disable-fortran --disable-alloca
and then I ran
make
make check
make install
Once that was done, the resulting desired DLL was in the bin directory, not the lib one. I followed the instructions in BUILD-MINGW64.sh from the fftw.org website to create the .def text file, and ran
lib /machine:x64 /def:libfftw3-3.def
on that text file to get the required .lib. VS2017 seems to be happy with that.
You are running your configure script in the cmd/power shell. You have to run your configure command in the MinGW shell.
http://www.fftw.org/install/windows.html has prebuilt libraries. They offer well maintained and optimised builds for 32bit and 64bit applications.
Related
I am building a simple command line game in C using the ncurses library on a Linux machine but I want to be able to run the compiled code on a Windows computer. To do this, I am using the MinGW-w64 cross compiler tool in Linux and compiling it to run in a 64 bit Windows environment. However, when I try to compile using this command:
x86_64-w64-mingw32-gcc -o game.exe barebones.c -lncurses
I get this error:
barebones.c:2:10: fatal error: ncurses.h: No such file or directory
2 | #include <ncurses.h>
| ^~~~~~~~~~~
compilation terminated.
I installed ncurses on my Ubuntu machine and can create and run the same simple program to run on Linux. I have been able to cross-compile and run simple programs that only use the default libraries. I think I must be listing the ncurses library incorrectly in the compliation command or that I am failing to understand other posts that show that this doesn't work.
I am using Windows 10 and Ubuntu 21.04.
Debian provides no cross-compiling packages for ncurses. (Ubuntu provides no additions or improvements to ncurses in any way, simply reusing packages from Debian). If you want to cross-compile ncurses, you'll have to build ncurses in cross-compiling form.
For development purposes, ncurses packages can be built using the scripts under the (sources) packages directory, e.g., after downloading the current source:
tar xf ncurses-whatever.tgz
cd ncurses-whatever
cp -var packages/debian-mingw64 ./debian
dpkg-buildpackage
That's a starting point. You'd have to do something about the email in the debian/control file to appease dpkg-buildpackage (tutorials are off-topic).
I'm a python developer new to C and developing C code on Windows that needs to work on Windows and Linux.
To that end, I downloaded MSYS2 and used pacman to install gcc and bz2.
My question is: How do I use bzip2 in my C code.
When I try to compile this C code:
#include <bzlib.h>
using the command gcc test.c -lbzip2 -o test.out I get the following error:
test.c:1:10: fatal error: bzlib.h: No such file or directory
Am I including the correct header file? Am I linking it correctly?
When not using 3rd party libraries a simple "hello world" program compiles and executes fine.
Short version: assuming you are using the MSYS target, pacman -S libbz2-devel.
Long version: In MSYS2 you can find which package contains a file using:
pacman -F bzlib.h
to which the answer is:
mingw32/mingw-w64-i686-bzip2 1.0.8-1 [installed]
mingw32/include/bzlib.h
mingw64/mingw-w64-x86_64-bzip2 1.0.8-1 [installed]
mingw64/include/bzlib.h
msys/libbz2-devel 1.0.8-1 (development)
usr/include/bzlib.h
To interpret this output, first understand that an MSYS2 installation supports three different development targets:
mingw32 (builds native Win32 applications using mingw-w64)
mingw64 (builds native Win64 applications using mingw-w64)
msys (builds Win32 or Win64 applications that depend on MSYS DLLs and runtime environment, using a custom GCC port and runtime library, and supports a lot of POSIX functionality).
When you install MSYS2 you will get three startup scripts in the Start Menu , one for each of those environments.
The output of pacman -F above told us that for targets mingw32 and mingw64, the package bzip2 contains the files required to do development with bzip. However, on the msys target, the package libbz2-devel is required.
This is a common package layout in msys and in the various *nix package managers (MSYS2 pacman is a port of ArchLinux pacman):
bzip2 is the binaries for using bzip2 in your shell
libbz2 is a shared object binary (DLL)
libbz2-devel is the header files and static libraries that you need to link bzip2 into your program.
You can list the files for each package with pacman -F --list libbz2-devel etc.
The mingw32/mingw64 targets typically have single packages that include all of those three things in the one package, e.g. pacman -F --list mingw64/mingw-w64-x86_64-bzip2.
I assume you are using msys target as otherwise this question would not have arisen .
Installing all the binary packages listed here and changing the header filename to bzlib.h fixed the problem.
I can successfully build protobuf in Windows, it result in three .lib files, but don't know how to build protobuf-c in Windows, there are no documents about it.
i was able to do that with Cygwin:
you can download the sources from here https://github.com/protobuf-c/protobuf-c
depending on the protobuf that you've compiled you can download the "right" version of the protobuf-c.
generally speaking, to build with Cygwin you'll need to add on top of the default installation:
gcc and the tools around it.
tools to build protobuf and protobuf-c as documented in the Github of each (https://github.com/protobuf-c/protobuf-c). build protobuf again i suspect for Cygwin to recognize it?
build as told (same for both):
./autogen.sh
./configure --prefix=/usr
make
make install
I downloaded the X264 source and installed mingw.
Step 1:
Executed this in the MINGW bash:
./configure --disable-cli --enable-shared --enable-win32thread -
-extra-ldflags=-Wl,--output-def=libx264.def
and then 'make'
Step 2:
Renamed the libx264-142.dll to libx264.dll and Opened up VS2012 Command Prompt and executed this:
LIB /DEF:libx264.def
which gave me libx264.lib and object libx264.exp
Step 3:
Included the lib file in a VS2012 project which uses the X264 API.
Problem:
When I start the project I get the following error message:
"The program can't start because libx264.dll is missing from your computer"
Question:
Why is it looking for the dll when I'm linking the static library in?
How do I resolve this? I would like to build a static X264 library which I can link in with my project.
EDIT:
I just had to put the dll in the same directory as the project executable.
However - My question still stands: How do I build a static x264 library? So I don't need the dll?
After the latest update of x264 you can build static library usable by MSVS project. For such library compilation you will need:
MSYS and MSVS 2013 Update 2 (express version [for Windows Desktop] would also work if you install Update 2)
run "VS2013 x86 Native Tools Command Prompt" or "VS2013 x64 Native Tools Command Prompt" depending what version (32 or 64-bit) you want to build
change dir to x264 path and run MSYS shell (sh)
from shell run "CC=cl ./configure --disable-cli --enable-static" for x264 configuring
run "make" which should build libx264.lib usable from MSVS
P.S. MSVS builds would be a little bit slower than one build by MinGW
Matthew Oliver has a GIT repository of a patched x264 source tree (https://github.com/ShiftMediaProject/x264) that compiles natively in VS2013 update 2 and later. It requires installing a YASM version for VS.
It worked pretty much straight out of the box for me, though I did have to change the VSYASM parameter "-f Win32" to "-f win32" for a 32bit build
Take a look here: http://siliconandlithium.blogspot.no/2014/03/building-x264-on-windows-with-visual.html
Static lib is not possible in windows as per my knowledge.
How can I cross compile my GTK+ app (written in C) from Linux to Windows? Could I just replace the "gcc" command with "mingw32"?
Fedora has a great mingw32 cross-compiler toolchain which comes with lots of precompiled libraries, including GTK+ and gtkmm. For most applications you just need to install the cross-compiler and the cross-compiled GTK+ libraries:
yum install mingw32-gcc mingw32-gtk2
Once everything needed is installed, compiling your application is just the matter of running "mingw32-configure" followed with "make".
More information at the project page https://fedoraproject.org/wiki/MinGW
You can use mingw-cross-env - all you have to do then is to change your CC/CXX environment path to use the i686-mingw32- prefix and export the mingw-cross-env bin dirs (both) to your PATH variable (or if you are using autotool it's even easier) - see the documentation on the homepage.
There is actually a project called MXE that does exactly this.
Pre-build package
You can download my pre-build binaries if you want.
Build from source
You can also build the code from scratch ideally also applying this PR to update to the latest GTK 3.24 version.
MXE has a easy wrapper (x86_64-w64-mingw32.static-cmake) to cross-build your project towards Windows, while using Linux. Allowing to evenly statically build your project into a single .exe file! Of course shared builds (x86_64-w64-mingw32.shared-cmake) are also supported. The example wrapper scripts are meant for CMake based projects.
Before you can build your project with MXE, you need to build the GTK3 from source-code. (There are some Linux packages available, but mostly out-dated). If you are using C++, you can also build gtkmm3. Since you are in place C, you only need to build gtk3.
git clone https://github.com/mxe/mxe.git
Become root user: su
mv mxe /opt/mxe
cd /opt/mxe
Build the MXE project yourself:
For static builds under Windows 64-bit for GTK3 & Gtkmm3:
sudo make gtk3 gtkmm3 -j 16 MXE_TARGETS='x86_64-w64-mingw32.static' MXE_PLUGIN_DIRS='plugins/gcc12'
For shared build to Windows 64-bit (again GTK3 + Gtkmm3):
sudo make gtk3 gtkmm3 -j 16 MXE_TARGETS='x86_64-w64-mingw32.shared' MXE_PLUGIN_DIRS='plugins/gcc12'
More info see the tutorial steps on MXE.cc.
Once you done the cross-compile environment / MXE build. Now you can use the CMake wrapper scripts I mentioned earlier. Those scripts are located in the /opt/mxe/usr/bin/ directory.
The scripts (like x86_64-w64-mingw32.static-cmake) can now be used to compile your project towards Windows, while using the Linux operating system. The build result would be an Windows .exe.
Disclaimer: I personally created this PR for MXE to update GTK to the latest 3.24.x release.