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. Build settings for the compiler
Forum Updated to NodeBB v4.3 + New Features

Build settings for the compiler

Scheduled Pinned Locked Moved Unsolved General and Desktop
14 Posts 5 Posters 5.6k Views 3 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.
  • H Offline
    H Offline
    hmedihe
    wrote on last edited by
    #1

    Hi,

    I am having trouble to find the flags in Qt creator that are equivalent in Visual Studio. Basically, I would like to add the flag (/Wholearchive in visual studio) in QtCreator. The flag /Wholearchive is added in additional options for the linker in the command line for visual studio and I have found a flag (QMAKE_LFLAGS), but it doesn´t work.

    It would be great if someone could help.

    Thanks in advance.

    jsulmJ 1 Reply Last reply
    0
    • H hmedihe

      Hi,

      I am having trouble to find the flags in Qt creator that are equivalent in Visual Studio. Basically, I would like to add the flag (/Wholearchive in visual studio) in QtCreator. The flag /Wholearchive is added in additional options for the linker in the command line for visual studio and I have found a flag (QMAKE_LFLAGS), but it doesn´t work.

      It would be great if someone could help.

      Thanks in advance.

      jsulmJ Online
      jsulmJ Online
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @hmedihe said in Build settings for the compiler:

      QMAKE_LFLAGS

      Can you show how you're using it?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • H Offline
        H Offline
        hmedihe
        wrote on last edited by
        #3

        Hi jsulm,

        You can see it below:
        QMAKE_LFLAGS += --whole-archive -ltf_cc
        QMAKE_LFLAGS += --whole-archive -ltf_cc_framework
        QMAKE_LFLAGS += --whole-archive -ltf_cc_ops
        QMAKE_LFLAGS += --whole-archive -ltf_core_cpu
        QMAKE_LFLAGS += --whole-archive -ltf_core_direct_session
        QMAKE_LFLAGS += --whole-archive -ltf_core_framework
        QMAKE_LFLAGS += --whole-archive -ltf_core_lib
        QMAKE_LFLAGS += --whole-archive -ltf_core_ops
        QMAKE_LFLAGS += --whole-archive -ltf_stream_executor
        QMAKE_LFLAGS += --whole-archive -llibjpeg
        QMAKE_LFLAGS += --whole-archive -ltf_core_kernels

        I run qmake, it compiles ok, but I still I have the same issue.
        Also, I have tried the flag the way is used in visual studio

        QMAKE_LFLAGS += /WHOLEARCHIVE:tf_cc.lib
        QMAKE_LFLAGS += /WHOLEARCHIVE:tf_cc_framework.lib
        QMAKE_LFLAGS += /WHOLEARCHIVE:tf_cc_ops.lib
        QMAKE_LFLAGS += /WHOLEARCHIVE:tf_core_cpu.lib
        QMAKE_LFLAGS += /WHOLEARCHIVE:tf_core_direct_session.lib
        QMAKE_LFLAGS += /WHOLEARCHIVE:tf_core_framework.lib
        QMAKE_LFLAGS += /WHOLEARCHIVE:tf_core_lib.lib
        QMAKE_LFLAGS += /WHOLEARCHIVE:tf_core_ops.lib
        QMAKE_LFLAGS += /WHOLEARCHIVE:tf_stream_executor.lib
        QMAKE_LFLAGS += /WHOLEARCHIVE:tf_core_kernels.lib
        QMAKE_LFLAGS += /WHOLEARCHIVE:libjpeg.lib

        But this last one doesn´t compile correclty.

        Thank you for your help, it is very much appreciated.

        jsulmJ 1 Reply Last reply
        0
        • H hmedihe

          Hi jsulm,

          You can see it below:
          QMAKE_LFLAGS += --whole-archive -ltf_cc
          QMAKE_LFLAGS += --whole-archive -ltf_cc_framework
          QMAKE_LFLAGS += --whole-archive -ltf_cc_ops
          QMAKE_LFLAGS += --whole-archive -ltf_core_cpu
          QMAKE_LFLAGS += --whole-archive -ltf_core_direct_session
          QMAKE_LFLAGS += --whole-archive -ltf_core_framework
          QMAKE_LFLAGS += --whole-archive -ltf_core_lib
          QMAKE_LFLAGS += --whole-archive -ltf_core_ops
          QMAKE_LFLAGS += --whole-archive -ltf_stream_executor
          QMAKE_LFLAGS += --whole-archive -llibjpeg
          QMAKE_LFLAGS += --whole-archive -ltf_core_kernels

          I run qmake, it compiles ok, but I still I have the same issue.
          Also, I have tried the flag the way is used in visual studio

          QMAKE_LFLAGS += /WHOLEARCHIVE:tf_cc.lib
          QMAKE_LFLAGS += /WHOLEARCHIVE:tf_cc_framework.lib
          QMAKE_LFLAGS += /WHOLEARCHIVE:tf_cc_ops.lib
          QMAKE_LFLAGS += /WHOLEARCHIVE:tf_core_cpu.lib
          QMAKE_LFLAGS += /WHOLEARCHIVE:tf_core_direct_session.lib
          QMAKE_LFLAGS += /WHOLEARCHIVE:tf_core_framework.lib
          QMAKE_LFLAGS += /WHOLEARCHIVE:tf_core_lib.lib
          QMAKE_LFLAGS += /WHOLEARCHIVE:tf_core_ops.lib
          QMAKE_LFLAGS += /WHOLEARCHIVE:tf_stream_executor.lib
          QMAKE_LFLAGS += /WHOLEARCHIVE:tf_core_kernels.lib
          QMAKE_LFLAGS += /WHOLEARCHIVE:libjpeg.lib

          But this last one doesn´t compile correclty.

          Thank you for your help, it is very much appreciated.

          jsulmJ Online
          jsulmJ Online
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @hmedihe Actually you should do it like here: https://bugreports.qt.io/browse/QTBUG-28622

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          2
          • H Offline
            H Offline
            hmedihe
            wrote on last edited by
            #5

            Thank you for your help.
            I have change the flag as the link shows and I run qmake and I recompile the project, but I still have the same issue (no session factory registered for the given options...). This issue is fixed in visual studio when I added the flag /wholearchive, however it doesn´twork in Qt. I pasted below the code, could you please check it again? maybe I have missed something.

            LIBS += -Wl, -whole-archive -ltf_cc -Wl, -whole-archive -ltf_cc_framework -Wl, -whole-archive -ltf_cc_ops
            -Wl, -whole-archive -ltf_core_cpu -Wl, -whole-archive -ltf_core_direct_session
            -Wl, -whole-archive -ltf_core_framework -Wl, -whole-archive -ltf_core_kernels
            -Wl, -whole-archive -ltf_core_lib -Wl, -whole-archive -ltf_core_ops
            -Wl, -whole-archive -tf_stream_executor -Wl, -whole-archive -llibjpeg \

            LIBS += -L"C:/tensorflow/tensorflow/contrib/cmake/libs"
            -lprotobuf
            -lzlibstatic
            -lgiflib
            -llibpng12_static
            -llibjpeg
            -llmdb
            -ljsoncpp
            -lfarmhash
            -lfft2d
            -lhighwayhash
            -lsqlite
            -ltf_python_protos_cc
            -llibprotoc
            -ltf_protos_cc
            -ltf_cc
            -ltf_cc_ops
            -ltf_cc_framework
            -ltf_core_cpu
            -ltf_core_direct_session
            -ltf_core_framework
            -ltf_core_kernels
            -ltf_core_lib
            -ltf_core_ops
            -lnsync
            -lsnappy
            -ltf_cc_while_loop
            -ltf_cc_op_gen_main \

            1 Reply Last reply
            0
            • H Offline
              H Offline
              hmedihe
              wrote on last edited by
              #6

              I would like to add that I havo also try with --whole-archive instead -whole-archive

              LIBS += -Wl, -whole-archive -ltf_cc -Wl, -whole-archive -ltf_cc_framework -Wl, -whole-archive -ltf_cc_ops -Wl, -whole-archive -ltf_core_cpu -Wl, -whole-archive -ltf_core_direct_session -Wl, -whole-archive -ltf_core_framework -Wl, -whole-archive -ltf_core_kernels -Wl, -whole-archive -ltf_core_lib -Wl, -whole-archive -ltf_core_ops -Wl, -whole-archive -tf_stream_executor -Wl, -whole-archive -llibjpeg

              1 Reply Last reply
              0
              • H Offline
                H Offline
                hmedihe
                wrote on last edited by
                #7

                Hi again,

                I have realized during the compilation, the flag whole-archive is not recognized. I have the following warning:

                LNK4044 /whole-archive not recognized
                LNK4044 /no-whole-archive not recognized
                This flag is available for the compiler Gcc, but in order to build my app in qt I am using the compiler "Microsoft visual c++ 14". So maybe that is the rason becaus the flag is ignored. Could you give me some advise please?

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  Hi,

                  Then you should use /WHOLEARCHIVE for MSVC

                  If you get errors then please post them.

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

                  1 Reply Last reply
                  0
                  • H Offline
                    H Offline
                    hmedihe
                    wrote on last edited by
                    #9

                    Hi SGaist,

                    When compiling with this option:
                    LIBS += -Wl, --whole-archive -ltf_cc -Wl,--no-whole-archive -Wl, --whole-archive -ltf_cc_framework -Wl,--no-whole-archive
                    -Wl, --whole-archive -ltf_cc_ops -Wl,--no-whole-archive -Wl, --whole-archive -ltf_core_cpu -Wl,--no-whole-archive
                    -Wl, --whole-archive -ltf_core_direct_session -Wl,--no-whole-archive -Wl, --whole-archive -ltf_core_framework -Wl,--no-whole-archive
                    -Wl, --whole-archive -ltf_core_kernels -Wl,--no-whole-archive -Wl, --whole-archive -ltf_core_lib -Wl,--no-whole-archive
                    -Wl, --whole-archive -ltf_core_ops -Wl,--no-whole-archive -Wl, --whole-archive -tf_stream_executor -Wl,--no-whole-archive
                    -Wl, --whole-archive -llibjpeg -Wl,--no-whole-archive

                    I have the following warnings:
                    :-1: warning: LNK4044: opción '/Wl,' not recognized; omitted
                    :-1: warning: LNK4044: opción '/-whole-archive' not recognized; omitted
                    :-1: warning: LNK4044: opción '/Wl,--no-whole-archive'not recognized; omitted

                    So, I have also tried with the flag /wholeArchive as the following:

                    LIBS += /WHOLEARCHIVE:-ltf_cc
                    LIBS += /WHOLEARCHIVE:-ltf_cc_framework
                    LIBS += /WHOLEARCHIVE:-ltf_cc_ops
                    LIBS += /WHOLEARCHIVE:-ltf_core_cpu
                    LIBS += /WHOLEARCHIVE:-ltf_core_direct_session
                    LIBS += /WHOLEARCHIVE:-ltf_core_framework
                    LIBS += /WHOLEARCHIVE:-ltf_core_lib
                    LIBS += /WHOLEARCHIVE:-ltf_core_ops
                    LIBS += /WHOLEARCHIVE:-ltf_stream_executor
                    LIBS += /WHOLEARCHIVE:-ltf_core_kernels
                    LIBS += /WHOLEARCHIVE:-llibjpeg

                    With the option above, the error is:
                    :-1: error: LNK1181: the file cannot be opened '\WHOLEARCHIVE:-ltf_cc.obj'

                    So, finally I have tried.
                    LIBS += /WHOLEARCHIVE:tf_cc.lib
                    LIBS += /WHOLEARCHIVE:tf_cc_framework.lib
                    LIBS += /WHOLEARCHIVE:tf_cc_ops.lib
                    LIBS += /WHOLEARCHIVE:tf_core_cpu.lib
                    LIBS += /WHOLEARCHIVE:tf_core_direct_session.lib
                    LIBS += /WHOLEARCHIVE:tf_core_framework.lib
                    LIBS += /WHOLEARCHIVE:tf_core_lib.lib
                    LIBS += /WHOLEARCHIVE:tf_core_ops.lib
                    LIBS += /WHOLEARCHIVE:tf_stream_executor.lib
                    LIBS += /WHOLEARCHIVE:tf_core_kernels.lib
                    LIBS += /WHOLEARCHIVE:libjpeg.lib

                    But I have the following error:
                    :-1: error: LNK1181: the file cannot be opened '\WHOLEARCHIVE:tf_cc.lib'

                    So, not really sure what is happening, I have tried almost the combinations possibles with different flags to link and register these object files, but none of them works. Any idea would be useful.

                    I really appreciated all your help.

                    Thanks in advance.

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      Because the first version is for gcc/MinGW.

                      And what error do you get when modifying QMAKE_LFLAGS ?

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

                      1 Reply Last reply
                      -1
                      • H Offline
                        H Offline
                        hmedihe
                        wrote on last edited by
                        #11

                        When I run with the flag: QMAKE_LFLAGS

                        QMAKE_LFLAGS += /WHOLEARCHIVE:tf_cc.lib
                        QMAKE_LFLAGS += /WHOLEARCHIVE:tf_cc_framework.lib
                        QMAKE_LFLAGS += /WHOLEARCHIVE:tf_cc_ops.lib
                        QMAKE_LFLAGS += /WHOLEARCHIVE:tf_core_cpu.lib
                        QMAKE_LFLAGS += /WHOLEARCHIVE:tf_core_direct_session.lib
                        QMAKE_LFLAGS += /WHOLEARCHIVE:tf_core_framework.lib
                        QMAKE_LFLAGS += /WHOLEARCHIVE:tf_core_lib.lib
                        QMAKE_LFLAGS += /WHOLEARCHIVE:tf_core_ops.lib
                        QMAKE_LFLAGS += /WHOLEARCHIVE:tf_stream_executor.lib
                        QMAKE_LFLAGS += /WHOLEARCHIVE:tf_core_kernels.lib
                        QMAKE_LFLAGS += /WHOLEARCHIVE:libjpeg.lib

                        I have the error LNK2001 extern symbol _imp_initializeSecurityDescriptor not resolved. So, I have tried the other version to link the libs:

                        QMAKE_LFLAGS += /WHOLEARCHIVE:-ltf_cc
                        QMAKE_LFLAGS += /WHOLEARCHIVE:-ltf_cc_framework
                        QMAKE_LFLAGS += /WHOLEARCHIVE:-ltf_cc_ops
                        QMAKE_LFLAGS += /WHOLEARCHIVE:-ltf_core_cpu
                        QMAKE_LFLAGS += /WHOLEARCHIVE:-ltf_core_direct_session
                        QMAKE_LFLAGS += /WHOLEARCHIVE:-ltf_core_framework
                        QMAKE_LFLAGS += /WHOLEARCHIVE:-ltf_core_lib
                        QMAKE_LFLAGS += /WHOLEARCHIVE:-ltf_core_ops
                        QMAKE_LFLAGS += /WHOLEARCHIVE:-ltf_stream_executor
                        QMAKE_LFLAGS += /WHOLEARCHIVE:-ltf_core_kernels
                        QMAKE_LFLAGS += /WHOLEARCHIVE:-llibjpeg

                        It doesn´t generate any warning as before and it compiles correctly. However the issue (not session found stills continues, you can find more details below) still continues. So it looks like it is ignoring somehow the flag /wholearchive .

                        Let me explain you about the issue. I have built the static library for tensorflow and I am using it in a project in visual studio. Visual studio raise the error "session.cc:58] Not found: No session factory registered for the given session options: {target: "" config: } Registered factories are {} ". So I fixed the issue adding the flag /Wholearchive.

                        And, I have exported the library for tensorflow in Qt, however I have the same error "session.cc:58] Not found: No session factory registered for the given session options: {target: "" config: } Registered factories are {} " and it is not still fixed, as I said before I have tried almost everything.
                        The solution for this issue is explain in the link:
                        https://joe-antognini.github.io/machine-learning/windows-tf-project

                        Please, let me know if you need more details.
                        Kind regards.

                        1 Reply Last reply
                        0
                        • H Offline
                          H Offline
                          hmedihe
                          wrote on last edited by
                          #12

                          Hi everyone,

                          At the end, I have been able to build the tensorflow.dll, so I don´t need to link it to the static library neither use the /wholearchive flag in Qt, so it is working now. Anyway, thank you very much for your time and your help.

                          Kind regards.

                          Pablo J. RoginaP 1 Reply Last reply
                          0
                          • H hmedihe

                            Hi everyone,

                            At the end, I have been able to build the tensorflow.dll, so I don´t need to link it to the static library neither use the /wholearchive flag in Qt, so it is working now. Anyway, thank you very much for your time and your help.

                            Kind regards.

                            Pablo J. RoginaP Offline
                            Pablo J. RoginaP Offline
                            Pablo J. Rogina
                            wrote on last edited by
                            #13

                            @hmedihe if you're done with the issue, could you please mark your post as "Solved". Thanks.

                            Upvote the answer(s) that helped you solve the issue
                            Use "Topic Tools" button to mark your post as Solved
                            Add screenshots via postimage.org
                            Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

                            1 Reply Last reply
                            0
                            • C Offline
                              C Offline
                              chopper
                              wrote on last edited by
                              #14

                              For those of you looking for how to package, on Windows, a static lib into your static lib - you have to use:

                              QMAKE_LIBFLAGS

                              This is because other linker flags are ignored by qmake when building a static library. I needed to do this with cryptopp recently - and the example below shows x86, x64, debug, and release entries in a PRO file that combines three libraries into a test library (denoted by $$TARGET) - you don't need to do this with Qt libs, I just used them for testing purposes to evaluate the results.

                              win32: {
                              	
                                  contains(QT_ARCH, i386) {
                                      CONFIG(release, debug|release): {
                              			QMAKE_LIBFLAGS += /OUT:$$TARGET "$$PWD/../dependencies/cryptopp/libs/Windows/x86/Release/cryptlib.lib" "$$[QT_INSTALL_LIBS]/Qt5Core.lib" "$$[QT_INSTALL_LIBS]/Qt5Network.lib"
                              		}
                              		
                                      CONFIG(debug, debug|release): {
                              			QMAKE_LIBFLAGS += /OUT:$$TARGET "$$PWD/../dependencies/cryptopp/libs/Windows/x86/Debug/cryptlib.lib" "$$[QT_INSTALL_LIBS]/Qt5Cored.lib" "$$[QT_INSTALL_LIBS]/Qt5Networkd.lib"
                              		}
                                  } else {
                                      CONFIG(release, debug|release): {
                              			QMAKE_LIBFLAGS += /OUT:$$TARGET "$$PWD/../dependencies/cryptopp/libs/Windows/x64/Release/cryptlib.lib" "$$[QT_INSTALL_LIBS]/Qt5Core.lib" "$$[QT_INSTALL_LIBS]/Qt5Network.lib"
                              		}
                                      CONFIG(debug, debug|release): {
                              			QMAKE_LIBFLAGS += /OUT:$$TARGET "$$PWD/../dependencies/cryptopp/libs/Windows/x64/Debug/cryptlib.lib" "$$[QT_INSTALL_LIBS]/Qt5Cored.lib" "$$[QT_INSTALL_LIBS]/Qt5Networkd.lib"
                              		}
                                  }
                              }
                              

                              Hope this helps someone who wants to AR on Windows.

                              Cheers!

                              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