Compilng C/C++ makefile files under Windows (XP) - c++

I'm trying to use a Python library (pyMedia) that has some non-Python requisites libraries. (libogg, libvorbis, liblame, and libfaad2 - this isn't relevant to the question specifically).
libogg requires you to manually compile it from the source and comes with a makefile. I have GCC installed for Windows. How would I go about compiling this?

Get cygwin. It's the unix environment for windows, along with the Autotools (including make) toolchain.

MinGW can be used to compile under Windows. Add the binary to the PATH environment variable and you can use mingw32-make to compile using the Makefile.

Related

Can't compile and include armeabi native library

I'm trying to build a native library (.so) for armeabi architecture, but I can't find the way.
I have achieved to compile and run successfully my native library for armeabi-v7a. It seems like Visual C++ 2017 (15.5.5) compiles for this architecture by default.
The closest question I found to my problem is this one: How to build x86 and ARM in a single apk under Xamarin?
In its last comment, the user "SushiHangover" mentions the AndroidArch property, but I can't figure out how to use it.
In this other link I have found that the GCC compiler defaults to armeabi (I have been using clang). I've tried it, but the .so still goes to armeabi-v7a folder inside the APK (and it runs correctly)
Does anyone knows how to compile armeabi native libraries with Visual C++ and create a fat APK (with the .so library compiled for all the architectures)?
Thanks a lot!

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).

How to install protobuf on windows? (Win7x64/MinGW)

C++-Protobuf does not compile in VS2012. Now I want to use MinGW to compile it on windows. Can someone please give me some brief headwords on how to compile protobuf on Win7 x64. I already installed MinGW with the GUI installer. Google writes as MinGW setup notice that I should refer to the Unix installation notes. But I cant figure out how to use the auto tools on windows.
Edit
Okay this is what I've done until now:
$ mount C:/ WinDir
$ cd ./[...]/protobuf.2.4.1
$ ./configure
$ minGW32-make.exe
$ minGW32-make.exe check
minGW32-make.exe runs without errors, but no tests are running and I cant find libprotobuf.lib. There are some libprotobuf.dll but I need the lib, dont I?.
You should have an MSys console together with your MinGW instalation. This console provides an linux-like environment in which you should be able to use autotools normally.
If MSys is not installed, you can grab it from the MinGW site too.
cd to your directory with sources and try the usual:
$ ./configure
$ make
Some libraries cause problems on Windows but most compile well with MinGW and MSys. Come back and add more info to your question if you run into specific problems.
Edit:
minGW32-make.exe runs without errors, but no tests are running and I cant find libprotobuf.lib. There are some libprotobuf.dll but I need the lib, dont I?.
Usually for a dynamic library you'd get protobuf.dll (the dynamic library) and libprotobuf.a (the static wrapper library).
When linking, just pass -lprotobuf to the linker - it will look for both libprotobuf.a and protobuf.lib.
(.lib is another static library format, which is partially handled by MinGW but not native here.)
You will not work with a .lib file when using the MinGW toolchain. Instead, you are able to link against the dll directly. The MinGW Wiki explains this.
I could get dll and lib both. This is when you do not want static lib file and want to use dll and lib file.
You need to make following changes in Protobuf code:
Open the project in VS. Or any other editor. I use VS2015.
In libProtoBuf project settings, in C/C++ Preprocessor add following flags.
PROTOBUF_USE_DLLS; LIBPROTOBUF_EXPORTS;
Those flags will export information from profobuf using dllexport
in ur client code where you are using Protobuf, define: PROTOBUF_USE_DLLS. Which will make protobuf includes to use dllimport.
Once you do step 2, you will see both dll and lib in your output folder. Otherwise, you will always see just dll and not lib file.
Hope this helps. If not, please write a message here and I can help you getting this sorted out.

Can't work with gloox library in ubuntu 12.04 64-bit

Some time ago I installed gloox library with the command sudo apt-get install libgloox-dev.
But it is not working in netbeans, for example. I noticed that there are only .h files (with only function declarations) in /usr/include/gloox directory. Need your help...
You need to configure your project dependencies in order to use a library.
Are you able to access Gloox files using <> ? If yes the environment variable is set correctly (should be done automatically in Ubuntu)
The library (.so file) will be in /usr/local/lib. You need to link the project against it in your makefile. On netbeans I think it's on project properties->c++ compiler. Personally, I use Cmake to generate my makefiles
Try to download library from http://camaya.net/gloox/download and follow installation instructions.

Compiling libpng and using it with netbeans and mingw

I have only previously used visual studio for developing c++ but I've just moved to netbeans and am having some issues.
I got mingw installed so that my projects will compile but I dont know how to add external libraries to that. I want to use a static library, not a dll.
The library I specifically am looking at is libpng
I hope this isn't too IDE specific, I'm also looking to know how to prepare the library.
Windows OS.
I figured it out more or less. I used the cmake gui, configured for msys make and mingw g++ and gcc, on the zlib source directory and then ran msys make and make install on the output directory. After that I did the same on libpng, but I had to add some variables to point to the zlib include and library directories within cmake.
Then in netbeans, I right clicked>>properties on my project and added include and lib location for each of the two libraries. I also could have copied the files into my mingw directories.
Now I'm just stuck with this issue.