Getting Eclipse to recognize automatic CUDA kernel variables and functions - eclipse

Is there a way to get Eclipse (Indigo) to know about the built-in variables and functions that are available to CUDA kernels?
Consider the following simple kernel
__global__ void myKernel()
{
int x = threadIdx.x;
__syncthreads();
}
The Eclipse IDE highlights "threadIdx" and "__syncthreads" with a "Symbol 'the built-in symbol' could not be resolved" error message. Is there a way to tell Eclipse these are actually implicitly defined?

flipchart is correct. #include <cuda_runtime_api.h> does the trick if the symbol __CUDACC__ is defined beforehand.

In cuda 11.3 you can add:
#include <device_launch_parameters.h>

Related

G_DECLARE_FINAL_TYPE() throws compiler error

I have written a programm in C and GTK3. I am using Arch Linux and everything works fine. However, I have to use my program also on a rather old Ubuntu machine.
gtk+-3.0 3.10.8
GCC 4.8.4
With this setup the program does not compile
In the Header file of a custom GTK-Widget I have:
#ifndef __LAYER_ELEMENT_H__
#define __LAYER_ELEMENT_H__
#include <gtk/gtk.h>
G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE(LayerElement, layer_element, LAYER, ELEMENT, GtkListBoxRow)
/* Rest of file comes here */
When compiling it throws the error message:
expected ')' before GtkListBoxRow in the line with the G_DECLARE_FINAL_TYPE macro.
How can I fix this issue?
G_DECLARE_FINAL_TYPE was added to GLib in version 2.44 (see the documentation). If you want to compile on an old version of Ubuntu, you will either have to get hold of a backport of GLib 2.44 (or later) for that version of Ubuntu, and compile against that; or you will have to modify your code to not use any GLib APIs added after version 2.40.

RTX implementation with eclipse

I have a question about RTX (RTOS), I have to implement the RTOS RTX on a NUCLEO-F411RE board (Cortex M4). I have to do it with Eclipse but I don't know how I should do.
Moreover, I tried to compile it with the gcc compiler and I had many errors like :
_ error: stray '#' in program
_ error: expected '(' before 'void' __asm void rt_set_PSP (U32 stack) {
Can someone help me to fix it?
Keil's MDK-ARM includes a plug-in for Eclipse as an alternative to using µVision. That would be the most straightforward way to start developing with Eclipse. It supports importing/exporting projects to and from µVision.
The errors you have are most likely due to attempting to compile ARM RealView compiler (armcc) specific code with gcc.

Opencv2.4.0 with mingw in windows get crashed

I followed steps in this SO link to compile a sample program using OpenCV2.4.0 in windows. I made a setup both in DEVC++ and NetBeans with Mingw. My sample Program is getting Compiled properly, but when I run the exe the application get crashes.
But In same machine I used opencv2.1.0 and the same sample program gets compiled and there is no crash while running it.
The below is the Sample Code I tried to execute:
#include "highgui.h"
using namespace std;
int main( int argc, char** argv ) {
IplImage* img = cvLoadImage( "C:\\Documents and Settings\\All Users\\Documents\\My Pictures\\Sample Pictures\\Water lilies.jpg" );
cvNamedWindow( "Sample", CV_WINDOW_AUTOSIZE );
cvShowImage( "Sample", img );
cvWaitKey(0);
cvReleaseImage( &img );
cvDestroyWindow( "Sample" );
}
UPDATE :
I follwed as the steps as moskito-x link to build the opencv and when I press "configure", I get the following error. And my make file is also 35kb in size.
Any suggestions to solve this?
Using the libs in "...\opencv\build\x86\mingw\bin" and "...\opencv\build\x86\mingw\lib
You can not use the libraries that come with OpenCV-2.4.x.exe.
As some developers in forums and I find out. On some systems, the precompiled libs of "opencv 2.4.x" can not be used.
To compile your own programs, works, but it crashed if you try to run them. Until there are not functioning precompiled libs of "opencv 2.4.x , you have to compile opencv yourself.
Ignore so the folder "...\opencv\build\x86\mingw\bin" and "...\opencv\build\x86\mingw\lib" completely.
As already pointed out you can't rely on precompiled binaries. I also had a lot of problems and finally ended up with compiling my own binaries. My setup was for Windows7, Eclipse CDT (Juno) and MinGW. You can check my post on Stackoverflow here
I guess this is an error related to memory management. Maybe because your'e releasing the window before the image. But anyhow you should use the OpenCV C++ interface, as this does a lot of stuff automagically. With the C++ Interface your code would look like this:
#include <opencv.hpp>
int main( int argc, char** argv ) {
cv::Mat img = cv::imread("C:\\Documents and Settings\\All Users\\Documents\\My Pictures\\Sample Pictures\\Water lilies.jpg");
cv::imshow("Sample", img);
cv::waitKey(0);
return 0
}

Eclipse giving me Invalid arguments ' Candidates are: void * memset(void *, int, ?) ' though I know the args are good

I am getting an invalid arguments error in eclipse, though I am confident my arguments are good. The suggested arguments contains a '?' which I think may indicate the problem, though I do not know how to fix it.
I have done my best to copy the example I saw here:
http://www.cplusplus.com/reference/clibrary/cstring/memset/
In order to be certain that I am getting the args right.
#include <stdio.h>
#include <string.h>
void foo()
{
char str[] = "why oh why does my IDE give me errors when I know my args are good?";
memset(str, '-', 4);
puts(str);
}
Eclipse gives me the following error on the memset line:
Invalid arguments ' Candidates are: void * memset(void *, int, ?) '
What could be causing this? And what is up with that '?' as the 3rd arg?
Thanks in advance!
PS: Just noticed I am getting similar errors when I try to use operations like malloc, calloc, etc.
In Eclipse:
right click the project
click properties
Expand "C/C++ general" the item in the left hand tree view by clicking the arrow, (just clicking the item itself does not expand the suboptions)
From the suboptions select "Preprocessor Include Paths, Macros etc."
Click the "Providers" tab
Check the box next to "CDT GCC Built-in Compiler Settings [ Shared ]".
Edit:
The reason this works is that there are a bunch of default includes and defines that the compiler silently adds behind the scene when you compile. These instructions get eclipse to grab these otherwise silent preprocessor directives so that it's own indexer is using the same settings
The following method resolves the same problem that I was having. (on eclipse 4.2)
Clean your project (Project -> Clean)
Reindex files (Project -> C/C++ Index -> Rebuild)
Rebuild your project (Project -> Build All)
I think it is something to do with your Eclipse setup, somehow.
Taken standalone, that fragment compiles under GCC (G++) 4.7.1 on Mac OS X 10.7.5 with the command line:
g++ -O3 -g -Wall -Wextra -c ms.cpp
The only surprising thing about the third argument to memset() is that it is of type size_t, but the headers are supposed to declare that, so it should not be an issue.
If you're using malloc() et al, you will be including <stdlib.h>, of course. There is also room to argue that you should be using <cstdio>, <cstring> and <cstdlib>, but that shouldn't stop the code you presented from compiling without error.
If you're working with Visual Studio, size_t is defined as
typedef unsigned __int64 size_t;
In previous versions of the Eclipse CDT, __int64 was not defined. You can fix that issue by adding into C/C++ General -> Paths and Symbols -> Symbols
Symbol: __int64
Value: long long
Or you can upgrade your Eclipse CDT version
I've been using a 3rd party C++ library for BeagleBone development and I tried every possible way to include it (as preprocessor includes, source folder, assember includes, library includes, C++ compiler includes, C compiler includes etc). Refreshen, reindex, clean and built for every change I attempted. I even deleted the project and copied only the .cpp and .h files over to a new project.
I finally found the problem in my setup and rectified it as follows.
Right-click the project > Properties > C/C++ Build > Tool-chain editor > Current Builder:> Select CDT Internal Builder
I'm using g++, for your information.
I had a similar issue with the Eclipse CDT. But in my case the thing was that I had put the using namespace std; statement in a several headers. And in some combination of conditions, when I included all of this headers the Eclipse had such the behavior.
I had a similar issue when compiling someone's code, and the problem was the code style. They defined some methods in this way:
// ... Inside a class
static void
sleep( u32 ms );
I guess this is GNU style. Just changing the declaration to
static void sleep( u32 ms );
removed the issue.

compiler errors using Boost.Python with macports Python.framework

This might be a very dumb question...
I'm trying to use Boost.Python in an Xcode project (boost 1.50, xcode 4.4, OS X 10.8). I installed both boost and python through macports. I dragged the macports Python framework (/opt/local/Library/Frameworks/Python.framework) into the project and tried the most minimal program possible:
#include <boost/python.hpp>
int main(int argc, const char * argv[]) {
Py_Initialize();
Py_Finalize();
return 0;
}
and get:
/opt/local/include/boost/python/detail/wrap_python.hpp:50:11: fatal error: 'pyconfig.h' file not found
Do I need to explicitly add the framework header folder to the project's header search paths? That seems irregular... so hopefully I'm just misunderstanding something?