How to generate two different version source code at the same time - build

I'm using QtCreator 2.8.0 qt 4.8.1
I have a program but two versions of it and have a variable to control.like that:
if(var==version1){/*...*/}else{/*...*/}
In the main function:
var=version1
Some of the function are shared.It's boring build everyone of them,How can I build both of them at the same time?
I've read this one .

In your Makefile have a target setup like this:
both: version1 version2
version1:
# commands to compile version 1
version2:
# commands to compile version 2
then you can just do
% make both
Technically this is called making a dependency, but it gives the effect you appear to want.

Related

can't compile or-tools examples on Mac due to "make: *** No rule to make target `run'."

I have installed Google's or-tools on my Mac running 11.1 (Big Sur). When I run make test_cc, I get a long list with different results and also some messenges like ---- Integer programming example with CPLEX ---- Supports for solver CPLEX not linked in.
However, if I try an example from https://developers.google.com/optimization/introduction/cpp, I get the above error (see header) when trying to make and run the program (I have copy pasted the complete program). I have executed the make command with
Death-Star:or-tools me$ make run SOURCE=../Routing/Routing/main.cpp. ls ../Routing/Routing/main.cpp shows the file.
What have I done wrong?
or-tools version is 8.1.8487

Mlton compiler not working (not giving any output)

Installed the MLton compiler on Ubuntu (sudo apt-get install mlton) and had no problems (seemingly) with installation.
When I try to use it (e.g. "mlton test.sml") it sits for a second and then returns nothing. If I try to print something in the file I'm trying to compile, nothing. However, weird part is if I give it bad ML code ("x = 2", without val), it spits out regular errors like "Undefined variable," etc.
I've looked on here, and elsewhere online, and nothing seems to concern what I'm experiencing.
Perhaps I'm just using it wrong?
Thanks in advance.
mlton is a non-interactive compiler; it compiles the program, and that's it. You can run the program later if you want.
So, for example, if test.sml is a valid Standard ML program, then this:
mlton test.sml # compile the program
will compile it and emit a Linux executable file named test. You then run that executable file like this:
./test # run the program
If you want to compile and run the program with a single command, you can use your shell's && feature to run two programs (but only running the second if the first one had succeeded):
mlton test.sml && ./test

C/C++ Cyanogenmod How to compile kernel using different version of toolchain?

I am trying to compile kernel for Cyanogenmod 13. I am getting error
ERROR: modpost: Found 2 section mismatch(es).
To see full details build your kernel with:
'make CONFIG_DEBUG_SECTION_MISMATCH=y'
To build the kernel despite the mismatches, build with:
'make CONFIG_NO_ERROR_ON_MISMATCH=y'
(NOTE: This is not recommended)
I read it here. That i need to compile my kernel using 4.7.
How can i choose the version of toolchain during cyanogenmod build ??
I believe you need to setup gcc version 4.7 and use CC variable to set it as a compiler. E.g. make target CC=/bin/gcc4.7
More information here and here.
Thanks to #nopasara and his valuable comment.
So i did little research further and discovered that the kernel is compatiable with arm-eabi tool chain not arm-linux-androideabi toolchain. So here is the command i used
export PATH=$PATH:~/android/system/prebuilts/gcc/linux-x86/arm/arm-linux-eabi-4.7/bin/ && export ARCH=arm && export SUBARCH=arm && export CROSS_COMPILE=arm-linux-eabi- && make msm8226_defconfig O=~/android/system/out/target/product/E6790/obj/KERNEL_OBJ
and
make O=~/android/system/out/target/product/E6790/obj/KERNEL_OBJ zImage -j4
To do with this Cyanogenmod add following line to your BoardConfig.mk
TARGET_KERNEL_CROSS_COMPILE_PREFIX := arm-eabi-
and either use
export TARGET_LEGACY_GCC_VERSION=4.7
Or edit ~/android/system/build/core/combo/TARGET_linux-arm.mk and set version in
$(combo_2nd_arch_prefix)TARGET_LEGACY_GCC_VERSION := 4.7

ldc2 vs ldmd2 whats the difference?

I recently installed ldc through hombrew on my Mac and was testing out running a code as a script from the D wiki when I noticed that using ldmd2 to compile my program doesn't also run my program after. Whats the difference then since this is the same behavior as running ldc2.
Heres my program
import std.stdio;
void main()
{
writeln("Hello, world without explicit compilations!");
}
EDIT:
The website states "For small projects it's handy to compile and run in a single step. Most (if not all) compiler packages, contain a tool named rdmd/gdmd/ldmd or similar. For instructional purposes we'll call it rdmd." What im taking from this is it depends on which compiler your using but in the case of ldc I should be using ldmd.
ldmd2 is just a wrapper script for ldc2 which converts argument formats from dmd style over to ldc style.
So it does exactly the same thing, just some options and flags on the compile command line have different names and stuff like that.
The link is talking about rdmd which is a separate program that recursively grabs dependencies, compiles, and automatically runs. rdmd works on top of the compiler and might have been packaged with it or might need to be downloaded separately.
Its source lives here: https://github.com/D-Programming-Language/tools/blob/master/rdmd.d
and it is compatible with ldmd2's option formats.

Can not compile to a native executable with Clozure CL on OS X 10.10 Yosemite

I have created a simple hello world (hello.lisp) ,code:
(defun main ()
(format t "Hello,World"))
, program to test CCL's native executable compilation. I proceed to compile and load buffer from the CCL GUI (using version Clozure Common Lisp Version 1.10-store-r16266 (DarwinX8664)).
When i test it:
? (main)
Hello,World
NIL
?
It finds the main function. When i proceed to compile it with: (save-application "/tmp/h" :toplevel-function #'main :prepend-kernel t), it proceeds with the operation and CCL exits.
The file is created and is arround ~56MB. When i try to run it though I get the following output:
Error: There is no applicable method for the generic function:
#
when called with arguments:
(# :NOTE-CURRENT-PACKAGE #)
While executing: #, in process toplevel(6).
Error: There is no applicable method for the generic function:
#
when called with arguments:
(# :BREAK-OPTIONS-STRING T)
While executing: #, in process toplevel(6).
Error: There is no applicable method for the generic function:
#
when called with arguments:
(# :BREAK-OPTIONS-STRING T)
While executing: #, in process toplevel(6).
Error: There is no applicable method for the generic function:
#
when called with arguments:
And the errors proceed. What do I do wrong? Is it a bug?
Thank you
I found the keywords :note-current-package and :break-options-string in the cocoa-ide of the sources. Since prepend-kernel t prepends the kernel that was used in the current session, it seems that you would include the cocoa-ide startup in your application. However, the methods dispatching on those keywords only dispatch on ´ns-application`s, which your new application seems not to be.
The solution might be to prepend a kernel without cocoa-ide, either by loading your code into a non-GUI image, or by using the pathname of such a kernel for the :prepend-kernel argument.
To create executables of Clozure CL on Mac OS X:
for non-GUI applications, you need to install Clozure CL from the repository: Installing Clozure CL. You need to download CCL from there. This version comes with an executable Lisp (kernel + image), which hasn't the GUI loaded.
for GUI applications you need to use the Application Builder. The corresponding function is ccl::build-application. GUI applications on Mac OS X need some infrastructure, which is created then. Note that CCL comes with a example application in ccl/examples/cocoa/currency-converter/. Personally I would also prefer to use CCL from the repository - it's usually a bit newer than the version in the Mac Application store.