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. QMAKE_EXTRA_COMPILERS adds file to OBJECTS
Forum Updated to NodeBB v4.3 + New Features

QMAKE_EXTRA_COMPILERS adds file to OBJECTS

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 230 Views 2 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
    Redman
    wrote on last edited by Redman
    #1

    I have following .pro file

    ...
    # Rename <Class>.rep to rep_<Class>_source.h for correct output filename and add <Class>.rep to C_REP_REPLICA for replica creation
    defineReplace(addToReplica) {
        # Add <Class>.rep to C_REPC_REPLICA for replica generation
        C_REPC_REPLICA *= $$1
    
    
        FILENAME_FULL = $$basename(1)
        FILENAME_SPLIT = $$split(FILENAME_FULL, .)
        CLASSNAME = $$member(FILENAME_SPLIT, 0)
        CLASSNAME_JOINED = $$join(CLASSNAME,,rep_,_source.h)
        return("$$FILENAME_FULL")
    }
    
    C_REPC_SOURCE += \
        ExampleClass/ExampleClass.rep
    
    # Build rep_class_source.h with customized repc
    c_repc_source.input = C_REPC_SOURCE
    c_repc_source.commands = $$OUT_ROOT/bin/repc.exe -o source -I C:/Dev/Qt/6.6.1/msvc2019_64/include -I C:/Dev/Qt/6.6.1/msvc2019_64/include/QtRemoteObjects -I C:/Dev/Qt/6.6.1/msvc2019_64/include -I C:/Dev/Qt/6.6.1/msvc2019_64/include/QtRemoteObjects  ${QMAKE_FILE_NAME} rep_${QMAKE_FILE_BASE}_source.h
    c_repc_source.output_function = addToReplica
    QMAKE_EXTRA_COMPILERS += c_repc_source
    ...
    

    which results in following Makefile

    ...
    SOURCES       = C:\Dev\project\src\Util\tests\tst_Ro\tst_Ro.cpp \
    		C:\Dev\project\src\Util\tests\tst_Ro\ExampleClass\ExampleClass.cpp \
    		C:\Dev\project\src\Util\tests\tst_Ro\RoTest\RoReceiverTest.cpp moc_ExampleClass.cpp \
    		moc_RoReceiverTest.cpp
    OBJECTS       = ExampleClass.rep \ <------- REMOVE THIS
    		tst_Ro.obj \
    		ExampleClass.obj \
    		RoReceiverTest.obj \
    		moc_ExampleClass.obj \
    		moc_RoReceiverTest.obj
    ...
    

    When the linker is invoked it fails because of the wrongly added ExampleClass.rep to the OBJECTS variable.

    I tried it with QMAKE_PRE_LINK but this variable only takes a command as input. I tried by passing a replaceFunction which does something like this

        # Remove Class.rep from objects files to prevent linker error
        myObjectFileList = $$files($$OUT_PWD/*.o)
        myObjectFileList-= $$1
    

    Which did not work because the reason stated in the previous sentence.

    Is there any way to remove that value from OBJECTS before linker gets invoked?

    SGaistS 1 Reply Last reply
    0
    • R Redman

      I have following .pro file

      ...
      # Rename <Class>.rep to rep_<Class>_source.h for correct output filename and add <Class>.rep to C_REP_REPLICA for replica creation
      defineReplace(addToReplica) {
          # Add <Class>.rep to C_REPC_REPLICA for replica generation
          C_REPC_REPLICA *= $$1
      
      
          FILENAME_FULL = $$basename(1)
          FILENAME_SPLIT = $$split(FILENAME_FULL, .)
          CLASSNAME = $$member(FILENAME_SPLIT, 0)
          CLASSNAME_JOINED = $$join(CLASSNAME,,rep_,_source.h)
          return("$$FILENAME_FULL")
      }
      
      C_REPC_SOURCE += \
          ExampleClass/ExampleClass.rep
      
      # Build rep_class_source.h with customized repc
      c_repc_source.input = C_REPC_SOURCE
      c_repc_source.commands = $$OUT_ROOT/bin/repc.exe -o source -I C:/Dev/Qt/6.6.1/msvc2019_64/include -I C:/Dev/Qt/6.6.1/msvc2019_64/include/QtRemoteObjects -I C:/Dev/Qt/6.6.1/msvc2019_64/include -I C:/Dev/Qt/6.6.1/msvc2019_64/include/QtRemoteObjects  ${QMAKE_FILE_NAME} rep_${QMAKE_FILE_BASE}_source.h
      c_repc_source.output_function = addToReplica
      QMAKE_EXTRA_COMPILERS += c_repc_source
      ...
      

      which results in following Makefile

      ...
      SOURCES       = C:\Dev\project\src\Util\tests\tst_Ro\tst_Ro.cpp \
      		C:\Dev\project\src\Util\tests\tst_Ro\ExampleClass\ExampleClass.cpp \
      		C:\Dev\project\src\Util\tests\tst_Ro\RoTest\RoReceiverTest.cpp moc_ExampleClass.cpp \
      		moc_RoReceiverTest.cpp
      OBJECTS       = ExampleClass.rep \ <------- REMOVE THIS
      		tst_Ro.obj \
      		ExampleClass.obj \
      		RoReceiverTest.obj \
      		moc_ExampleClass.obj \
      		moc_RoReceiverTest.obj
      ...
      

      When the linker is invoked it fails because of the wrongly added ExampleClass.rep to the OBJECTS variable.

      I tried it with QMAKE_PRE_LINK but this variable only takes a command as input. I tried by passing a replaceFunction which does something like this

          # Remove Class.rep from objects files to prevent linker error
          myObjectFileList = $$files($$OUT_PWD/*.o)
          myObjectFileList-= $$1
      

      Which did not work because the reason stated in the previous sentence.

      Is there any way to remove that value from OBJECTS before linker gets invoked?

      SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Based on the qmake Adding Compilers chapter of Qt's documentation, you are missing c_repc_source.output.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      C 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        Based on the qmake Adding Compilers chapter of Qt's documentation, you are missing c_repc_source.output.

        C Offline
        C Offline
        ChrisW67
        wrote on last edited by
        #3

        Further to @SGaist's suggestion, there is c_repc_source.variable_out that might be worth a look.

        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