OpenCV Compilation error on TX1 (JetPack L4T 2.2)


Is anybody encountering any error on the compilation of opencv after flashing to JetPack L4T 2.2?

I am unable to compile opencv-3.1.0 on my Jetson TX1 after flashing JetPack L4T 2.2.

I’m having the following error after make -j4 install (process stopped at 45%):
cc+: internal compiler error: Segmentation fault (program cc1plus)

Previously, I managed to compile opencv using JetPack L4T 2.1 using the following method (link below).

Thank you.

Same issue. Re-running make seems to continue to make progress (but then it happens again).

I have had this before too. Usually watching the memory usage shows that it is capping out and crashing!

FIXES (For me):

  1. Rerun it a lot and slog your way onwards! (This only sometimes works)
  2. Don't use -j4, use -j1 or -j2. This will be slower but you won't run out of memory!

Hi RNZNobody,

Thank you for the suggestion.

Don’t use -j4, use -j1 or -j2. This will be slower but you won’t run out of memory!

I have tried to use -j1 or -j2, but it doesn’t seem to work.

@charlyn, sorry, then I am also stuck for options! For me (with compiling PCL 1.8 I had this sometimes even on -j1, but it did progress… slowly).

Otherwise cross compile? I have seen the odd thing here or there and am currently experimenting cross compiling PCL (rather large project). I’ve battled through getting cmake to work with a toolchain.cmake file I made… stuck with the assembler throwing a hissy fit though… I’m going to make a new thread re this.

JetPack 2.2 comes with OpenCV 2.4.13. Perhaps you could use this version instead of 3.1.0?

I am getting the same error. I wanted to access the camera on board adn I have L4T v24 but I’m unable to do so using C++. I read on the forums that OpenCV3.1 is able to read the camera using


I have tried compiling several times but getting the compiler error.

The error looks like this:

c++: internal compiler error: Segmentation fault (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
make[2]: *** [modules/ocl/CMakeFiles/opencv_ocl.dir/src/cl_runtime/cl_runtime.cpp.o] Error 4
make[2]: *** Waiting for unfinished jobs....
make: *** [all] Error 2

I tried reading about this error and found this thread on a forum:

The post suggests to run the following commands:

fallocate -l 3072m /var/spool/swap
mkswap /var/spool/swap
swapon /var/spool/swap

But, apparently, the swapon command is not implemented on the TX1 due to some security issue.

Does anyone have any suggestions?


Thank you for your reply. I think cross compile would the last option that I would choose.

Thank you for your suggestion. I have tried several version of opencv-2.4.x using L4T 2.1 but it seems like as if it doesn’t support using external USB camera. In the end, I only managed to access to my external USB camera via opencv-3.1.0.

The swap issue isn’t actually about security. It just means the feature was not enabled during this particular kernel compile. The part which makes this a bit more complicated is that many features can be built as a module for use with the existing kernel, but this feature must be integrated…module format install isn’t possible.

Had a module format been available, one would build just the module and copy it to the right place. With an integrated feature change you need to build the entire kernel and install that plus the modules using a different CONFIG_LOCALVERSION (this is part of “uname -r”, it helps determine where modules are searched for).

Same issue here.

c++: internal compiler error: Segmentation fault (program cc1plus)

stop at [37%]

Don’t know if this will be relevant or not, but there is a version 4.8 compiler within the driver package documents “baggage” subdirectory. You might try that compiler as a workaround if you are cross-compiling, or perhaps one the Linaro 5.x series cross-compilers.

In case this is useful to anyone, because we’ve been hitting internal compiler errors in other packages, to work around this issue we’ve been upgrading to GCC6 in the following manner:

sudo apt-get -y update

# Enable Trusty Universe packages. Enable test packages for gcc6
sudo add-apt-repository "deb trusty universe"
sudo add-apt-repository "deb trusty-updates universe"
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test

sudo apt-get -y update
sudo apt-get -y dist-upgrade
sudo apt-get -y autoremove
sudo apt-get -y clean
sudo apt-get -y autoclean

# Switch from gcc 4.8 to gcc6
sudo apt-get -y install gcc-6 g++-6
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 50 --slave /usr/bin/g++ g++ /usr/bin/g++-4.8
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-6 100 --slave /usr/bin/g++ g++ /usr/bin/g++-6
sudo update-alternatives --config gcc

We have not hit any internal compiler issues with GCC6, (I believe this issue was addressed was addressed as far back as GCC4.9, however, as long as you are upgrading, GCC6 is the latest at present.)


Hi Mark

your solution is effective to install gcc 6.0 and thaught me how to use update-alternatives.

Unfortunately, OpenCV 3.1 Makefiles have some problems in dealing with gcc 6.0. There is a workaround for that, see here

Once you solve that, you will notice that the preinstalled CUDA headers include a nice #error in case gcc version is higher than 4.9

Turning #error in #warning leads to mayhem.

So, personally, still not able to compile.