Tarun Maganti
Tarun Maganti

Reputation: 3086

How to cross compile a library in Ubuntu for mingw/msys2 in Windows?

I have a sqlite library which I need to use in msys2 environment, it doesn't have access to internet. I want to compile and give the path to binaries in the msys2 environment.

How do I do the regular

./configure --prefix=/path/to/my/folder/
make 
make install

with x64_86-w64-mingw-gcc as the default compiler and it's respective libraries.


I tried with export CC=x64_86-w64-mingw-gcc first and running the above commands. It gives me an error at

checking whether we are cross compiling: error... If you are cross compiling, use --host.

How do I use host? What are the values, I should pass to configure, so that the library is a binary usable in Msys2 environment.

Upvotes: 0

Views: 2146

Answers (1)

Tarun Maganti
Tarun Maganti

Reputation: 3086

I can't say about all different architectures but for mingw platform, we can

./configure --prefix=/path/to/my/folder --host=x86_64-w64-mingw32

You need not specify CC. It'll use the above host as the prefix for your compiler, i.e., will use x86_64-w64-mingw32-gcc.


I don't know if it is true, but you can try on your own, if your compiler is arm64-gcc then try to put --host=arm64


This solved my problem, I don't claim this to be generic solution, until someone answers a more generic one, I'll mark my answer as the correct one.

Upvotes: 1

Related Questions