Google Tink library building C++ - c++

Trying to build Tink library (https://github.com/google/tink) with Bazel. Bazel installed, gcc version 7.2.0, Windows 10 x64. Visual C++ 2017.
At first, there were errors like "C++ compilation of rule '#boringssl//:crypto' failed" - I commented these lines (with compilation flags I think) in boringssl/BUILD file (sections boringssl_copts, boringssl_copts_c11) and they disappeared.
But after that, bazel said, that error is in errors.h file (https://github.com/google/tink/blob/master/cc/util/errors.h)
// from #include "absl/base/port.h"
#define PRINTF_ATTRIBUTE(string_index, first_to_check) \
__attribute__((__format__ (__printf__, string_index, first_to_check)))
// Constructs a Status object given a printf-style va list.
crypto::tink::util::Status ToStatusF(
crypto::tink::util::error::Code code, const char* format, ...)
PRINTF_ATTRIBUTE(2, 3);
} // namespace tink
} // namespace crypto
enter code here
Error C3646: unknown override specifier on line 32 (line with "PRINTF_ATTRIBUTE(2, 3);"). The most frightening thing is that in another files the same code (defining same attribute) is working.
There are another errors in this file, but mentioned is the first (and another are about the same line, so they are consequences of the first I guess).
I'm nearly a total newbie in cpp, but only cpp should be used, not java-version of library.
Thank you for your help, and sorry for possible misformatting and broken english - this is my first question here.

Unfortunately, we don't support Windows for now. It's something that we plan to support next year, please see our feature roadmap.

Related

How can I compile a mex function in Windows with Eclipse (4.20.0 version) and Matlab (R2021a)

I'm trying to compile a c++ mex function that I created according to the specifications given by mathworks here (Create a C++ MEX Source File). However, after following the steps of the answer in this thread to link Eclipse 4.4.2 and Matlab R2015a in a linux enviroment (old but the only one I've found about it), I get the following error:
undefined reference to `get_function_ptr' mpi_pevd_mex_f line 79, external location: C:\Program Files\MATLAB\R2021a\extern\include\MatlabDataArray\detail\ExceptionHelpers.hpp C/C++ Problem
I don't know what else is missing. I've been trying to find a solution, but nothing useful so far.
Thank you for your help.
I have found the problem. Apparently, I needed to add additional libraries to those detailed in most of the posts related to MEX files, i.e. libmex/ libmat/libmx.
Making use of the verbose mode in Matlab (mex -v MexFunction.cpp), I realized that these libraries were missing: libmwlapack, m, libmwblas, libMatlabEngine, libMatlabDataArray. After adding them, the error disappeared.

Assistance including a basic SDK into a C++ program Dev C++

I have been making some applications that I would like to link to discord, specifically with Discord's SDK. The SDK comes with 64 and 32 bit x84 lib files, and a C++ folder full of the includes it needs, so I would assume C++ is supported.
However, I am very terrible at linking libraries or anything at that, and always run into issues when linking. I am using Dev C++ as my IDE, and my code is as follows:
#include <iostream>
#include "Discord/discord.h"
using namespace std;
void InitDiscord()
{
auto discid = 772671910668133376; //Not my actuall discord app ID, but real one does not make a difference
discord::Core* core{};
discord::Core::Create(discid, DiscordCreateFlags_Default, &core);
}
int main(){
InitDiscord();
cout << "Discord active";
while(1){
}
return 0;
}
and I am getting the error:
C:\TDM-GCC-64\x86_64-w64-mingw32\bin\ld.exe Discord Testing.o:Discord Testing.cpp:(.text+0x32): undefined reference to `discord::Core::Create(long long, unsigned long long, discord::Core**)'
for only the line discord::Core::Create(discid, DiscordCreateFlags_Default, &core); and not discord::Core* core{};
I am using C++17 and a newer TDM-GCC compiler, the same one that works for all of my other applications. I am including the .lib files and .dll files in the program's directory, and in the linker the only thing I am using is -discord_game_sdk.dll.lib which is a valid directory. I have also tried discord_game_sdk.dll.lib and putting the library in the same directory as the includes: Discord/discord_game_sdk.dll.lib. I have tried using both 32 bit and 64 bit libraries in all project and compiler directories with no change, and im sure this is something probably really simple, but nowhere have I found any example C++ discord programs or how to include their SDK.
If anyone could figure out what the problem is and how I can fix it, that would be very helpful and appreciated.
EDIT:
It appears that user4581301 was right, TDM-GCC and other Mingw compilers do not support .lib files, and will ignore them despite being linked. The SDK did not come with any other formats other than .dylib, .so, and .bundle.
This creates a somewhat new issue, I already have my compiler set up and cannot really switch to Visual Studio, so I need a way to convert .lib to .a somehow. A post here recommends http://code.google.com/p/lib2a/ , which requires a .def file, another file that did not come with the SDK, but apparently a program called gendef.exe that came with my compiler can create .def files from .dll files. That is indeed the case, however when attempting it I get the error:
C:\Program Files (x86)\Dev-Cpp\MinGW64\x86_64-w64-mingw32\bin>gendef.exe discord_game_sdk.dll
* [discord_game_sdk.dll] Found PE image
* failed to create discord_game_sdk.def ...
with no other warnings. Now I need to know if I am converting wrong, if there is an easier workaround, or if one of the other file types can be converted or used. Any suggestions at this point are welcome and appreciated!

Building OpenSSL under Borland C++ Builder, Win 8.1

I'm following the instructions from INSTALL.W32 (various OpenSSL versions), in general it's:
* Configure for building with Borland Builder:
> perl Configure BC-32
* Create the appropriate makefile
> ms\do_nasm
* Build
> make -f ms\bcb.mak
Now, I do get two kind of errors when trying to build:
For OpenSSL < 1.0.0
nasmw -f obj -d__omf__ -ocrypto\md5\asm\m5_win32.obj .\crypto\md5\asm\m5_win32.asm
'nasmw' is not recognized as an internal or external command,
operable program or batch file.
Otherwise
Warning W8017 C:\CBuilder5\Include\sys/stat.h 34: Redefinition of 'S_IFMT' is not identical
Warning W8017 C:\CBuilder5\Include\sys/stat.h 35: Redefinition of 'S_IFDIR' is not identical
Error E2227 .\crypto\rand\randfile.c 226: Extra parameter in call to _open in function RAND_write_file
Warning W8053 .\crypto\rand\randfile.c 262: '_chmod(const signed char *,int,...)' is obsolete in function RAND_write_file
*** 1 errors in Compile ***
Yes, I feel bad for using Borland C++ Builder 5 but I can't do anything about it, and yes, I consider the Shining Light option if everything else fails.
I do not use OpenSSL but from your text some hints:
NASM
is not default assembler for Borland compilers
you need to download and install it first
(it is for free and one of the best compilers I used in the past)
you are missing some #define before including OpenSSL or including in wrong order
that is why you have the first warnings and most likely also the error
some libs need to add configuration #defines (added by some specific IDE's)
to specify what compiler,platform,endianess... is used
before any includes
usually if you include in wrong order then the defines are defined for some instances of a lib file but not for all
so try to reorder the includes
sometimes helps to include before the lib some other thing like conio,stdio,windows,...
to determine which define is missing or wrong open the stat.h
and look for #ifdef #ifndef statements around S_IFMT
The solution for the newest version (1.0.2d) was to:
remove the extra parameter from randfile (which, as comment stated, was unnecessary),
edit ms\bcb.mak, search for -DMD5_ASM -DSHA1_ASM -DRMD160_ASM
and change to -DMD5_NO_ASM -DSHA1_NO_ASM -DRMD160_NO_ASM . (there was an unresolved external error with SHA, MD5 and RMD160, they basically couldn't be compiled in asm).
There were some other steps included as well, but they're just specific to my environment.

Have trouble using NCBI c++ toolkit

I'm trying implement a small program to do blast and obtain result without browsers.
The ncbi c++ toolkit seems like what I'm looking for, however, I met some problem of using it.
My environment is windows with MSVC 2010 c++ compiler and QT framework,
I've download, configure, and build the toolkit according to the following instruction.
http://www.ncbi.nlm.nih.gov/books/NBK7167/
and I have all libs (.*lib files) at the directory below:
ncbi_cxx--12_0_0\compilers\msvc1000_prj\dll\lib\ReleaseDLL
Following is an example provided by ncbi, I'm trying to do similar stuff.
http://www.ncbi.nlm.nih.gov/IEB/ToolBox/CPP_DOC/lxr/source/src/sample/app/blast/remote_blast_demo.cpp
After everything seems ready, I create a project (with Qt Creator) and try to use the toolkit.
However, the problem occurs when I include any of the header files, for example
#include <corelib/ncbiapp.hpp>
I have no clue how to solve the compiler error when including ncbi libraries.The error message is as follows:
'ncbi::CUtf8::AsUTF8' redefinition of
default parameter : parameter 2 (ncbistr.hpp line 2861)
'ncbi::CStringUTF8 ncbi::CUtf8::AsUTF8(const ncbi::TCharUCS2*,ncbi::SIZE_TYPE)' : member function already defined or declared (ncbistr.hpp line 2861)
'ncbi::CUtf8::AsUTF8' : missing default parameter for parameter 2 (ncbistr.hpp line 2861)
I spent days on figuring how to use this toolkit, if anyone can give me some idea, I'll really appreciate.
By the way, in the project file I do include path and libs.
INCLUDEPATH += "../../lib/ncbi_cxx--12_0_0/include"
LIBS += "../../lib/ncbi_cxx--12_0_0/compilers/msvc1000_prj/dll/lib/ReleaseDLL/*.lib"

wdk ddk compiler problems with std::string and std::wstring

I've started playing around with the WDK / DDK (I'm assuming they're the same thing) samples and in particular the printer port monitor example. I've got this compiling using their build tool and I can attach to the spooler process and debug through... good stuff!
.. Problem comes when I simply want to write some debug out. I really thought this would be simple (haven't doing c++ in a while!) but it appears not!
The current problem I'm having is simply trying to create an instance of std::wchar, as in below:
std::wstring test("Blah");
Problem is, when I compile with the wdk build tool I get these errors:
1>c:\winddk\7600.16385.1\src\print\monitors\localmon\localmon.c(361) :
error C2143: syntax error : missing ';' before ':'
1>c:\winddk\7600.16385.1\src\print\monitors\localmon\localmon.c(363) :
error C2143: syntax error : missing ';' before 'type'
I'm guessing that this is because the compiler doesn't understand the std:: bit maybe? The line number points to the wstring declaration above.
I've added include <string.h> but that didn't help and my sources file is below:
!IFNDEF MSC_WARNING_LEVEL
MSC_WARNING_LEVEL=/W3
!ENDIF
MSC_WARNING_LEVEL=$(MSC_WARNING_LEVEL) /WX
C_DEFINES=-DUNICODE -D_UNICODE -D_SPL_CLUST
TARGETNAME=ddklocalmon
TARGETTYPE=DYNLINK
DLLENTRY=_DllMainCRTStartup
DLLDEF=localmon.def
DLLORDER=localmon.prf
TARGETLIBS=$(SDK_LIB_PATH)\kernel32.lib \
$(SDK_LIB_PATH)\advapi32.lib \
$(SDK_LIB_PATH)\user32.lib \
$(SDK_LIB_PATH)\ws2_32.lib \
$(SDK_LIB_PATH)\spoolss.lib
INCLUDES=$(INCLUDES); \
$(DDK_INC_PATH); \
USE_MSVCRT=1
SOURCES=localmon.rc \
localmon.c \
winspool.c \
util.c \
config.c \
xcv.c \
irda.c \
mem.c \
PRECOMPILED_INCLUDE=precomp.h
Also, if I ever got wstring working I was going to use this with OutputDebugString() to process my debug to the visual studio output console, but I think I've read somewhere that this may not work as the port monitor runs in kernel mode?
If anyone could shed any light on this I'd really appreciate it! :)
Andy.
std::string and std::wstring are C++ classes (actually typedefs for C++ classes), and you are compiling .c files.
Using the C++ runtime libraries in drivers feels a bit strange, I don't know if it works.
If you where to compile as C++ the include is <string> and not <string.h>.
Almost all, if not all, of the DDK uses C, not C++.
std::string and std::wstring is a part of C++ standard library (included in header file - NOT that is part of C standard library as #dalle already posted).
And as #dalle already posted you compile C source code (samples are written in C) - the right format for C++ source file name is *.cpp
Full C++ support is available in user-mode. So since you have user-mode DLL using C++ is OK it you rename files to *.cpp (but looks ugly because you embed C++ chunks into pure-C code samples).
In kernel-mode code however the C++ support is very limited.
If you really need full C++ language support in kernel-mode you may use some tricks to enable it but it is very complicated thing to do by yourself that requires lots of knowledge and experience (though there are some incomplete solutions available to the public).