What is the difference between make and make -j5? - opencv

I have been trying to include OpenCV extra modules by following the link OpenCV Contrib. After solving several errors obtained during the cmake command, when I did make -j5, it stopped giving error
[ 27%] Built target IlmImf
Makefile:149: recipe for target 'all' failed
make: *** [all] Error 2
When I ran simple make command, it started compiling and making the targets what happens when we make OpenCV in the build directory.
I again then tried make -j5 but this time I received some other error while make again compiled.
I wanted to know what's the differnce between make and make -j5 !!
Thanks in advance for the reply !!

-j [jobs], --jobs[=jobs] Specifies the number of jobs (commands) to run simultaneously. If there is more than one -j option, the last one is effective. If the -j option is given without an argument, make will not limit the number of jobs that can run simultaneously.
This is from man make. Errors are the same, but compilation process can encounter them in different order

Related

Use all cores to make OpenCV 3 [duplicate]

Quick question: what is the compiler flag to allow g++ to spawn multiple instances of itself in order to compile large projects quicker (for example 4 source files at a time for a multi-core CPU)?
You can do this with make - with gnu make it is the -j flag (this will also help on a uniprocessor machine).
For example if you want 4 parallel jobs from make:
make -j 4
You can also run gcc in a pipe with
gcc -pipe
This will pipeline the compile stages, which will also help keep the cores busy.
If you have additional machines available too, you might check out distcc, which will farm compiles out to those as well.
There is no such flag, and having one runs against the Unix philosophy of having each tool perform just one function and perform it well. Spawning compiler processes is conceptually the job of the build system. What you are probably looking for is the -j (jobs) flag to GNU make, a la
make -j4
Or you can use pmake or similar parallel make systems.
People have mentioned make but bjam also supports a similar concept. Using bjam -jx instructs bjam to build up to x concurrent commands.
We use the same build scripts on Windows and Linux and using this option halves our build times on both platforms. Nice.
If using make, issue with -j. From man make:
-j [jobs], --jobs[=jobs]
Specifies the number of jobs (commands) to run simultaneously.
If there is more than one -j option, the last one is effective.
If the -j option is given without an argument, make will not limit the
number of jobs that can run simultaneously.
And most notably, if you want to script or identify the number of cores you have available (depending on your environment, and if you run in many environments, this can change a lot) you may use ubiquitous Python function cpu_count():
https://docs.python.org/3/library/multiprocessing.html#multiprocessing.cpu_count
Like this:
make -j $(python3 -c 'import multiprocessing as mp; print(int(mp.cpu_count() * 1.5))')
If you're asking why 1.5 I'll quote user artless-noise in a comment above:
The 1.5 number is because of the noted I/O bound problem. It is a rule of thumb. About 1/3 of the jobs will be waiting for I/O, so the remaining jobs will be using the available cores. A number greater than the cores is better and you could even go as high as 2x.
make will do this for you. Investigate the -j and -l switches in the man page. I don't think g++ is parallelizable.
distcc can also be used to distribute compiles not only on the current machine, but also on other machines in a farm that have distcc installed.
I'm not sure about g++, but if you're using GNU Make then "make -j N" (where N is the number of threads make can create) will allow make to run multple g++ jobs at the same time (so long as the files do not depend on each other).
GNU parallel
I was making a synthetic compilation benchmark and couldn't be bothered to write a Makefile, so I used:
sudo apt-get install parallel
ls | grep -E '\.c$' | parallel -t --will-cite "gcc -c -o '{.}.o' '{}'"
Explanation:
{.} takes the input argument and removes its extension
-t prints out the commands being run to give us an idea of progress
--will-cite removes the request to cite the software if you publish results using it...
parallel is so convenient that I could even do a timestamp check myself:
ls | grep -E '\.c$' | parallel -t --will-cite "\
if ! [ -f '{.}.o' ] || [ '{}' -nt '{.}.o' ]; then
gcc -c -o '{.}.o' '{}'
fi
"
xargs -P can also run jobs in parallel, but it is a bit less convenient to do the extension manipulation or run multiple commands with it: Calling multiple commands through xargs
Parallel linking was asked at: Can gcc use multiple cores when linking?
TODO: I think I read somewhere that compilation can be reduced to matrix multiplication, so maybe it is also possible to speed up single file compilation for large files. But I can't find a reference now.
Tested in Ubuntu 18.10.

Is TelosB mote compatible with Contiki-OS?

I found exp5438 and z1 motes, which have TI MSP430x as a MCU, in the Contiki code tree, and we know that TI MSP430 is the TelosB mote's microcontroller.
I would like to know if TelosB motes are compatible with Contiki ?
The telosB mote is compatible with Contiki OS, in fact I am using them with Contiki. To program them, in case you are using Instant Contiki, you will need to install the GCC for the MSP430 micro controller. You can use the next command:
sudo apt-get install gcc-msp430
On the other hand, I think to solve the problem of your answer I think you just need to be root. So try the next:
sudo -s
make TARGET=sky hello-world.upload
I hope that help you out.
Cheers!
currently I am using telosb to run contiki applications. I followed the official site tutorial and apparently if u do make TARGET=sky it compiles the source files. However, doing make TARGET=sky hello-world.upload does not work. Shows
make sky-reset sky-upload
make[1]: Entering directory `/home/user/contiki-2.6/examples/hello-world'
make -k -j 1 sky-reset-sequence
make[2]: Entering directory `/home/user/contiki-2.6/examples/hello-world'
Done
make[2]: Leaving directory `/home/user/contiki-2.6/examples/hello-world'
make -j 1 sky-upload-sequence
make[2]: Entering directory `/home/user/contiki-2.6/examples/hello-world'
Done
make[2]: Leaving directory `/home/user/contiki-2.6/examples/hello-world'
make[1]: Leaving directory `/home/user/contiki-2.6/examples/hello-world'
rm hello-world.ihex
which according to the official site tutorial means that the board is not connected. I am very certain it is connected. Also, make login never shows anything for me since the previous command didnt work.
Eventually, a friend of mine discovered a way to flash contiki applications into telosb. However, you need TinyOS development environment in your Instant Contiki. You can find information on setting up TinyOS environment in Ubuntu on www.eetutorials.com.
This doesn't seem like a proper way of doing it but well so far it works for me when running simple applications
Step 1:
Compile your applications by doing:
make TARGET=sky application-name
Step 2:
msp430-objcopy application-name.sky -O ihex application-name.ihex
sudo tos-bsl --telosb -c /dev/ttyUSB0 -r -e -I -p application-name.ihex
However, make login still doesn't show anything hence I have been seeing my printf outputs
via Serial Port Terminal application which need to be installed. My guess is that contiki supports sky but not really for telosb? I am no expert and I can't tell the difference between the 2 boards. However, hope this information help and hope a contiki expert can further clarify on this.
Cheers
telosb mote is the same as a tmote sky or sky. The name is all the same platform.
I dont know from which vendor you have the board, but they have to work.
I am also using sky motes with contiki and i had no complications from the beginning.
Try to use the code in the following site: Unreadable output results when typing "make login"
This will print a message every second.
PS: Try to update your question if you found more information, dont add an answer since it confuses people.

Package Makefile error in OpenWRT Attitude adjustment

I am changing the question as I could get over the initial issue.
I am having the following define in my package//Makefile
PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
define Build/Compile
$(MAKE) -s -C $(PKG_BUILD_DIR)
endef
$(eval $(call BuildPackage,<Module-name>))
I am trying to get a custom kernel module to compile with OpenWRT.
I am building using the command make package/"Module_name"/compile ;
Make never succeeds and it comes out saying :
make[2]: Nothing to be done for `compile'.
Why is make coming out doing nothing eventhough rule exists ? Any suggestion to get over this error would be helpful.
Please first run
make menuconfig
and check if the module your are trying to compile is selected in the OpenWRT configuration.
If the module is selected then it will be built as you are trying to do.

Error installing Last Value Cache pluggable exchange

I am trying to install the LVC exchange to my RabbitMQ broker. I downloaded the public umbrella and ran make as per the instructions on the RabbitMQ website.
Next I downloaded the LVC pluggin and followed their instructions. However make didn't work so I am unable to continue. Has anyone managed to install it, if so please can you give me full directions, from the very beginning. Otherwise if anyone one has any ideas as to what I am doing wrong then please let me know. Below is the output from make.
ERL_LIBS=./build/dep-apps erlc -Wall +debug_info -I ./include -pa ebin -o ebin src/rabbit_exchange_type_lvc.erl
src/rabbit_exchange_type_lvc.erl:11: can't find include lib "rabbit_common/include/rabbit_exchange_type_spec.hrl"
make: * [ebin/rabbit_exchange_type_lvc.beam] Error 1
I have the same problem trying to install the Recent History Exchange.
The solution was to this to remove the include line about rabbit_exchange_type_spec. I found this information here. Tried it and and ran make again. The make finished and I was able to enable the plugin after moving it to the correct location.

Nmake standard output to file

I'm looking for a way to write the standard output of my nmake call to a specified file. I tried something like "nmake target > file.log", but this won't work. Moreover I call multiple nmakes from within my MAKEFILE and may use multiple log-files to keep track of the output. I've only found the nmake option to write errors to a file but what's about the standard output.
Is there a simple way to do that (in Windows)?
#Cheeso
I've tried to built simple example and noticed that it doesn't work for me because the MAKEFILE must running in elevated mode. Consider a makefile like this:
default:
REM Test
and a batch-file like this:
cd /d "%~dp0"
nmake output.log
pause
When running the batch-file as administrator it doesn't redirect the stdout to my file and returns an error.
jom is really picky, and it's made based on nmake. Since that's the case, we're probably dealing with the same pickiness.
This works : jom -j 8 >> build.log
While this doesn't work : jom -j 8>>build.log
Add some whitespace, and you should be good to go. This was incredibly annoying for me too with Qt 5.6.1-1. I even tried using Powershell transcripts, but that ended up being a complete bust.

Resources