Build settings for the compiler



  • 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.


  • Moderators

    @hmedihe said in Build settings for the compiler:

    QMAKE_LFLAGS

    Can you show how you're using it?



  • 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.


  • Moderators

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



  • 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 \



  • 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



  • 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?


  • Lifetime Qt Champion

    Hi,

    Then you should use /WHOLEARCHIVE for MSVC

    If you get errors then please post them.



  • 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.


  • Lifetime Qt Champion

    Because the first version is for gcc/MinGW.

    And what error do you get when modifying QMAKE_LFLAGS ?



  • 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.



  • 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.



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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.