Including library in command-line based buidling of QT Plugin - c++

I would like to build the QT Opc Ua Plugin for QT 5.13.2 with the security patch for the Open62541 library.
So far I managed to install the mbedTLS library and it gets recognized in the qmake step prior to nmake. Nmake then runs into a problem:
mbedcrypto.lib(entropy_poll.obj) : error LNK2019: unresolved external symbol __imp__CryptAcquireContextA#20 referenced in function _mbedtls_platform_entropy_poll
As far as I understand the issue, this is because my linker? doesnt find the library in which those functions are located, which would be advApi32.lib
Although there are many tutorials as to how to include this library with Visual Studio or with Qt Creator, i need to do this from the command line (or by manipulating dome files in the QtOpcUa directory), how would this be possible ?
I already tried adding LIBS += -ladvAPI32 to all the .pro files I could find, but it did not help at all.

I fixed it by adding AdvAPI32.lib to the win32: part of the open62541.pri file. I don't know why it's expected at this place, but I'm happy it works now.

This seems like a path issue. In the qtopcua.pro file, you can try adding the absolute path of the advapi32 library using 'LIBS +=' option and then run qmake.

Related

How to solve error "o rule to make target"?

This Error pops up while I try to Compile the Project Map of Cartotype, I followed The Instruction on The Cartotype Documentation, but at this point I couldn't do any progress, help please !
:-1: error: No rule to make target 'G:/QT/Projects/cartotype-eval/CartoType-Public/src/apps/Maps/../../../../cartotype_windows_sdk_evaluation_5.10.7/CartoType/bin/15.0/x64/DebugDLL/libcartotyped.a', needed by 'debug/CartoTypeMaps.exe'. Stop.
My colleage tested same project on QT Linux - Ubuntu, and it worked smoothly !
I presume that you're using MinGW since the buildtool is looking for foo.a. You need to simply look at that error and understand what it means: a library it needs is missing. Until you provide that library, it won't build. That's the simple part. The hard part is that according to the SDK overview, CartoType comes with .lib libraries only, not .a libraries. But modern MinGW supports .lib files, so you only need to convince it to look for the .lib file, not .a file. Most likely, your build scripts have the reference to .a, or no full filename whatsoever.
If you're using QMAKE, you likely have something like:
LIBS += -LX:/cartotype_windows_sdk_evaluation_5.10.7/CartoType/bin/15.0/x64/DebugDLL cartotyped
Instead, you'd want:
LIBS += X:/cartotype_windows_sdk_evaluation_5.10.7/CartoType/bin/15.0/x64/DebugDLL/cartotyped.lib

Error building tensorflow C++ shared library on windows

I am trying to build tensorflow as a standalone project and have been following this tutorial
http://www.stefanseibert.com/2017/10/tensorflow-as-dll-into-your-windows-c-project-with-gpu-support-and-cmake-v1-3/
but alternatively with cpu support
My environment setup versions
protobuf 3.6.1
tensorflow 1.10.0
tf.GIT_VERSION = b'v1.10.0-rc1-19-g656e7a2b34'
Here are the steps I used to generate the shared lib
Acquired source code from https://github.com/tensorflow/tensorflow.git
Have installed the dependencies since I do not use the python bindings, there is no need for SWIG, so I installed Git (version 2.15.1.windows.2) and cmake 3.11.1
I used the 64bit tools from Visual Studio 2015 since VS2015 is necessary to build the DLL. I should be able to open the “VS2015 x64 Native Tools Command Prompt”. This is needed so VS uses the 64 bit toolset.
Navigated in the commandline to the “tensorflow/contrib/cmake” subfolder of the source code and create a directory with “mkdir build”. Afterwards navigate to the fresh build folder with “cd build”.
Create a build solution: cmake .. -A x64 -DCMAKE_BUILD_TYPE=RelWithDebInfo -Dtensorflow_BUILD_CC_EXAMPLE=OFF -Dtensorflow_ENABLE_GRPC_SUPPORT=OFF -Dtensorflow_BUILD_CC_TESTS=OFF -Dtensorflow_BUILD_PYTHON_TESTS=OFF -Dtensorflow_ENABLE_GPU=OFF -Dtensorflow_WIN_CPU_SIMD_OPTIONS=/arch:AVX -Dtensorflow_BUILD_SHARED_LIB=ON
Everything went fine till this. To build the tensorflow.dll, I issued the following command: MSBuild /p:Configuration=RelWithDebInfo tensorflow.vcxproj
This throws an error: D:\work\tensorflow\tensorflow/core/lib/core/stringpiece.h(34): fatal error C1083: Cannot open include file: 'absl/strings/string_view.h': No such file or directory (
compiling source file D:\work\tensorflow\tensorflow\core\lib\core\coding.cc) [D:\work\tensorflow\tensorflow\contrib\cmake\build\tf_core_lib.vcxproj].
I fixed the above error with this: https://github.com/tensorflow/tensorflow/issues/22007#issuecomment-424553600.
Doing the above I ended up with this error: path.obj : error LNK2019: unresolved external symbol "void __cdecl absl::base_internal::ThrowStdOutOfRange(char const *)" (?ThrowStdOutOfRange#base_internal#absl##YA
XPEBD#Z) referenced in function "class std::basic_string,class std::allocator > __cdecl tensorflow::io::internal::JoinPathIm
I am not able to proceed further. Any workaround for this? Thanks!
lnk2019 error occurs when your directly you are using in your source code are not linked properly. Please add additional dependencies to your project.
Going to project properties
select C/C++ option
Add aditional dependencies
Go to Linker Option Below C/C++
Add additional Dependencies here.
It might be help full for you from getting out to LNK2019 problem
view this to understand LNK2019 error.
I met same issue, I think tensorflow new version doesn't support CMake, but we can solve the issues.
1. Seems the absl version in project folder is out dated, so I cloned the latest version of abseil-cpp from: https://github.com/abseil/abseil-cpp
2. Use cmake to build the abseil-cpp, it will be fast.
3. Add lib path to tensorflow dependency, the needed one will be D:\git\abseil-cpp\abseil-cpp\build\absl\base\Release\absl_absl_throw_delegate.lib
4. If you meet other linking error, you can find the function name in absl sources and find the library contain it.
Hope this can help you and people who may met this issue in future.

Compiling QT OPCUA on Windows

I have a problem when I try to compile Qt OPCUA on windows with open62541.
I am following this tutorial (Building On Windows - Mingw32)
I cannot seem to specify the path to the header open62541.h and the lib open62541.a even if I did
set QTOPCUA_OPEN62541_INCLUDE_PATH=c:\path\to\open62541\build
set QTOPCUA_OPEN62541_LIB_PATH=c:\path\to\open62541\build\bin
Note that open62541 is compiled and that I do have the files open62541.h and libopen62541.a (in version 0.3) where they should be.
The error I get is a linker problem : cannot find -lopen62541
I added manually the open62541.h to the project files since it was not working either.
What should I do to specify correctly the path to open62541 please ? Is there an up-to-date documentation ?
You need to add the path where libopen62541.a is to the library path directory.
If you are using QMake, you need to specify add it to the LIBS variable prepending the path with a -L as follows:
LIBS += -L$${PATH_WHERE_LIB_FILE_IS}
Take a look on how is done in the QUaServer project.
If you are using CMake, then take a look at this answer on how to add to the library path directory.
What you are doing with those commands is telling the linker where to find the missing libraries.

Qt - Cannot use external library for cross compiling

I follow this document Cross Compile Qt - Raspberry, and it works completly. I can cross compile simple application from qt creator. Now i want to use external libary (ID3lib). But it gets error when build project
/home/shymaxtic/Documents/FPT/Hihi/ID3tag/lib/libid3.so: error: error adding symbols: File format not recognized.
Can anyone help me?
Like Kuba Ober pointed, in order to include on you board a external library, you need to cross compile it, just like you do for your application.
Depending on the size of the library, you can either integrate it in your Qt project by creating a top level SUBDIR project, or simply cross-compile it manually, and provide the path to the cross-compiled library like you did here with LIBS += -L<path> -l<library>
When cross compiling, make sure to use the toolchain specific for your board (you already have it for Qt), and not the gcc/g++ of your desktop distribution

C++ Qt: Static builds and external dylibs

I've been doing some funny stuff in personal projects with Qt. I'm not an expert in this so if it's a dumb question (guess not I couldn't find anything useful) feel free to kill me.
Anyway, I'm in OSX and usually I compile the final versions against a static version of Qt using a shell script with this commands:
cd "project folder...";
PATH=/Users/TCB13/(...)/qt-source/bin:$PATH; --> Path to my static QT.
export PATH;
qmake -config release;
make;
make clean;
So far if I move the compiled binary to another computer without Qt installed everything works just fine! ;)
Yesterday I start to play around with a dynamic library provided by a company and I've included the dylib in my .pro file like this: (I've a copy of the dylib in the project folder)
#macx: LIBS += -L$$PWD/ -lwpsapi
#INCLUDEPATH += $$PWD/
#DEPENDPATH += $$PWD/
And when I compile it "statically" (using the commands above) and run it on the other computer I get:
dyld: Library not loaded: #executable_path/libwpsapi.dylib
Referenced from: /Users/TCB13/Desktop/dude111
Reason: image not found
Trace/BPT trap: 5
I noticed that the size of my compiled binary is the same with or without including the dylib so, I googled how to include and external lib and some people are saying that I need to add "CONFIG += static" to my .pro file. I did it and the size of the file increased but I still got the same error.
Hope someone can help me.
The error message is pretty clear, you need to distribute libwpsapi.dylib with your application. If you want to avoid that, consult the documentation of this third-party library to make it use the statically linked code. Note that the fact that you are telling the linker to link a static library, does not mean that the code is referenced. I suspect that there is some kind of preprocessor #define in the code (or defaulted) to use the dynamically loaded library.