How to build NLopt library as 32-bit DLL for Windows?

183 Views Asked by At

The official instruction is as follows (on github):

"If you want to compile NLopt on Windows with MinGW, be sure to install the MinGW version of cmake (e.g. with pacman -S mingw-w64-x86_64-cmake) and then build via cmake -G"MSYS Makefiles" . && make in order to ensure that cmake produces the correct type of makefile."

I did this on MSYS2 but the result is a 64-bit dll (as expexted) and I don't know how to get a 32-bit!

There are precompiled binaries for Windows (32-bit and 64-bit). Until now I used this 32-bit version but I need a build from the latest source including a bugfix I need.

I tried it in a MSYS2 MinGW32 terminal but I could not install cmake. Same problem on a 32-bit version of cygwin.

Last I tried (found in a stackoverflow post):

"pacman -S --needed base-devel mingw-w64-i686-toolchain" on MSYS2 (resulting in adding 1 GB data!) but still a 64-bit dll!

Thanks, Rolf

1

There are 1 best solutions below

1
On

I solved it!!

I used the "MSYS2 MSYS" shell and installed mingw-w64-i686-cmake:

$ pacman -S mingw-w64-i686-cmake

Then I opened a "MSYS2 MINGW32" shell and built it:

$ cd nlopt
$ cd build
$ cmake -G"MSYS Makefiles" ..
$ make

That's it!