Build settings for the compiler
-
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_kernelsI 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 studioQMAKE_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.libBut this last one doesn´t compile correclty.
Thank you for your help, it is very much appreciated.
-
@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? -
Hi,
Then you should use
/WHOLEARCHIVE
for MSVCIf 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-archiveI 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; omittedSo, 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:-llibjpegWith 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.libBut 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.
-
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.libI 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:-llibjpegIt 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-projectPlease, 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.
-
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!