Cross compile nodejs modules to Windows with node-gyp - node.js

Due to some compiler problems on my Windows 7 x64 machine, I have to compile all my code on my Linux ARM box. How can I cross compile node modules with node gyp? Thanks in advance.

There are two problems here. First, you have to get cross-compiling set up to go from your ARM box to Windows.
This should help: http://wiki.wxwidgets.org/Cross-Compiling_Under_Linux
Then (assuming your compilers and linker are set up: CXX, etc.), you just need to specify the architecture when running node-gyp:
node-gyp --arch x64 rebuild
That should do it.

Related

Why does Ubuntu install ARM64 compilers with a version suffix that breaks autoconf?

I just installed the ARM64 cross-complier (aarch64-linux-gnu) on x86_64 Ubuntu 16.04 and all of the binaries have "-4.8" (like aarch64-linux-gnu-gcc-4.8). When I try to configure with --host=aarch64-linux-gnu, it fails to find aarch64-linux-gnu-gcc and falls back to the native gcc.
What did I miss? Is there an additional package that needs installation other than gcc-4.8-aarch64-linux-gnu? Or is there another mystery parameter to autogen.sh/configure that I don't know about?
Thanks.

Optimal way to install clang locally when GCC is outdated

I need to use tools that depend on clang on a Unix machine I remote onto at work. Anything I install is locally installed onto ~/local. I do not have root permissions.
/usr is pretty outdated, with gcc being at version 4.4.7. clang requires gcc 4.7+
I read on linux from scratch that a gcc 6.1 installation requires 8.4 gb. This is not something I can do, because that's huge.
Can someone advise me on the best workaround to install up to date clang on my ~/local?
Please and thanks.
Edit:
Courtesy of Nishant, here is the short answer:
Set up a personal machine running the same linux distro and cross compile using gcc to your specific architecture. For me, I will run a Redhat 6.5 VM and compile using gcc an arm x64 binary. Thanks Nishant!
You can get pre-build binaries for Unix system from LLVM's release website: http://llvm.org/releases/
You can then put the binaries in any local folder you want and source it using the PATH variable, which can be done by modifying your ~/.bashrc file by appending:
export PATH=$PATH:<clang-binary-directory>
Now you will able to use clang from the command line terminal as if it was installed.
If you want to build from source only, you can get older source code of clang which will use gcc 4.4.7 and build it and then use clang to build clang. Or get the latest clang binary and use it to build latest clang.

Compiling For 64bit Architecture in Ubuntu 32bit

I'm looking for tutorial how to compile project for 64bit architecture in ubuntu 32 bit architecture. I have to put this project on shared hosting machine which is x86_64 architecture. I can't compile this project on remote machine because I didn't have permissions to install some dependencies for this project.
When I try to put compiled project from my computer (ubuntu 32 bit) the execution fails because of floating point exceptions. The same scenario with simple hello_world application.
I'm total beginner with gcc, ld and I was always using compiled packages but now I have to compile for target machine different than mine.
For now I figured out that I need to install g++-multilib and add to CCFLAGS -m64 to the gcc.
Now I have errors like this:
/usr/bin/ld: skipping incompatible /usr/lib/libc.so when searching for -lc
Is there any way to compile dependency libraries inside aplication so I didn't have to resolve dependency libraries on the remote machine.
You need to install a 64-bit library pack.
apt-get install ibc6-dev-amd64
or something close to that (I used to have an Ubuntu machine at work, but I'm using Fedora at home, so can't even attempt to try what I'm suggesting - I know the principle is correct, but the exact detail is a bit vague)

Compiling libcurl x86 on Linux x64

I've cross-compiled the bulk of my 32-bit code on my x64 Ubuntu install, but I can't work out how to do the same trick with libcurl.
I've tried many permutations of --host and/or --build i486, x86, etc. but none have helped. I've also tried editing the makefiles to include gcc's -m32 flag manually, but it never shows up when I run them.
What should I be doing?
After you download and extract the libcurl source package, as a root user, run this command for setting up the build environment.
configure --host=i686-pc-linux-gnu CFLAGS=-m32 CC=/usr/bin/gcc
followed by
make
you can find the libs under ./lib/.libs/libcurl.so from where you ran the make command.
if you dont find /usr/bin/gcc, you will have to install gcc for 32-bit cross compilation env in a 64-bit machine.
It would help if you gave us an error message. I've had issues on Ubuntu x64 systems compiling 32-bit code with 'ld' errors.. I solved it by adding LDEMULATION=elf_i386 to my environment.

Which cross compiler?

What is the difference between
MinGW cross compiler and
GCC Cross compiler.
Which one used in which operating system?
I need to create an EXE file in the Linux operating system using Qt, hence which is the cross compiler to be used?
MinGW is a GCC cross compiler for Windows environments. (There are multiple GCC cross compilers for various different targets.)
To compile Windows executables on your Linux box, you want a MinGW install for your distribution of Linux.
If you're running
Debian, you want http://packages.debian.org/lenny/mingw32 (apt-get install mingw32)
Ubuntu, you want http://packages.ubuntu.com/jaunty/mingw32 (apt-get install mingw32)
Red Hat Linux or CentOS, you want several of the MinGW packages from http://download.fedora.redhat.com/pub/epel/5/i386/repoview/M.group.html (see EPEL how-to then yum install mingw32-binutils and mingw32-gcc-g++ at minimum)
Gentoo, see http://www.gentoo-wiki.info/MinGW
openSUSE, then you can find builds at http://download.opensuse.org/repositories/CrossToolchain:/mingw/
MingW32 is a port of GCC with "win32 target".
There are two architecture in a cross-compiler: host and target. The host is the platform the compiler run on; the target is what the result code will run.
Assume you are using Ubuntu, you can see the package here.
MinGW is basically a port of GCC and related tools, allowing them to run natively on Windows machines.
Cross compiling is the act of using a compiler on one operating system/architecture to generate a binary/EXE/DLL/object that is compatible with another operating system/architecture. Basically, you ask the compiler to generate assembly and startup routines for something other than the host OS's default.
If you were on a Linux machine, you'd use GCC to compile it for the Linux machine... If you were on a Windows machine, you'd use MinGW, but with flags to tell it to compile for the Linux machine's specifications.
GCC is usually used in Linux.. MinGW is just a Windows port of GCC to compile source to EXE files.

Resources