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

  • Home
  • SEARCH
  • 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 7871745
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T01:59:55+00:00 2026-06-03T01:59:55+00:00

I have a function to convert from one image representation ( MyImage ) to

  • 0

I have a function to convert from one image representation (MyImage) to a QImage, and I decided it would be tidier to dedicate a namespace to functions that interface in this manner. I previously had this function directly in the class representing my main QMainWindow.

So, I created a file MyFormatToQtInterfacing.h which looks as follows:

#include <QtGui/QMainWindow>
#include <qlabel.h>

namespace MyFormatToQtInterfacing
{
    // These functions below convert a cv::Mat to a QImage.
    // Adapted from http://stackoverflow.com/questions/5026965/how-to-convert-an-opencv-cvmat-to-qimage
    // The grayscale ones seem to be inverted.  Look into this later.

    QImage MyImage2QImage(const MyImage &src) { //snip };
};

I then call the function from this new namespace, as you would expect, and I get the following linker error:

1>main.obj : error LNK2005: “class QImage _cdecl
MyFormatToQtInterfacing::Mat2QImage(class MyImage2QImage const &)”
(?MyImage2QImage@MyFormatToQtInterfacing@@YA?AVQImage@@ABV?$Mat
@V?$Vec@E$02@cv@@@cv@@@Z)
already defined in moc_Tracker.obj

1>Tracker.obj : error LNK2005: “class QImage _cdecl
MyFormatToQtInterfacing::MyImage2QImage(class MyImage2QImage const &)”
(?MyImage2QImage@MyFormatToQtInterfacing@@YA?AVQImage@@ABV?$Mat
@V?$Vec@E$02@cv@@@cv@@@Z)
already defined in moc_Tracker.obj

1>C:\Projects\Tracker\Tracker.exe : fatal error LNK1169: one or more
multiply defined symbols found

I’ve also been subbing out MyImage with OpenCV matrices and getting the same problem. Why is this happening and how can I resolve it?

  • 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-03T01:59:57+00:00Added an answer on June 3, 2026 at 1:59 am

    You are falling afoul of the one definition rule. You are not allowed to define non inline or non template functions in headers that are included in multiple compilation units. Move your definition to a .cpp file or mark the function as inline.

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

Sidebar

Related Questions

I have used a convert function in one of my Queries Select * from
I'm trying to create a function to read Morse code from one file, convert
How does one convert an image from one color profile to another (screen to
I have a function that convert ticks to time_t format long ticks = DateTime.Now.Ticks;
i have a function to convert into NSDate by using NSDateFormatter . +(NSDate*)getDateFromCurrentTimestamp:(NSString*)currentTimestamp{ //
I have my class public function convert( $title ) { $nameout = strtolower( $title
I have used this function to convert string to bits. def a2bits(chars): return bin(reduce(lambda
I have this function in C# to convert a little endian byte array to
I need to convert the function path::combine(path1, path2). Please help me if you have
How to convert Ruby Hash to C# Dictionary? Do we have any built-in function...or

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.