Unable to find Torch header files using nvcc - compilation

I'm trying to call some CUDA code from luaJIT (Torch) but I'm running into compiling issues. nvcc seems unable to find my Torch header files. I have CUDA 6.5 and gcc 4.4.7.
nvcc -o im2col -I/deep/u/ibello/torch/include im2col.cu
In file included from /deep/u/ibello/torch/include/THC/THC.h:4,
from utils.h:6,
from im2col.cu:1:
/deep/u/ibello/torch/include/THC/THCGeneral.h:4:23: error: THGeneral.h: No such file or directory
/deep/u/ibello/torch/include/THC/THCGeneral.h:5:25: error: THAllocator.h: No such file or directory
In file included from /deep/u/ibello/torch/include/THC/THC.h:7,
from utils.h:6,
from im2col.cu:1:
/deep/u/ibello/torch/include/THC/THCStorage.h:4:23: error: THStorage.h: No such file or directory
In file included from /deep/u/ibello/torch/include/THC/THC.h:9,
from utils.h:6,
from im2col.cu:1:
im2col.cu includes the following
#include "utils.h"
#include "common.h"
#include <lua.h>
#include <lauxlib.h>
#include <lualib.h>
where "utils.h" is
#ifndef CUNN_UTILS_H
#define CUNN_UTILS_H
extern "C" { #include <lua.h> }
#include <luaT.h>
#include <THC/THC.h>
THCState* getCutorchState(lua_State* L);
#endif
This is relatively weird since the mentioned files are indeed in the include location I gave to the compiler..
ls /deep/u/ibello/torch/include/THC
THCAllocator.h THCDeviceTensor.cuh THCDeviceTensorUtils-inl.cuh THC.h THCReduce.cuh THCTensorConv.h THCTensorMath.h
THCApply.cuh THCDeviceTensor-inl.cuh THCDeviceUtils.cuh THCReduceAll.cuh THCStorageCopy.h THCTensorCopy.h THCTensorRandom.h
THCBlas.h THCDeviceTensorUtils.cuh THCGeneral.h THCReduceApplyUtils.cuh THCStorage.h THCTensor.h THCTensorSort.h
Any ideas about what I'm doing wrong?
Thx in advance!

It seems that this compile command:
nvcc -o im2col -I/deep/u/ibello/torch/include im2col.cu
did not give the necessary search paths for the compiler to find the header files like THGeneral.h that were located in /deep/u/ibello/torch/include/TH
The solution was to specify a compile command like this:
nvcc -o im2col -I/deep/u/ibello/torch/include -I/deep/u/ibello/torch/include/TH im2col.cu

Related

open62541: Error when building PubSub example

Currently, I am trying to build the PubSub example of the open62541 implementation. I have already gone through the documentation on how to build the examples a several times but I cannot figure it out.
I have tried to compile the PubSub tutorial examples. This includes the tutorial_pubsub_publish.c and the tutorial_pubsub_subscribe.c files. After I cloned the repository, I built the library as followed:
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -
DUA_ENABLE_AMALGAMATION=ON -DUA_ENABLE_PUBSUB=ON ..
make
First I compiled the publish example which worked:
gcc -std=c99 -o PubSub_Publish_Example open62541.c tutorial_pubsub_publish.c
Then, I tried to compile the subscribe example in the same way like this:
gcc -std=c99 -o PubSub_Publish_Example open62541.c tutorial_pubsub_subscribe.c
This generated lots of errors - all saying "No such file or directory(first error was for the #include "ua_architecture_base.h") Then I tried to compile it with the ua_architecture_base.h and get other missing file or directory error and so on...
I also tried to compile the whole include folder of the open62541, but I also get "No such file or directory" errors:
gcc -std=c99 -I /home/theresa/Desktop/open62541/include -o PubSub_Subscribe_Example open62541.c tutorial_pubsub_subscribe.c
I also noticed that of all examples provided by the open62541 master, the tutorial_pubsub_subscribe.c file is the only example which does NOT include
the open62541.h folder. Instead it includes a few other header files:
#include "ua_pubsub_networkmessage.h"
#include "ua_log_stdout.h"
#include "ua_server.h"
#include "ua_config_default.h"
#include "ua_pubsub.h"
#include "ua_network_pubsub_udp.h"
#ifdef UA_ENABLE_PUBSUB_ETH_UADP
#include "ua_network_pubsub_ethernet.h"
#endif
#include "src_generated/ua_types_generated.h"
#include <stdio.h>
#include <signal.h>
So how can I compile and run the tutorial_pubsub_subscribe.c example and why does the subscriber example not include the open62541 header file?
I had success following the instructions "Building with CMake for Windows".
Using cmake-gui I selected the (advanced) features: UA_BUILD_EXAMPLES, UA_ENABLE_PUBSUB, UA_ENABLE_PUBSUB_INFORMATIONMODEL, UA_ENABLE_PUBSUB_INFORMATIONMODEL_METHODS, and UA_NAMESPACE_ZERO = FULL

Failed to use LLVM libraries on Windows

I've been using the LLVM release build from here https://github.com/ziglang/zig/wiki/Building-Zig-on-Windows. When I build a simple cpp file that references to LLVM library, the compiler crashes. I'm using x64 cl as the compiler.
The command I'm using is roughly: cl -I <llvm include directory> main.cpp %libs% /link /LIBPATH:<llvm lib directory>
The %libs% variable is set to be the output of llvm-config --libnames all --system-libs
Below is the simple CPP program I used.
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/Type.h"
#include "llvm/IR/Verifier.h"
using namespace llvm;
LLVMContext TheContext;
int main()
{
return 0;
}
I have found the problem in my batch script where there's whitespace in the path.

macOS 10.14: Cannot find stdio.h

I am trying to run the following hello world program:
#include <stdio.h>
int main(){
printf("Hello, world!\n");
return 0;
}
With my system's default C compiler located in /usr/bin/gcc, that works as expected. But when I am using the compiler I installed, GCC version 6.4, located in $HOME/usr/bin/, I get the following error:
$ gcc main.cc
main.c:1:19: fatal error: stdio.h: No such file or directory
#include <stdio.h>
Any idea on how to fix it? I've tried xcode-select --install/reset. Also, at first, compilation was failing with the system's gcc but I fixed it by creating the /usr/include directory. However, I need to use the compiler I've installed.

CMake executable runs slower than running in ROOT

I wrote a macro for ROOT with the following libraries:
#include <iostream>
#include <math.h>
#include <vector>
#include <iomanip>
#include <time.h>
#include <stdio.h>
#include <gsl/gsl_matrix.h>
#include <gsl/gsl_odeiv2.h>
//ROOT libraries
#include <TTree.h>
#include <TFile.h>
When running in ROOT with .x script.cpp, it works fine and takes 0.25 seconds to write a root file.
Then, I created an executable using CMake. For that, I created the next CMakeLists files:
This CMakeLists file is outside the directory where the .cpp file is
cmake_minimum_required(VERSION 2.6)
project(CMAKE_TEST)
find_package(GSL)
find_package(ROOT REQUIRED COMPONENTS)
set(CMAKE_CXX_FLAGS "-g++ -O2 -Wall")
set(CMAKE_CXX_FLAGS ${ROOT_CXX_FLAGS})
add_subdirectory(script_sub)
This is the one that is inside (same location as the .cpp file)
include_directories(${CMAKE_TEST_SOURCE_DIR}/script_sub)
link_directories(${CMAKE_TEST_BINARY_DIR}/script_sub)
include(${ROOT_USE_FILE})
set(CORELIBS ${ROOT_LIBRARIES} ${GSL_LIBRARIES} m)
add_executable(script script.cpp)
target_link_libraries(script ${CORELIBS})
CMake creates the Makefile just fine, and then I can run make with no problems either. The issue is that when running the executable by ./script, this writes the root file in 0.92 seconds, i.e., it is slower than running the code in ROOT. The results are correct, and I see no error message.
How is this possible?

Problems with ffmpeg build in Xcode

Hi I have a problem with getting ffmpeg libraries to build in my Xcode project. It is in C++ . I have installed it using homebrew and have checked that all the correct libraries have installed via terminal. I have tried with and without extern C as I know it is a c library.
#include <iostream>
#include <opencv2/opencv.hpp>
#include <libavformat>
//extern "C" {
// #include <libavformat>
//}
The linker flags have been set by using (e.g. pkg-config --libs libavcodec) in terminal and these flags do not throw up an error when building. The header files are also found with no problems as the autocomplete flags them top while typing.
Please see attached pictures for Xcode build settings. Really stuck pease help
I identified the problem as being related to the path that the include statement relates to. The header files were one down in the hierarchy from the folders so:
#include <libavformat>
produces an error that the library was not found. The change below sorted the problem out.
#include <libavformat/avformat.h>

Resources