Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8746761
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:14:43+00:00 2026-06-13T12:14:43+00:00

Loading a QImage object from a jpeg file fails when the application is linked

  • 0

Loading a QImage object from a jpeg file fails when the application is linked against OpenCV 2.3 or 2.4. The program segfaults when I attempt to create a QImage from a jpeg file

QImage( "some-jpeg.jpg" )

This is only true if the application is linked against opencv’s highgui library.

I’m building on Ubuntu 12.04 with OpenCV 2.4 and Qt 4.8.1

Does anyone know why this is happening and how I can work around this? My research project uses OpenCV’s image processing code and the frontend depends on Qt.

I’ve put a bug report in to Qt (https://bugreports.qt-project.org/browse/QTBUG-27032). I tried at OpenCV, but their registration project is borked or something, because it accepted registration info, but then denies attempts to log in…

qt-cv-jpg-test.pro

QT += core gui

TARGET = qt-cv-jpg-test
TEMPLATE = app

INCLUDEPATH += /usr/local/include
LIBS += -L/usr/local/lib -lopencv_highgui -lopencv_core

SOURCES += main.cpp

main.cpp

#include <QImage>
#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"

int main(int argc, char *argv[])
{
    QString fileName = "some-jpeg.jpg";
    cv::Mat cvImage = cv::imread( fileName.toStdString() );
    QImage qtImage( fileName );
    return 0;
}

The program segfaults, but here is the stack:

0   jpeg_CreateDecompress   /usr/local/lib/libopencv_highgui.so.2.4 0   0x7ffff7ae55fc  
1   ??  /usr/lib/x86_64-linux-gnu/qt4/plugins/imageformats/libqjpeg.so  0   0x7ffff0549ee7  
2   ??  /usr/lib/x86_64-linux-gnu/qt4/plugins/imageformats/libqjpeg.so  0   0x7ffff054a18f  
3   QImageReader::read(QImage*) /usr/lib/x86_64-linux-gnu/libQtGui.so.4 0   0x7ffff6c3f0c8  
4   QImageReader::read()    /usr/lib/x86_64-linux-gnu/libQtGui.so.4 0   0x7ffff6c3f6f7  
5   QImage::load(QString const&, char const*)   /usr/lib/x86_64-linux-gnu/libQtGui.so.4 0   0x7ffff6c348dc  
6   QImage::QImage(QString const&, char const*) /usr/lib/x86_64-linux-gnu/libQtGui.so.4 0   0x7ffff6c34a75  
7   main    main.cpp    9   0x400d10

I don’t really know why an opencv method is showing up at the bottom of the stack. I built opencv telling it to use the libjpeg on the file system. I have both libjepg 6.2 and libjpeg8 installed on the system.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T12:14:44+00:00Added an answer on June 13, 2026 at 12:14 pm

    I got the same error – and we found the problem yesterday evening.

    I assume you had build OpenCV with the BUILD_JPEG or the OPENCV_BUILD_3RDPARTY_LIBS flag. Furthermore, OpenCV is installed in /usr/local/lib. In this case, OpenCV is built with its own libjpeg, which is statically linked into the opencv_highgui library.

    So, when you’re creating a QImage and you have linked the opencv_highgui to your project/application, the linker will search for the jpeg_CreateDecompress function (the function is internally used by Qt), which it first will find in the opencv_highgui lib. And there should be some incompatibility between the version which is expected by Qt (in Ubuntu 12.04 its the libjpeg8) and OpenCV’s shipped one (libjpeg62).

    So, there exist an easy solution 😉 – build OpenCV without it’s shipped libjpeg (BUILD_JPEG=OFF) and use the systems shared library.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Loading a CGImage or NSImage from a file using a standard image format (jpeg,
while loading getfptex(got it from CTAN) batch file ,when i'm extracting this batch file
I´m loading data from MySQL DB into Java application. How to define column type?
C# - Loading image from file resource in different assembly I have a PNG
Loading an external php file with jquery is actually easy. I simply use the
Loading multiple child forms from a loop into a MDI parent form. They are
When loading one view in to another with jquery i do that. In file
Im loading an entity 'Member' from its id in route data. [ListItemsForMembershipType(true)] public ActionResult
When loading Mootools More from my server, Android Stock Browser (froyo 2.2 and gingerbread
When loading tables from SAS to Teradata, SAS loads the data (usually using the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.