Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Linker error while accessing static member funtion of QString with /GZ compiler option
Forum Updated to NodeBB v4.3 + New Features

Linker error while accessing static member funtion of QString with /GZ compiler option

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 1.8k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    ramanujam
    wrote on last edited by
    #1

    Hi,

    I am facing a problem when linking my project with /GZ compiler option.

    I followed below steps

    1. Created a shared library to include QtCore modules
    2. included QtCore in my cpp file and added QString test = QString::number(5000); to convert number into a QString.
    3. Then added the
      QMAKE_CFLAGS += /Gz
      QMAKE_CXXFLAGS += /Gz
      into the .pro file
    4. Rebuild entire project

    There are linker errors for these QString.
    error LNK2019: unresolved external symbol "__declspec(dllimport) public: static class QString __stdcall QString::number(int,int)" (_imp?number@QString@@SG?AV1@HH@Z) referenced in function "void __stdcall function(void)" (?function@@YGXXZ)

    If I remove above compiler option /GZ from a .pro file it links successfully.
    My observation is accessing all static member functions of a class are giving linker error with this compiler option.
    For Example:
    quint64 g_ulCurrentPID = QCoreApplication::applicationPid();
    Also my project settings include "UNICODE" and "No (/Zc:wchar_t-)". I tried with "treat _wchar_t as default Built-in Type" as Yes. Still I am facing the same problem.

    Could you please help to solve this linker error

    Thanks & Regards,
    Ramanujam

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      Just guessing, but perhaps you should compile Qt itself with this option too for this to work?

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved