I'm new to erlang and rebar. In my rebar project I used a dependency containing native c code and during rebar compile I'm getting error:
Name cl.exe is not recognized as an internal or external command, operable program or batch file
I guess that rebar is trying to compile c files from my dependency using Microsoft's cl.exe compiler from VisualStudio, right? The problem is that I don't have VS installed and don't want to install it.
Why rebar is trying to use cl.exe? Can I configure rebar to use different compiler to compile c files?
According to the comments in the rebar port compiler code, you can provide an alternative C compiler by adding something like this to your rebar.config:
{port_env, [{"CC", "/path/to/gcc.exe"}]}.
You will most likely have to change the CFLAGS to match the compiler. To compile NIFs and ports the OTP headers and development libraries must be compiled and available.
Related
In our project team we applications for micro-controller targets with arm-none-eabi-gcc. For running our testrunner we compile using the native cc compiler.
In our project team most use a Linux os, but some us a windows os (for reasons). The issue we run into is that we use the C11 keyword _Static_assert. When compiling on Linux it works, but when compiling under windows we get the following error: error LNK2019: unresolved external symbol _Static_assert referenced in function {}
This is due to the reason that the default MSVC compiler implements ANSI C89 which doesn't support the _Static_assert symbol. MSVC - C standards support
It also specifies that adding the /std:c11 or /std:c17 compiler options enable the support for _Static_assert.
We already have enabled --enable_platform_specific_config for other reasons.
Simply adding the build:windows --copt="/std:c11" to the .bazelrc solves the issue but also breaks the normal application build because arm-none-eabi-gcc compiler doesn't support the /std:c11 compiler flag.
Question: How can i add the /std:c11 compiler flag so that it only propagates to the native msvc compiler and not to the rest of my build targets?
When using MSVC for host builds (when building a tool that emits source code which is then #include'd, for example protocol buffer compiler) add build:windows --host_copt="/std:c11". When using MSVC for test builds, add test:windows --host_copt="/std:c11". Don't put it in build:windows --copt because that will apply even when running builds to the target.
I am an absolute Erlang newbie and I wonder if it is possible for rebar to compile .core files using rebar3 compile. According to the documentation : https://www.rebar3.org/docs/commands rebar3 will only compile the .app.src and .erl files. And I can see that when I build my project the .core files are ignored. I would appreciate any help with this. Thanks
How can I load another F# source file (*.fs) into a project? The #load "path/to/file" preprocessor directive only works if the file you're working from is an F# script file or F# interactive.
I think it may have to do with a makefile, am I correct?
EDIT: Also, I'm not using any IDE; just Emacs, and Mono.
If you're compiling manually at the command line, you must list all the files you want the F# compiler to use, in order.
Otherwise, the .NET equivalent to a makefile is MSBuild, and the Mono version of MSBuild is XBuild.
I am using open source C++ library DCMTK from http://dicom.offis.de/dcmtk.php.en.
I have successfully compiled this library on Windows using VC++ IDE, MacOS Xcode, Mac iOS simulator.
But I am not able to compile this library on iOS device as it is ARM based architecture.
DCMTK library compiled very well on Intel architecture.
Now my problem statement is :-
I need to compile this DCMTK C++ library on ARM architecture by cross compilation.
I am using Ubuntu 64 bit machine for cross compilation.
I have installed binaries from GNU ARM tool chain from http://www.gnuarm.com/
I am using GCC toolchain 4.0 binutils-2.16.1, gcc-4.0.2-c-c++, newlib-1.14.0, insight-6.4, TAR BZ2 [65.5MB] binaries for Ubuntu 64 bit machine for ARM cross compilation.
After Installing these binaries on Ubuntu I have set PATH environment variable to
PATH=$PATH/gnu_arm/bin
For configuring the DCMTK C++ library I have run the following command on shell
CC=arm-elf-gcc CXX=arm-elf-g++ AR=arm-elf-ar RANLIB=arm-elf-ranlib ARFLAGS=cruv ./configure –prefix=$home_dicom –target=arm-elf –host=arm-elf –enable-std-includes –disable-threads
It creates a make file properly. Now I am trying to compile the code by using make command, but facing so many compilation errors like :-
1) I tried to compile my first dependent C++ library that is ofstd.
I got error for DIR*, struct dirent, opendir(), closedir() calls.
It includes for these calls, but I did not found any definitions for the above calls in this header file.
2) When I compile another library oflog I got the following errors like
error: nthos was not declared in this scope
error: ntohl was not declared in this scope
error: htons was not declared in this scope
error: htonl was not declared in this scope.
These calls are networking calls and are not defined in any of the header file from GNU ARM tool.
I tried to download the sources of ARM binaries and extracted the tar files and try to copy missing header files to installed GNU ARM on Ubuntu.
For some files it compiles after doing changes to copied header files, and for some again it gives compilation errors.. There is a loop of compilation errors for every file present under DCMTK library as some of the standard header files are missing.
Please suggest if there is any other tool chain available for ARM cross compilation on Ubuntu 64 bit machine.
Or any other good solution apart from this.
Thanks!!!
Amit
There are many areas for problems when it comes to cross compiling. There are three main flags for cross compiling. -host , -target, and -build. The -host flash is the machine in which the resulting binaries will run on. The -build flash is the system in which you will be compiling on. The -target flag is for building libraries that will be used in cross compiling. So if you were to build your own gcc tool chain. So in your case you won't set the target flag as we're not building a tool chain. the -host flag will be arm-elf. And the -build flag will be amd64.
Usually a cross compilation fails if there are inconsistencies between the regular c compiler and the cross compiler. I have compiled several libraries for the avr32 with a toolchain generated by buildroot, but in some cases (socat project for example) it hasn't been possible.
Your host, your target and the CXX flags look ok. I think it is not necessary to put the AR flag (that is the idea with the host and target option).
In other hand, this is an example for the expat libraries for the avr32:
./configure --host=avr32-linux --prefix=/home/juan/builds/build_expat/ CC=avr32-linux-gcc
make; make install
I can recommend you that tries to cross compile from an ia32 architecture. I had several problems with that ubuntu in the past.
After reading this question Is Erlang the C of the clustered computing world? , I am wondering the official Erlang OTP compiles with HiPE?
In other words, when I compile my .erl source with the OTP release R13 (as example), does it produce "object code" BEAM?
Looking at http://www.it.uu.se/research/group/hipe/ , it does not appear that a standalone HiPE compiler is maintained anymore.
By default HiPE is not used to compile OTP. It is known, however, that OTP libraries can be successfully compiled using HiPE with usually some performance boost (though it depends on your application).
When you run a erlc on your .erl file it produces BEAM file, which is NOT compiled to native code with HiPE. To compile an .erl file to native code using HiPE just run erlc +native file.erl.
Standalone HiPE compiler is not maintained anymore, since it was included into core Erlang/OTP distribution.
I think this depends on what options you passed to the configure script when you compiled the Erlang compiler. It certainly can include it but whether it does by default or not is another issue.