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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T05:09:13+00:00 2026-05-18T05:09:13+00:00

My Qt project links to a library that is linux-only. When the project is

  • 0

My Qt project links to a library that is linux-only. When the project is run under linux, I wish to have a signal fired on an event using a type defined in that library. A complication that I have, though, is that the project must also build in Windows. Obviously, this signal and the slot catching it wouldn’t exist in Windows, and that’s fine. I am, however, finding issues with Qt’s moc tool failing to recognize the existence of an #ifdef __linux__ around the code that emits the signal. My code looks like this:

[SomeFile.h]

#ifdef __linux__
signals:
  void SomeSignal(SomeTypeDefinedInTheLinuxLibrary);
#endif

[SomeFile.cpp]

#ifdef __linux__
  emit SomeSignal(someObject);
#endif

When I attempt to compile this with g++, I get the error:
SomeFile.cpp:(.text+0x858c): undefined reference to SomeFile::SomeSignal(SomeTypeDefinedInTheLinuxLibrary)

Any ideas how to get moc and #ifdefs to play well together?

  • 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-18T05:09:13+00:00Added an answer on May 18, 2026 at 5:09 am

    A much better solution is to always provide the signal and just comment out the code that fires it on Windows. That way, the public API is the same on all platforms.

    [EDIT] The moc tool is really dumb. It doesn’t actually understand the code; instead it just reacts on certain patterns. That’s why it ignores the #ifdef.

    To solve the issue, wrap the type or use #ifndef __linux__ and define your own dummy type in there so it compiles on Windows. Since the signal won’t be emitted on Windows, the slot will never be used so any type that makes the code compile should be fine.

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

Sidebar

Related Questions

I have a project that contains several submodules, that communicate using some objects that
I am planning my directory structure for a linux/apache/php web project like this: Only
I have a C++ project that due to its directory structure is set up
I have simple console application project for live video streaming using cross-platform libs on
Looking for good project methodologies.Anyone got some good reference links..want to share.
Anyone manage to write code that uses the mysqlclient library? I can get compiling
Is there a built in linux utility that I can use to test a
I've got a library definition in CMake that builds a shared library out of
I got a problem of linking an OpenSSL library into an existing project. Where
I think my problem is that the Visual Studio static library linker hardcodes relative

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.