Building the latest iconv and libxml2 binaries in Win32 - c++

I'm trying to get MinGW and MSYS working so I can build iconv and libxml2 in Windows, but I'm finding ./configure and make are giving lots of BSD/Unix related errors that aren't specific enough to google, and not descriptive enough for me to figure out. Can anybody go through some of the steps needed to get iconv and libxml2 .dll/.lib built on a Win32 machine?
I'm updating the libraries for some software and I fiddled around with this all day today and haven't figured it out. I got the newest libpng, zlib and curl built with no issues but I see there isn't much support or how-to's for these libraries like there was for the others. Any help would be very appreciated, thanks in advance for your time.
James

I realize that I may be reviving a dead thread, but...
Something that worked for me was to not compile the shared libs, instead deriving them using the a2dll tool as follows:
./configure --prefix=/mingw --disable-shared
make
make install
a2dll libiconv.a -o iconv.dll
mv -iv iconv.dll /mingw/bin/

Environment mingw32
I was able to compile libxml2 with the help of this post
https://mail.gnome.org/archives/xml/2011-December/msg00005.html
Inside the win32 directory of the unzipped http://xmlsoft.org/sources/libxml2-2.9.1.tar.gz
perform 2 steps as below
cscript configure.js threads:no static:yes compiler:mingw iconv:no prefix=where_you_want_to_install include=where_your_mingw_include_is lib=where_your_mingw_lib_is debug=yes
and then
mingw32-make -f Makefile.mingw
I was able to compile and execute http://xmlsoft.org/examples/reader1.c example using code::blocks on mingw with Windows 7 environment.
Remember to specify -lxml2 and -lws2_32 flags in the "Other linker options" box under "Project build options"

libxml2 provides JavaScript configure. Look for it in win32 folder. There also is a separate readme file there. Example of building libxml2:
cd win32
cscript.exe configure.js compiler=mingw prefix=D:\soft\Qt\2010.03\mingw debug=yes static=yes
mingw32-make -f Makefile.mingw
I've downloaded prebuilt iconv and it works for me.

you can get the binaries for windows made by Igor Zlatkovic at http://www.zlatkovic.com/libxml.en.html

you must make clean first then
./configure --host=arm-linux --disable-shared --enable-static CC="arm-linux-gcc" --prefix="/tmp/iconv" --with-configuredir="/tmp/iconv"
make
make install
then at the /tmp/iconv get the libconv.a

I have recently found a tutorial from Andrew Marlow (July 2013), explaining briefly how to compile libxml2 under VisualStudio.
The libiconv can be compiled following this complete tutorial, also given as link in the first link.
EDIT
The version 1.14 of libxml2 has now a VS2010 solution. Now it is very simple to do this!
Otherwise, you can follow the readme and Marlow's tutorial to do the same job with other windows specific compilers.
EDIT
I want to write down here some details about the VS2010 solution included with libxml2 v1.14, to help anyone interested. It is pretty badly done; for example, the Release configuration is not properly done at all, you have to do it. If you want to use it, I give you two advices:
Delete first the project iconv if the path is not correct. Then add your project file; you will have still a warning at compilation, due to a reference kept on the old file. To suppress this warning, edit the .vcxproj with a text editor, change the ProjectReference Include path of the last ItemGroup with the correct path, AND also the Project item of this node (replace it with the ProjectGuid of the iconv vcxproj).
Link with Ws2_32.lib any application using the static library libxml2.lib.
These are some errors I've been thru, hope this will help anyone who wants to rebuilds libxml2 under VS.

Related

How to compile Quantlib via Xcode?

I am trying to install QuantLib on my Mac running OSX 10.11.6. Installed Boost 1.59 via MacPorts and then followed these instructions.
I used these additional environment variables
./configure --with-boost-include=/opt/local/include/ \
--with-boost-lib=/opt/local/lib/ --prefix=/opt/local/ \
CXXFLAGS='-O2 -stdlib=libstdc++ -mmacosx-version-min=10.6' \
LDFLAGS='-stdlib=libstdc++ -mmacosx-version-min=10.6'
and then make && sudo make install.
However when I run the Bermuda Swaption test it gave me the same error described here.
Little premise: I don't know anything about C++. I need QuantLib to work on Python. So I read carefully the answer by SmallChess and tried to solve it by myself. As I read in his answer
You can't just compile BermudanSwaption.cpp and hope everything would be fine. You have to compile the entire QuantLib library and link with the generated library files. Please google "compiling and linking C++" for more information.
By far, the easiest way to make it happen on Mac is to do it with Xcode. You will need to create a new Xcode project, and import the entire Quantlib project files into it. Next, you will need to create a main() function. Xcode does the compiling and linking for your automatically.
This is what I exactly did:
created a new project in Xcode (version 8.2.1)(file/new project/Command Line Tool/"HelloWorld"/Documents/create)
selected Targets, Build Phases and Link Binary With Library. Added libQuantLib.0.dylib
set libstdc++(GNUC++ standard library) as C++ Standard Library in Build Settings
Modified Header Search Paths to include: /opt/local/include/, and Library Search Paths to include: /opt/local/lib
C++ Language Dialect is set on Compiler Default.
Dragged the ql folder onto the left window of the Xcode
Now, I managed to copy a simple code which includes the library and even if there are many warnings, it runs. Still when I run on the Terminal the command for the Bermuda Swaption test I get the same error. What am I doing wrong?
Additional info (may or may not be useful): if I change the C++ Standard Library setting on Xcode to libc++, I get on Xcode the same error I get when i try the Bermuda Swaption test (ld: symbol(s) not found for architecture x86_64).
Any help would be very much appreciated
Regards
EDIT: you can find a picture of the code at https://i.stack.imgur.com/1zhjO.png

How to build Crypto++ library on Linux with MinGW?

im trying to port a c++ project from visual studio 2013 to netbeans on ubuntu. The target is a windows executable, so far im able to compile windows exe files from netbeans using mingw as compiler.
The project needs the Crypto++ library and i only have the .lib version for visual studio. To include the library in netbeans i first need to build the Crypto++ library in the .a format.
Its not clear to me how should i do that.
Ive found informations on how to build the library for linux with mingw but not for cross compilation with mingw. The provided GNUmakefile does not work.
Should i set up a vm with windows and mingw and compile the library that way? Or maybe use the qmake "hack" as suggested here http://www.qtcentre.org/threads/28809-Compiling-amp-using-Crypto-with-mingw-version-of-Qt ? The last good Crypto++ version suggested there is quite old. This is confusing, porting the whole project is easier than having the required library.
Im open to any suggestion.
tldr: how to build libcryptopp.a on linux for the cross compilation of a windows exe project
edit:
for example if i cross compile something there are windows libraries in the /usr/i686-w64-mingw32/lib/ folder like libuser32.a. i need to make the equivalend libcryptopp.a.. sorry if is a bit unclear.
if i simply build using the steps in answer (and in the wiki) i end up with a libcryptopp.a file but i suspect is linux-only, cause if i link that library in netbeans in the .exe file im cross compiling i end up with undefined references to cryptopp stuff everywere. the paths are correct, i suspect the library needs to be replaced with the equivalent libcryptopp.a compatible with crosscompiling.
edit2: im trying to follow the answer down here, now im stuck here. after this command to build cryptopp.
make CXX=/usr/bin/i686-w64-mingw32-gcc INCLUDES="-I /usr/i686-w64-mingw32/include" LIBS="-L /usr/i686-w64-mingw32/lib" CXXFLAGS="-std=c++0x"
and many variations of it i always end up with this error
trap.h:26:25: fatal error: Windows.h: No such file or directory
# include
which makes me think its using the right compiler to make a .a lib file for cross compiling the windows .exe with the lib.
however i dont understand whats going on now with the missing header..:(
Also if i try to link the lib file (used with visual studio) i get a lot of linking errors, undefined reference to cryptopp stuff.
ill offer a symbolic beer (a couple of $ of Bitcoins) if someone finds out how to do it.
Inspired by http://wiki.amule.org/wiki/Cross-compilation_for_windows_with_mingw:
sudo apt-get install mingw-w64
git clone https://github.com/weidai11/cryptopp
cd cryptopp
export TARGET=i686-w64-mingw32
CXX=$TARGET-g++ RANLIB=$TARGET-ranlib AR=$TARGET-ar LDLIBS=-lws2_32 make -f GNUmakefile
I've found informations on how to build the library for linux with mingw but not for cross compilation with mingw.
Its relatively easy...
Get Crypto++ ZIP into MinGW.
Unpack Crypto++ ZIP.
Change directories.
Build the library.
Verify All tests passed.
(1) and (2) can be tricky because Cygwin and MinGW are missing a lot of tools. So curl https://www.cryptopp.com/cryptopp563.zip -o cryptopp563.zip may not work.
For (2), I seem to recall ZIP is missing, so unzip -aoq cryptopp563.zip -d cryptopp-5.6.3 may not work.
At step (4), just perform make static dynamic test and be sure it finished with All tests passed.
I do a lot of testing with Cygwin and MinGW. I have a script that copies Crypto++ into the environments from my Desktop. I have not been able to figure out a way to automate it. A recent question on automating it was closed, so no one can supply an answer (see How to automate software testing for Cygwin and MinGW).

Qt - 4.7.3 - How to make static build

I used 4.7.2 for the past months. Now I downloaded 4.7.3. Now I am searching to type "configure -static". But I don't know where the hell "the qt path". Can anybody shed a light on this issue.
Download the source package here. Download and install your favorite perl distribution. I must warn you that Strawberry perl comes with its own toolchain and that may get used instead of the MinGW you downloaded. Use ActivePerl if you don't want any trouble, or build it yourself.
Unzip it to say, C:\Qt-source so that there is a configure.exe in C:\Qt-source
Open the toolchain's command prompt
a) If you're using the Visual Studio compiler, search in the "start" menu for a CMD shortcut in the Visual Studio folder. The Windows SDK also has this shortcut.
b) If you're using MinGW, either use the accompanying mingwvars.cmd, or open a command prompt, (Run->"cmd.exe") and type set PATH=C:\path\to\mingw\bin;%PATH%. Try gcc -v to see if it can be found.
Make a build directory, preferable something like C:\Qt. Do set QTPATH=C:\Qt and set PATH=C:\Qt\bin;%PATH% and cd C:\Qt, and type:
..\Qt-source\configure -static
After configure finishes, you'll either have to type nmake (Visual Studio) or mingw32-make.
Go do something else, because it will take a while.
Some tips that result from my experience, and add a bit more to the answer of rubenv:
Pass the install directory as a flag of the configure; be sure to choose a different directory from the one where you have stored a non-static version of Qt!
Some modules will likely cause you troubles when compiling statically because you need to resolve the dependencies statically; one example is webkit, so if you don't need it be sure to disable it
It is generally not a good idea to build the debug symbols into a static library, so I normally debug with the dynamic version, and use the static Qt to generate releases only.
Therefore, my configure looks something like this:
configure -static -prefix C:\Qt\4.8.6_static -no-webkit -release

Compiling boost with zlib

I'm compiling boost with bjam under Windows 7 (64bit-should be irrelevant)
D:\development\boost\boost_1_44\libs\iostreams\build>bjam stage ^
--toolset=msvc-10.0 link=static ^
--build-type=complete ^
-s ZLIB_SOURCE=C:\zlib125-dll ^
-s ZLIB_LIBPATH=C:\zlib125-dll\lib ^
-s ZLIB_INCLUDE=C:\zlib125-dll\include ^
-s ZLIB_BINARY=C:\zlib125-dll
But I only get
stage/libboost_iostreams-vc100-mt-gd-1_44.lib
bin.v2/libs/iostreams/build/msvc-10.0/debug/threading-multi/boost_iostreams-vc100-mt-gd-1_44.dll
bin.v2/libs/iostreams/build/msvc-10.0/debug/threading-multi/boost_iostreams-vc100-mt-gd-1_44.lib
bin.v2/libs/iostreams/build/zlib/msvc-10.0/debug/threading-multi/boost_zlib-vc100-mt-gd-1_44.dll
bin.v2/libs/iostreams/build/zlib/msvc-10.0/debug/threading-multi/boost_zlib-vc100-mt-gd-1_44.lib
but stage/libboost_zlib-vc100-mt-gd-1_44.lib is missing.
Am I compiling something wrong?
when I try running my project that worked well with boost and self-compiled boost/thread libraries I get the following error when I include the boost zlib stuff
6>LINK : fatal error LNK1104: cannot open file 'libboost_zlib-vc100-mt-gd-1_44.lib'
Does anyone know what I'm doing wrong?
I did manage to build them using the option
-sZLIB_SOURCE="C:\zlib-1.2.5"
Note there is no space after the -s and the quotes around the path.
It took me a while to get Boost to build correctly with zlib support.
The problem I ran into was that at some point zlib no longer included a gzio.c source file. The jamfile for the Boost build system (jamfile.v2) had a reference to the gzio module which caused it fail. The solution was to remove that reference before building.
I'm not sure this answer is relevant any longer, unless you're trying to build an old version of Boost. I believe the original build issue has been fixed in more recent versions of Boost.
I had the same problem (Windows 7 Visual Studio) and I believe the issue is not in how you build boost.
1) As ecotax, there should not be a space after the -s
2) When running bjam, add the flag --debug-configuration. If in the output you do not see errors and it prints out something like
notice: iostreams: using prebuilt zlib
then it has found your zlib copy, which it is good.
3) Notice that the library libboost_zlib-vc100-mt-gd-1_44.lib should not be produced.
4) When you compile your application in Visual Studio, seems that Boost.Iostreams auto-linking still wants libboost_zlib-vc100-mt-gd-1_44.lib and reports a link error.
What it worked for me (I founded googling) was to add to the preprocessor definitions the flag
BOOST_IOSTREAMS_NO_LIB
I was trying all sorts of things and had a hard time finding the correct solution for newer versions of boost (1.75.0).
All the -sZLIB_xxx switches seem to be not working anymore.
Boost Documentation just states
On Windows the zlib, bzip2, zstd and/or LZMA binaries need to be in the PATH, else they will not ordinarily be found by default, so it is always a good idea under Windows to setup the zlib, bzip2, zstd and/or LZMA toolsets in your own jamfile.
Setting path did not lead to any success, so I dig through more documentation. Boost provided jam documentation and examples are not the most helpful, so through analysis of the Conan Recipe for the Conan boost package I finally came up with this minimal user-config.jam file that does the trick for me:
using zlib : your.zlib.version :
<include>"path/to/zlib/include/headers"
<search>"path/to/zlib/library/file" ;
The minimal b2 command to execute this for me is:
.\b2.exe --user-config="path/to/user-config.jam"
Hope this can be of help to others so they don't need to waste a lot of time as I did.
For guys, who compiling, using prebuilt 'zlib'.
These steps needs to be done:
Download and build 'zlib'
Run b2.exe --with-iostreams -s ZLIB_BINARY=zlib -s ZLIB_INCLUDE=C:/Sys/zlib-1.2.7/Include -s ZLIB_LIBPATH=C:/Sys/zlib-1.2.7/Lib release
Update paths to your local installation zlib folder. This way, Boost will embed into libboost_iostreams the gzip.cpp, zlib.cpp files. No libboost_zlib will be generated.
At your source file add this lines (somewhere in stdafx.h, before including Boost.Iostream headers):
--
#ifdef _DEBUG
#define BOOST_ZLIB_BINARY zlibd
#else
#define BOOST_ZLIB_BINARY zlib
#endif
This tells that you don't want to link against libboost_zlib, but you provide precompiled zlib library instead.
At your project settings provide path to zlib.lib file.
It should compile and link now.
I took a combination of advice from other answers here and this is what I did:
Extract zlib to C:\zlib\zlib-1.2.11.
Use CMake to configure and generate MS Visual Studio 2017 project and use MS Visual Studio 2017 to build the project. I built it in place so that C:\zlib\zlib-1.2.11 now contains (in addition to previous contents) directories lib and include.
Extract Boost 1.67.0 to C:\Boost\boost_1_67_0.
(Be on drive C:)
cd \Boost\boost_1_67_0
bootstrap.bat
set ZLIB_SOURCE="C:\zlib\zlib-1.2.11"
set ZLIB_INCLUDE="C:\zlib\zlib-1.2.11\include"
set ZLIB_LIBPATH="C:\zlib\zlib-1.2.11\lib"
The following line built libboost_iostreams and it did put libboost_zlib files in C:\Boost\boost_1_67_0\stage\lib:
b2 --debug-configuration --with-iostreams -sZLIB_SOURCE="C:\zlib\zlib-1.2.11" -sZLIB_INCLUDE="C:\zlib\zlib-1.2.11\include" -sZLIB_LIBPATH="C:\zlib\zlib-1.2.11\lib"
The following line built the rest of Boost:
b2 -sZLIB_SOURCE="C:\zlib\zlib-1.2.11" -sZLIB_INCLUDE="C:\zlib\zlib-1.2.11\include" -sZLIB_LIBPATH="C:\zlib\zlib-1.2.11\lib"
Don't know if this is the most optimal way to do it, but it did build the libboost_zlib lib files.
set ZLIB_SOURCE="c:\zlib"
set ZLIB_INCLUDE="c:\zlib"
.\b2
.\bjam will not build but .\b2 will build the library: stage/libboost_zlib-vc100-mt-gd-1_44.lib

Boost 1.37 pre-built for MSVC

I can't find a pre-built set of MSVC++ libs for Boost 1.37.0, only the source. I don't understand how their weird build system works... are there any places I can find a download of a visual studio project or something?
The BoostPro Computing folks maintain the Boost installer for Windows but it usually take a few weeks for them to put new versions online. It's not yet up for 1.37.
There's no Visual Studio solution (remember, Boost targets many platforms) though there is an effort to also support building Boost with CMake. I'm not sure how far along they got for 1.37 but I believe it's still early days for this process.
However the standard build system isn't that weird! Start by downloading bjam for your platform (look for a suffix of 'ntx86' for Windows) and installing it somewhere in your path (C:/Windows/System32). Then download the source, uncompress it and run the build system from the command line. It'll look something like this for Visual Studio users:
bjam --build-dir="C:\boostsource" --toolset=msvc --build-type=complete stage
This is lifted pretty much from the Getting Started Guide which goes into much more detail. The build-dir is not needed if you're current directory is the root of the source.
After waiting a couple of hours for everything to build ('complete' means that it'll build debug, release, single/multi threaded, static/dynamic, static/dynamic linking to the runtimes - and combinations) you'll end up with all of the libs in a 'stage/lib' directory.
Finally you need to tell Visual Studio where to find the headers and libs. Go to Tools->Options->Projects and Solutions->VC++ Directories. Add an entry for "Include files" (like "C:\boostsource"). Add an entry for "Library files" ("C:\boostsource\stage\lib").
I've got a build of 1.37 (VC 7.1, 8, 9) on my website, help yourself.
http://boost.teeks99.com/
(Update... 1.38 is up there as well)
(Another Update, 1.39 is now there)
(1.40 is up)
(1.41 is up, a bit late)
It seems complicated, but building Boost is really not that bad. First you need to download the bjam tool (SourceForge is a good source). Make sure bjam.exe is in a directory in your PATH.
Go the the root of your unzipped Boost download (e.g. C:\Boost_1_37_0)
Type bjam --help to get a list of all your build options.
I use the following command to build everything, you can customize it to suit your needs:
bjam --prefix=C:\boost --build-dir=C:\build --build-type=complete install
The results will be placed in C:\boost and you can delete C:\build.
Building it isn't difficult.
They have a fairly good expanaltion of the default process here:
http://www.boost.org/doc/libs/1_37_0/more/getting_started/windows.html#or-build-binaries-from-source
Download bjam (from sourceforge, there are links from the boost website), as well as the boost sources, make sure bjam is accessible from the boost dir, cd to the boost dir, and run something like the following:
bjam --build-dir= --prefix-dir= --toolset=msvc --build-type=complete install
where is an temp dir where it can store intermediate files, and is the final install location. There are all sorts of other options you can play around with, and not all of them are documented very well, but the basics are fairly simple.
For more help, you can run bjam --help from the boost source dir.