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 7019189
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:09:02+00:00 2026-05-27T23:09:02+00:00

I am having a serious issue with my DLL in Qt. When I compile

  • 0

I am having a serious issue with my DLL in Qt. When I compile my most recent additions (assertInt() and randomInt()), i get the following compile error

error: function ‘T randomInteger(const T&, const T&)’ definition is marked dllimport

Obviously I can force the program to compile by replacing JECLIBRARYSHARED_EXPORT with Q_DECL_EXPORT but then I would have to change it back to import when using the library. That would be a pain.

Does anyone know why these two particular subroutines are being flagged as DLLIMPORT instead of export? The rest of the library exports as it should. I have defined JECLIBRARYSHARED in my .pro file.

This is the how QtCreator generated the DLL exporting code when i created the DLL project.

JecLibary_global.h

#ifndef JECLIBRARY_GLOBAL_H
#define JECLIBRARY_GLOBAL_H

#include <QtCore/qglobal.h>

#if defined(JECLIBRARY_LIBRARY)
#  define JECLIBRARYSHARED_EXPORT Q_DECL_EXPORT
#else
#  define JECLIBRARYSHARED_EXPORT Q_DECL_IMPORT
#endif

#endif // JECLIBRARY_GLOBAL_H

JecMath.h

#ifndef JECMATH_H
#define JECMATH_H

#include <QList>
#include <QTime>

#include <JecLibrary_global.h>
#include <JecUtils.h>

template<class T>
T JECLIBRARYSHARED_EXPORT randomInteger(const T& max, const T& min = 0)
{
    assertInteger(max);

    qsrand((uint)QTime::currentTime().msec());
    return qrand() % ((max + 1) - min) + min;
}

JecUtils.h

#include <typeinfo>

#include <QString>
#include <QRegExp>

#include <JecLibrary_global.h>

template<class T>
void JECLIBRARYSHARED_EXPORT assertInteger(const T& var)
{
    static_assert(sizeof(T) != sizeof(bool) ||
            sizeof(T) != sizeof(char) ||
            sizeof(T) != sizeof(short) ||
            sizeof(T) != sizeof(int) ||
            sizeof(T) != sizeof(long), "T is not an integer.");
}

The only things different about these subroutine is that they are templated. I’m also wondering if there is a dependency issue because JecMath.h includes JecUtil.h so JecLibrary_global.h gets included twice but I thought that the #Ifndef would protect against that. I’ll try some experimenting and post any results i may get.

Any help will be appreciated. Thank you,

Jec

  • 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-05-27T23:09:03+00:00Added an answer on May 27, 2026 at 11:09 pm

    How are you going to import or export template function? Template function has no any code to export. Caller first provides actual definition for template function, then code for that actual definition is generated.

    So, you cannot export

    template<typename T>void foo(T param);
    

    When you use this function as foo(intValue); you provide actual definition for the template and then code for void foo(int param) is generated, but there is no any way to generate code until you know what is typename T actually.

    Actually as the function is defined in header, you shouldn’t mark it neither dllexport nor dllimport

    Also you cannot dllimport a function, that has a defenition (not declaration), obviously.

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

Sidebar

Related Questions

I am having serious trouble with trying to get all the forms on a
I'm having serious trouble figuring out what is making certain function calls ambiguous and
I'm having a serious issue with Internet Explorer caching results from a JQuery Ajax
I am having some serious issue while loading Staging Table from Data Store. My
I'm having serious trouble debugging the following Matlab Warning: Warning: Ignoring excess mask dialog
I am having a serious issue with UITableView reloadData method. I have a UIViewController
I'm having a serious issue when trying to display a FlareCanvas within my application.
I am having a serious issue with my app. I use the permission android.permission.ACCESS_COARSE_LOCATION
I am having a serious issue with one application developed in CI. Currently my
I´m having serious trouble to get Django to work with my Apache/mod_wsgi installation accessing

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.