Is it possible to make this library as 32bit? By default, this builds as 64bit.
How can i include this library in my 32bit application?
There's ways to cross-compile libraries, but it's usually easier to build from a 32 bit system if you don't know how. You can debootstrap a 32 bit userspace on your own system and use chroot to access it.
https://jblevins.org/log/ubuntu-chroot
It certainly is possible. Actually, one of gRPC's continuous tests is testing that the 32bit build works well.
We are using this 32bit dockerfile to build:
https://github.com/grpc/grpc/blob/5059fd195753d0c18e51efa930aebd7e0461ed51/tools/dockerfile/test/cxx_jessie_x86/Dockerfile
You can also crosscompile as others are mentioning above. You're not mentioning if you are building on linux, windows or macos, so I assumed you're on linux but building a 32bit grpc is possible on windows and macos too (and perhaps easier than on linux).
Related
I sometimes run into this problem:
1 - I develop a working C++/C program on Ubuntu Linux for Ubuntu, which uses some libraries (which are platform-independent, such as OpenSSL, Boost, GNU Scientific Library, DCMTK, and others: these are generally available from apt-get, and are installed properly).
2 - I would like to also cross-compile the program from Ubuntu to run on Windows, using mingw (x86_64-w64-mingw32-g++).
3 - The libraries are missing from mingw.
Is there a generic way to easily "convert" any library from linux-version (or source-code) into mingw installation so that it can be used to build windows a program? Each library seems to have it's own separate complicated installation instructions for mingw.
You certainly can't convert Linux libraries directly to Windows, since they almost certainly make use of Linux system calls and calling libraries (such as the C runtime library) that are specific to Linux (even if the code doesn't directly call anything else, the compiler may add function calls implicitly, such as memory allocation calls from template functions and such)
You may be able to find "replacement" Windows libraries that you can install, but yes, many probably come with a Windows installer, which makes it hard to install without using either Wine or having a "real" Windows (but then you need that to test your app, so I'm not sure how much hindrance it really is).
Some libraries may be possible to BUILD with the mingw compiler as a cross-compiler under Linux, if they are written in a portable way, which may be an easier choice than installing a ready-made Windows library. But it assumes you can find the sources...
Researching something similar right now and running into issues with libraries like openssl, boost, sqlite, libpcap,...
The best solution have found so far is to utilize WSL2 and Docker.
https://code.visualstudio.com/blogs/2020/03/02/docker-in-wsl2
WSL2 is a Linux environment for Windows (utilizes Hyper-V).
Docker allows you to make containers for both windows and Linux that can talk with each other.
I have the base code I need run under WSL2 in Linux and when I need to access it from windows I utilize docker.
This isn't a perfect solution but I hope it helps.
Some Linux programs can be compiled on Windows via Mingw.
Here is how to set the cross-compiler environment:
How to compile a Linux program with Mingw?
http://qt-project.org/downloads . I downloaded the openGL since many say this set standard is better. but now i got requirement from my prof that I need to provide something that can work on windows 32/64. Is there any way that i do not have to install Qt for windows 32 and produce an application that can be run on windows 32?
what I am saying is that I only installed Qt for win64 but now I want something can work on win32 platform. so I suppose one way is to install Qt for win32 and create a new project. But I want to ask whether I can maybe do some configuration and produce something that can work on win32 using the installed Qt on win64 on my com
thanks!
For Windows Vista and up, there's no reason not to use the ANGLE implementation of OpenGL that's bundled with Qt. "many say tis set standard is better" - this is false unless you can guarantee that your customers have a decent OpenGL-supporting graphics card driver installed on their machine. I'd suggest forgetting about system OpenGL, and use ANGLE implementations.
It's trivial to compile your project for both 32 and 64 bit Qt, if you really need the 64 bit address space. For many applications, there's no reason at all to provide a 64 bit version.
No, you can't do it directly.
The only way to launch 64-bit applications on 32-bit Windows is to use emulators and virtual machines, for instance VMWare. But it reduces the application performance.
Can it cause any problem if I use 32 bit library on a 64 bit system?
What could be the incompatibilities?
I know this question is too vague. An example :
I tried to setup FreeGlut 32bit library with VS2010 on windows 7 64bit. There were a lot of issues at first.So, I was looking for 64bit of FreeGLUT, thinking 32bit FreeGlut might conflict with 64 bit windows. But later on I managed to run my 32bit FreeGlut with my 64bit windows without any problem.
Question is, if there are any thing in the program, that we should look into while using those libraries which doesn't match with the system. (32bit library on 64 bit OS)
64 bit Windows is fully capable of running 32 bit applications. In fact, the default configuration for Visual C++ is to build an x86 application regardless of the operating system it is running on.
There are some gotchas you have to be aware of when running a 32bit app on 64bit Windows. For instance, there's registry redirection (to avoid it you pass KEY_WOW64_64KEY to e.g. RegOpenKeyEx). There's filesystem redirection, too. These are important things to have in mind when you are reading system configuration values, for example.
Also, be aware that you can't mix 32 and 64 bitness in the same process. Your 32bit app can't use 64bit DLLs or static libraries.
Visual studio can compile for 32 bit or 64 bit based on the project setting.
Probably, Question you mean to ask is about Linking 32-bit library to 64-bit program
The answer is:
You can't directly link to 32bit code inside of a 64bit program.
The only option is to compile a 32bit (standalone) program that can run on your 64bit platform (using ia32), and then use inter-process communication to communicate to it from your 64bit program.
It's not about the operating system- Windows doesn't care if your code is 32bit or 64bit. It matters that your process is the same bitness as all libraries it cares to load- and they must all be the same bitness.
You might be interested in this link explaining common compiler errors when porting to 64-bit. It might help you solve your problem.
To try to answer your question more directly, there are things that might make 32 bit libraries break in a 64 bit environment, but that's too much information to share in a SO answer.
This link is the MSDN index related to development for 64 bit systems and might interest you as well.
Your question could be about how to develop specifically code that will run natively on 64-bit versus 32-bit hardware. There is info on that here. In particular you would have to follow the instructions here to enable 64-bit build tools.
If you are building 64-bit binaries, you will need to link with 64-bit libraries. Note that 32-bit binaries should run just fine on 64-bit Windows, so you may not need to go to this trouble.
Obviously you can't really run Mac or Linux apps on Windows, but can you compile binaries for those platforms using MSVC++ for example (plugging in additional compilers and tools obviously)? For a serious build system, you don't want one build server per platform so having an automated build server which compiles for all target platforms seems quite a reasonable aim.
Crosstool-NG seems like your best option for Linux apps; they show that as one of the standard configurations. I do not know about Mac OS X; this question suggests that it will probably be difficult.
I would like to believe (notice my careful words) that GCC can be built to run on windows (any relevant form of the triplet --mingw*) and target another triplet.
A proof-of-concept for the non-believers is provided here, where you can find Win64 hosted compilers that build native linux binaries. I assume the same can be done for mac if the necessary libraries (like the CRT and necessary Mac framework libraries) can be built/used by that compiler.
if you want to build applications using C++, why not use Qt from Nokia. it's cross platform. http://qt.nokia.com/
I have a small piece of code that works as a plugin for a larger graphics application. The development platform is Qt with c++ code. I've managed to build a .so, .dylib and .dll for linux, MacOS and Windows respectively, but to do so I had to have a machine running each operating system (in my case, running linux [ubuntu] gcc natively, and windows MinGW and MacOS XCode gcc in virtual machines).
Is there a way to build for all 3 platforms from one? I beat my head against this problem a while back, and research to date suggests that it's not easily (or feasibly) done. The code only needs to link against a single header that defines the plugin
API and is built from a fairly basic Makefile (currently with small variations per platform).
You should have a look at crosscompiling.
You basically build a compiler that (on your current plattform) will output binaries for your desired platforms.
Try this link about doing it on linux, for windows, with QT
Better late than never, I just came across IMCROSS
It looks quite promising!
For Linux it is fairly easy to setup or even download a virtual machine using VMWare for instance. Getting OSX to run on VMWare is somewhat tricky but possible.
Running VMWare and sharing a directory on a local drive you can even compile for the different platforms using the same exact files.
There is somewhere a cross-compiler for OSX but I wouldn't trust it to be of great quality.