cuda 5.0 linking with samples .h in Visual Studio 2010 - header

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.

Related

getting error while compiling yara in VC++ libyara

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.

Make(compiler) complains about missing llvm/PassAnalysisSupport.h file

I downloaded LLVM (12.0.1) from the script file llvm.sh which they have now started to include on their Debian downloads page.
Ran clang and everything was working as expected(good job dev team I guess?).
The installation script installed LLVM in /usr/lib/LLVM-12/ and /usr/include/LLVM-12/ (these had some .h files)
So I tried writing some passes; created an out-of-tree build using the answer given here:
Facing issue with makefile for Hello pass in llvm
But when I ran the make, it gave me this error:
/usr/include/llvm-12/llvm/Pass.h:337:10: fatal error: llvm/PassAnalysisSupport.h: No file or directory
337 | #include "llvm/PassAnalysisSupport.h"
|
compilation terminated.
So I checked /usr/include/llvm-12/llvm/ and found that Pass.h and PassAnalysisSupport.h both were present in the current directory, so shouldn't the Pass.h file have #include "PassAnalysisSupport.h" instead of the present #include "llvm/PassAnalysisSupport.h"?
I also checked the code for Pass.h online and it also had #include "llvm/PassAnalysisSupport.h". Other header files in the llvm directory also used the same format #include "llvm/<name>"
So what is going on here, who messed up, the devs or my llvm.sh (also the devs) or the problem is something else?
Any help would be appreciated (Im using Mint MATE 20.2 if thats relevant)
Source file (headers; firstpass/first/fpass.cpp):
#include <llvm-12/llvm/Pass.h>
#include <llvm-12/llvm/IR/Function.h>
#include <llvm-12/llvm/Support/raw_ostream.h>
#include <llvm-12/llvm/IR/LegacyPassManager.h>
#include <llvm-12/llvm/Transforms/IPO/PassManagerBuilder.h>
(firstpass/CMakeLists.txt):
find_package(LLVM REQUIRED CONFIG)
include_directories($(LLVM_INCLUDE_DIRS))
add_subdirectory(first)
(firstpass/first/CMakeLists.txt):
add_library(LLVMfirst MODULE fpass.cpp)

Visual Studio Express 12 (2013) with CMake 3 and shared libraries provides LNK1104 errors

I have the following CMakeLists.txt
project(testproject)
cmake_minimum_required(VERSION 2.8.4)
add_library(library lib.cpp)
add_executable(test.x main.cpp)
target_link_libraries(test.x library)
If I build a project for visual studio with
cmake path\to\project
then open the solution in visual studio express 12 I have no problems. However, if I build the project with
cmake -DBUILD_SHARED_LIBS=ON path\to\project
Then I get the following error in visual studio:
LINK : fatal error LNK1104: cannot open file 'Debug\library.lib'
which seems to be because, as per what I specified, visual studio built the file 'Debug\library.dll'
Everything works fine if I do a linux makefile build.
So...any idea why visual studio is still looking for the static lib? Is this a cmake bug, or something I did?
I'm not very experienced at windows-side development, so I would appreciate any help you could give. Thanks!
Probably this is because you are not "exporting" anything.
Example
If you create library foo:
add_library(foo foo.cpp foo.hpp)
CMake will provide foo_EXPORTS macro for you in case shared library is building:
cl /c ... /D foo_EXPORTS
You can use this macro to declare your functions, something like this:
// foo.hpp
#if defined(_WIN32)
# if defined(foo_EXPORTS)
# define FOO_EXPORT __declspec(dllexport)
# else
# define FOO_EXPORT __declspec(dllimport)
# endif // Foo_EXPORTS
#else // _WIN32
# define FOO_EXPORT
#endif
FOO_EXPORT int foo();
Update
Header can be generated automatically using GenerateExportHeader module:
// foo.hpp
#include "foo_export.h" // foo_export.h is generated for you
FOO_EXPORT int foo();
# CMakeLists.txt
include(GenerateExportHeader) # include module with function `generate_export_header`
include_directories("${PROJECT_BINARY_DIR}") # this is the default directory for generated header, i.e. location of generated file `${PROJECT_BINARY_DIR}/foo_export.h`
add_library(foo foo.cpp foo.hpp)
generate_export_header(foo) # create `foo_export.h`

How to add a static library CppUTests to my project atmel studio

I'm using Atmel Studio 6.1.2 SP2. I'm setting up CppUTest for our embedded system project.
I created a static CPP library for the CppUTest Framework which copiled successfuly after a small change. Now I'm including this library to a test project. A C++ application project.
The issue I'm facing now is that even though the intellisense is auto completing my include, that means that it sees where the library is, I get "No chuch file or directory" error when compiling.
In GccApplication1.cpp I have this:
#include <avr32/io.h>
#include <CommandLineTestRunner.h>
int main(int ac, const char** av)
{
/* These checks are here to make sure assertions outside test runs don't crash */
CHECK(true);
LONGS_EQUAL(1, 1);
return CommandLineTestRunner::RunAllTests(ac, av);
}
And the error is that it can't find the CommandLineTestRunner.h. I tried with "" and <> but it doesn't see it.
Any ideas?
For more information. I'm following the steps from Atmel, here is the tutorial:
Adding the library only tells the linker that the file is available to be linked with the rest of your object code. What appears to be missing is telling the compiler where it can find the header files for the library. If you add the library path to your include list you should be good to go.
The "No such file or directory" error is a preprocessor error. It is telling you that the include file cannot be found in the include file path. Your IDE will have a way to specify the include path.
If you are using make, then you will want to use the -I option.
If you are using CppUTest's MakeFileWorker.mk, you will want to add define an environment variable, CPPUTEST_HOME, that specifies the directory where you installed CppUTest.
I hope that helps.

Why would an application not find the DLL “boost_thread-vc100-mt-1_46_1.dll”?

Question: why would an application not find the DLL “boost_thread-vc100-mt-1_46_1.dll” when the DLL is in fact properly installed, and other applications use the DLL successfully?
Problem: when starting an instance of my application, the following error message appears:
“The program can’t start because boost_thread-vc100-mt-1_46_1.dll is missing from your computer. Try reinstalling the program to fix this problem.”
Several reasons why this message confuses me:
The dll is present in C:\Program Files(x86)\boost\boost_1_46_1\lib
Another project with similar settings runs properly and does create
boost::thread objects successfully
When I remove the code that creates boost::thread objects from my application, the error
message does not appear.
Additional details:
I am developing a C++/CLI application using MS VS 2010 with CLR enabled.
I am using the Boost Thread library (version 1.46.1).
Following the advice on posts about using Boost Thread and C++/CLI, I added the following code to one of my header files:
#if defined(_MANAGED)
#define BOOST_USE_WINDOWS_H
#endif
#define BOOST_THREAD_USE_DLL
#include "boost/thread.hpp"
namespace boost {
struct thread::dummy {};
}
#pragma warning(push)
#pragma warning(disable:4793)
#include "boost/thread/mutex.hpp"
#pragma warning(pop)
#include "boost/thread/locks.hpp"
I appreciate any advice you may have. Thank you.
Being in C:\Program Files(x86)\boost\boost_1_46_1\lib doesn't help much.
It needs to be in the DLL search path.
Other applications using boost probably have a local copy of the DLL alongside the main executable.
You need to add the location of the boost libs to the linker search path.
Right click on the C++ project that is showing the linker error, select Properties. Go to Linker -> General then in the right hand panel you see Additional Library Directories. Put in the path to the folder holding boost_thread-vc100-mt-1_46_1.dll - typically this folder will hold all of your boost libs and will be something like D:\Program Files\boost\boost_1_49_0\stage\lib.
Now the linker will search that folder when looking for libs, and everything should work.