getting error while compiling yara in VC++ libyara - lnk2001

I want use yara library in my Visual studio C++ program. I used vcpkg to install yara 64 bit on my system.
Here is a simple code to initialize yara.
#include
#include <yara.h>
int main()
{
yr_initialize();
}
I get linker errors while compiling
Please help me in fixing this.

Related

Command line to build C++ program with LLVM libs

I am starting in the world of LLVM and searched in several places and read several documentation about LLVM but I found nothing showing how to compile a program that uses LLVM headers and libs ....
I wrote this simple program just to try to compile, using the Visual Studio cross-compiler, I tried several command line options .... even using the -lLLVM option, but, nothing worked ...
I tried using g++ and clang++
#include <iostream>
#include <llvm/ADT/OwningPtr.h>
#include <llvm/Support/MemoryBuffer.h>
int main()
{
llvm::OwningPtr<llvm::MemoryBuffer> buffer
return 0;
}
When I try to build, I get this erro:
error : 'llvm/ADT/OwningPtr.h' file not found
So, what is the command line to compile this simple program?
The command llvm-config --cxxflags --ldflags --system-libs --libs core will provide you with all the linkable llvm libraries, provided you have llvm installed. Just link with this command in single quotes

How to compile OpenCV3 using MinGW

I am trying to compile OpenCV3 and put it into Qt project because Qt officially provides MinGW Version, so I didn't use MinGW-w64.
I enabled ENABLE_CXX11 and disabled ENABLE_PRECOMPILED_HEADERS in CMake.
Now the problem is MinGW does not contain std::thread.
I know the mingw-std-threads lib can fix it. but I don't want to modify OpenCV source code. Is there any other way to adding c++ thread feature to MinGW? or tell OpenCV using pthread by CMake?
BTW. I don't want use Qt's MinGW because I think using official MinGW to compile the lib shall be used in any version of Qt.
Update:
In OpenCV detection_based_tracker.cpp, there is a CV_CXX11 Marco choice to the using std thread or the pthread. But I didn't see anywhere define CV_CXX11.
Is part of detection_based_tracker.cpp code:
#ifdef CV_CXX11
#define USE_STD_THREADS
#endif
#ifdef USE_STD_THREADS
#include <thread>
#include <mutex>
#include <condition_variable>
#else //USE_STD_THREADS
#include <pthread.h>
#endif //USE_STD_THREADS
My environment:
windows 7 64bit
cmake-3.10.1-win64-x64
opencv-3.4.0
gcc 6.3
What I tried:
install CMake and MinGW
disable ENABLE_PRECOMPILED_HEADERS in CMake-gui
comment #define USE_STD_THREADS in detection_based_tracker.cpp line 48
configure and generate Makefile
Run mingw32-make
it's successfully compiled, but I have to modify OpenCV source code.
If you use the right version of MinGW, namely MinGW-w64, most toolchains builds have the modern threading features available.
You can e.g. use the installer or install it through MSYS2.

Linking lots of .libs to make a DLL: unresolved external symbol _DllMainCRTStartup

I'm performing the (terrifying) task of building LLVM 3.3 on windows and I have got to the stage where I have a load of LLVM*.lib files. I want to link them together to one huge shared DLL but am struggling (this is my first time linking stuff on windows). I've tried:
link /DLL /MACHINE:X64 /OUT:LLVM3.3.dll LLVM*.lib
but to no avail. It errors with:
LINK : warning LNK4001: no object files specified; libraries used
LINK : error LNK2001: unresolved external symbol _DllMainCRTStartup
LLVM3.3.dll : fatal error LNK1120: 1 unresolved externals
The internet suggested adding the /DEFAULTLIB:corelib switch, so I did that but again it has problems:
> link /DLL /MACHINE:X64 /DEFAULTLIB:corelibc /OUT:LLVM3.3.dll LLVM*.lib
LINK : warning LNK4001: no object files specified; libraries used
LINK : fatal error LNK1104: cannot open file 'corelibc.lib'
How do I do this?
EDIT: I managed to fix the above problem, by implementing an empty DllMain and making an EmptyDllMain.obj from it:
#include <windows.h>
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}
and then trying:
link /DLL /OUT:LLVM3.3.dll LLVM*.lib EmptyDllMain.obj
but the DLL I get out is just 8kb - it seems to have missed out the many megabytes of LLVM libraries! How do I get them included?
EDIT2: I solved the LLVM compilation on Windows problem, take a look at this document on github.
I had this once while linking one lib with a wrong platform set together (X86 to X64). Make sure all the LLVM*.lib are build and linked with the correct toolchain:
[...]\Microsoft visual Studio 10.0\VC\bin\amd64\ cl.exe and link.exe
which you get by calling
"%PROGRAMFILES(X86)%\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" amd64
Also I had similar problems when mixing MT and MD CRTs, I recommend you stick to
/MD (or /MDd for debug)
when compiling the objects for any of the LLVM*.lib (and any other objects from other external libraries you link into these).
[edit]
And kick out that ugly EmptyDllMain.obj !
[/edit]
If you manually entered the _DllMainCRTStartup, be sure you spelled it (watch case) correctly. I had _DLLMainCRTStartup and took a while to catch why I still received the linker error. For Windows CE, the required link lib is corelibc.lib.
remove lib files from "ignore specific default libraries" from "Linker->Input" on project properties

cuda 5.0 linking with samples .h in Visual Studio 2010

I have visual studio 2010 ultimate and cuda toolkit 5.0. the samples work perfectly. VS recognize cuda`s language, syntax and works fine. but when I tried something like this:
#include <helper_functions.h>
#include <stdio.h>
#include <stdio.h>
int main()
{
return 0;
}
the compiler can't find helper_functions.h (this header file come with the samples and is in C:\ProgramData\NVIDIA Corporation\CUDA Samples\v5.0\common\inc and my program and the samples aren`t in the same directory.)
when I try with the absolute path:
#include <C:\ProgramData\NVIDIACorporation\CUDASamples\v5.0\common\inc\helper_functions.h>
#include <stdio.h>
int main()
{
return 0;
}
compiler : exception.h no such file or directory
helper_functions.h and exception.h are in the same directory.
I know that I have to link them but I don`t know how do that with VS
You are using visual studio 2010 so you should add the path to your project. Just right click on the name of the project, select properties. under configuration properties select VC++ Directories. add an extra ; at the end of Include Directories and add C:\ProgramData\NVIDIACorporation\CUDASamples\v5.0\common\inc\. also the common directory might also have a lib folder that you should add under Library Directories.
You should do this for each project that needs them. also you can copy them to your VS directory under VC\include.

i386-mingw32-g++: error trying to exec 'cc1plus': execvp: No such file or directory

If I compile this QT c++ program in SuSE Linux
#include <iostream>
using namespace std;
int main ()
{
cout << "Hello World!";
return 0;
}
When I type
i386-mingw32-g++ helloworld.cpp
I get the following error
i386-mingw32-g++: error trying to exec 'cc1plus': execvp: No such file or directory
Is this because MinGW package which i installed contains only gcc in it.. hence i downloaded gcc-g++-3.4.5.rpm package and just copy pasted i386-mingw32-g++ and cc1plus executable along with C++ include files.
Pls reply.
Thanking You
Ugh. The cc1plus in gcc-g++-3.4.5.rpm is not for mingw32. You need the one for your distro.
e.g. for Fedora 10, use http://sourceforge.net/projects/outmodedbonsai/files/Mingw%20Cross-compiler/mingw-1.10-1.fc10.x86_64.rpm
Quoting from here:
It means that your shell could find
the g++ frontend of the GNU compiler
but that frontend couldn't find
cc1plus, the actual C++ compiler; it
could find cpp, the preprocessor, it
already ran. Go to the directory where
the g++ frontend is stored (type:
"which g++") and look for the file
cc1plus in that same directory or a
sub- directory thereof. If it isn't
there your compiler installation is
broken; if it is there some
configuration of it went berzerk.
Also, have a look at this thread.
suse cross-compile toolchain is here.
http://download.opensuse.org/repositories/CrossToolchain:/mingw/