I installed Cilk successfully on my home computer, a 32-bit machine running Ubuntu. I replicated the process to the best of my knowledge on my 64-bit Ubuntu netbook, excepting, of course, that I downloaded the 64-bit version instead of the 32-bit version. When attempting to run the very simple cilkexample.c copied below, however, I get very very many errors, all seeming related to it not having access to library files:
In file included from /usr/include/stdio.h:28,
from cilkexample.c:1:
/usr/include/features.h:323:26: error: bits/predefs.h: No such file or director\
y
/usr/include/features.h:356:25: error: sys/cdefs.h: No such file or directory
/usr/include/features.h:388:23: error: gnu/stubs.h: No such file or directory
In file included from cilkexample.c:1:
/usr/include/stdio.h:36:25: error: bits/types.h: No such file or directory
/usr/include/stdio.h:161:28: error: bits/stdio_lim.h: No such file or directory
/usr/include/stdio.h:846:30: error: bits/sys_errlist.h: No such file or directo\
ry
In file included from /usr/include/stdio.h:34,
from cilkexample.c:1:
/usr/local/cilk/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.2.4/include/stddef.h:\
214: error: expected constructor, destructor, or type conversion before ‘typede\
f’
In file included from cilkexample.c:1:
/usr/include/stdio.h:49: error: expected constructor, destructor, or type conve\
rsion before ‘typedef’
et cetera, et cetera, et cetera.
Here is the file I attempted to compile with the command cilk++ -o cilkexample cilkexample.c:
#include <stdio.h>
#include <cilk.h>
int foo() {
return 100;
}
int bar() {
return 50;
}
int cilk_main(int argc, char **argv) {
int x, y;
x = cilk_spawn foo();
y = cilk_spawn bar();
cilk_sync;
printf("Got %d %d, expecting %d %d\n", x, y, 100, 50);
return 0;
}
Again, I think this has to be a configuration problem. The code is unmodified from the working version our professor distributed, which I tested on a separate machine.
Last bit of information I can think of is the PATH.
******#********:~/Path/To/Cilk$ echo $PATH
/usr/local/cilk/bin/:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
Thanks for your help!
Looks like you are missing some headers. You say you are on Ubuntu in which headers are distributed in xxx-dev packages.
Googling for some of the headers in your error I found that bits/types.h are part of libc6-dev on Debian, you should check that you have that package at least.
You should check with your distro in what package the files appear, I don't have a Debian or Ubuntu machine available to check on right now.
Edit: I found myself an Ubuntu box and it looks like libc6-dev contains all the files listed at least. dpkg-query -S [file] gives you package name
Related
I am struggling to understand linking process in c. (I am new in C) When I make object a test code in my local directory (plplotExample.c and mathglExample) some complain that header are not there even though I have them in usr/local/...., except for mathglExample. The test codes are below:
plotExample.c
#include "plConfig.h"
#include "plcdemos.h"
#define NSIZE 101
int
main( int argc, char *argv[] )
{
PLFLT x[NSIZE], y[NSIZE];
PLFLT xmin = 0., xmax = 1., ymin = 0., ymax = 100.;
int i;
// Prepare data to be plotted.
for ( i = 0; i < NSIZE; i++ )
{
x[i] = (PLFLT) ( i ) / (PLFLT) ( NSIZE - 1 );
y[i] = ymax * x[i] * x[i];
}
// Parse and process command line arguments
plparseopts( &argc, argv, PL_PARSE_FULL );
// Initialize plplot
plinit();
// Create a labelled box to hold the plot.
plenv( xmin, xmax, ymin, ymax, 0, 0 );
pllab( "x", "y=100 x#u2#d", "Simple PLplot demo of a 2D line plot" );
// Plot the data that was prepared above.
plline( NSIZE, x, y );
// Close PLplot library
plend();
exit( 0 );
}
the error message is :
plplotExample.c:2:10: fatal error: plConfig.h: No such file or directory
mathglExample.c
#include <mgl2/mgl_cf.h>
int main()
{
HMGL gr = mgl_create_graph(600,400);
mgl_fplot(gr,"sin(pi*x)","","");
mgl_write_frame(gr,"test.png","");
mgl_delete_graph(gr);
}
the error message is
In file included from /usr/include/mgl2/mgl_cf.h:29:0,
from mathglExample.c:1:
/usr/include/mgl2/data_cf.h:513:17: error: expected ‘,’ or ‘;’ before ‘mgl_find_roots’
how to fix linking or should I bring all codes and libraries under one directory? I am using linux opensuse leap 15.2 and Geany as c editor.
plConfig.h has to be in the same directory as plotExample.c.
In the file /usr/include/mgl2/data_cf.h, on the line 513, at the column 17, the compiler expects a ',' or a ';' before mgl_find_roots
As already mentioned, inclusion is not linking. You have in case 1 a file not found error and in case 2 an error in the source code.
Read this on how to include header files: Source file inclusion (or since you're using linux and geany, the compiler is presumably gcc: GNU CPP Header Files)
Try to read and understand the compiler messages.
Addendum (based on your comment)
-I plplot is a relative directory. That means, the compiler is searching in your current working directory for a directory named plplot. Either use the compiler option -I /usr/include/plplot or use the following inclusion in your source files (without the -I compiler option):
#include <plplot/the_relevant_header_file.h>
As I understand it, the 'pl...' headers are part of a third party lib (that your project depends on) and is installed e.g. by the system or make, in either case, don't pick random headers (from that project) and relocate them and try to include them from that directory. Because, the headers itself might (presumably) include other headers from that lib. In such a case, use either the -I option (not recommended) or avoid the compiler option (recommended) and include from the system path as described in my example above. The reason for that is, that from your include directive (#include <plplot/...>) you're able to see, from which library you (and not only you, but most importantly others) are including the symbols from.
I am trying to use OpenBLAS libraries. I have downloaded the pre compiled libraries OpenBLAS-v0.2.14-Win64-int64.zip from http://sourceforge.net/projects/openblas/files/v0.2.14/. I extracted the archives to my C:\ directory. Then I've tryied to run this simple c program:
#include <cblas.h>
#include <stdio.h>
void main()
{
int i=0;
double A[6] = {1.0,2.0,1.0,-3.0,4.0,-1.0};
double B[6] = {1.0,2.0,1.0,-3.0,4.0,-1.0};
double C[9] = {.5,.5,.5,.5,.5,.5,.5,.5,.5};
cblas_dgemm(CblasColMajor, CblasNoTrans, CblasTrans,3,3,2,1,A, 3, B, 3,2,C,3);
for(i=0; i<9; i++){
printf("%lf ", C[i]);}
printf("\n");
}
using this command:
C:\Users\MWAHAHA\Documents\Programas>x86_64-w64-mingw32-gcc -o hello -IC:\OpenBLAS-v0.2.14-Win64-int64\include -LC:\OpenBLAS-v0.2.14-Win64-int64\lib\libopenblas -libopenblas testeoblas.c
and got the following message:
C:/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/5.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -libopenblas
collect2.exe: error: ld returned 1 exit status
Also, if I use this command:
C:\Users\MWAHAHA\Documents\Programas>x86_64-w64-mingw32-gcc -o hello -IC:\OpenBLAS-v0.2.14-Win64-int64\includes testeoblas.c
I got this message:
testeoblas.c:1:19: fatal error: cblas.h: No such file or directory
compilation terminated.
I am using the TDM-GCC-64 compiler.
This is probably very elementary, but I have no experience with linking libraries. What am I doing wrong?
I guess you've somehow managed to compile since this was more than 6 years ago . I'll leave a comment for future solution seekers, though:
It seems that the options -I and -L don't work. Alternatively, one can define the $CPATH and $LIBRARY_PATH variables to point to the folders containing include files and library files, respectively. (at least on Linux where both methods work).
see this blog post
I'm trying to get the ADC running on beaglebone black. The OS is Debian GNU/Linux 7.7. I'm using C language. When I try to compile the following code:
#include <stdio.h>
#include <unistd.h>
#include "pruio_c_wrapper.h"
#include "pruio_pins.h"
int main(int argc, const char *argv[]) {
PruIo *io = pruio_new(0, 0x98, 0, 1);
if (io->Errr) {
printf("Initialisation failed (%s)\n", io->Errr);
return 1;
}
if(pruio_config(io, 0, 0x1FE, 0, 4, 0)){
printf("Config failed (%s)\n", io->Errr);
return 1;
}
int a = 0;
int i;
while(1){
printf("\r%12o %12o %12o %12o %4X %4X %4X %4X %4X %4X %4X %4X\n", io->Gpio[0].Stat, io->Gpio[1].Stat, io->Gpio[2].Stat, io->Gpio[3].Stat, io->Value[1], io->Value[2], io->Value[3], io->Value[4], io->Value[5], io->Value[6], io->Value[7], io->Value[8]);
fflush(STDIN_FILENO);
usleep(1000);
}
pruio_destroy(io);
return 0;
}
But I get the following error:
undefined reference to 'pruio_new'
undefined reference to 'pruio_config'
I installed everything like FreeBasic compiler and pruss driver kit for freebasic and BBB and libpruio. I also copied all the header files in the same directory as the .c file, including "pruio_c_wrapper.h", "pruio-pins.h", "pruio.h" and all the other files in the src directory of libpruio. But it doesn't work.
Could you please tell me what to do?
Thanks
libfb is the FreeBASIC run-time library. When you want to compile against the old libpruio-0.0.x versions, you'll need an old FreeBASIC installation from
www{dot}freebasic-portal.de/dlfiles/452/bbb_fbc-0.0.2.tar.xz
Which installs /usr/local/lib/freebasic/libfb.so.
See the libpruio-0.0.x C example codes for compiler command line arguments (ie. header section of io_input.c).
But I recommend to use the new version libpruio-0.2 from (the last post links to the documentation of this new version)
http://www.freebasic-portal.de/dlfiles/592/libpruio-0.2.tar.bz2
which doesn't have this pitfalls, gcc compiles without FB installation, and provides new features like pinmuxing, PWM, CAP. There're small bugs in this versions C header, which is now named pruio.h: a missing enum and a copy / paste bug regarding a function name. See this thread for details:
http://www.freebasic.net/forum/viewtopic.php?f=14&t=22501
BR
Ok, I downloaded it, the binaries are in libpruio-0.0.2/libpruio/src/c_wrapper and so are the include files, copy the headers and libpruio.so to the same directory where the test.c file resides, and then
For the includes, you need to to append libpruio's include directory to the compiler command using -I. then you can do
#include <pruio_c_wrapper.h>
#include <pruio_pins.h>
You need to append the library to the linker command, with
-L. -lpruio
your complete compilation command will be then
gcc -o test -I. -L. -lpruio test.c
Resently I'm installed Opencv in my machine. Its working in python well(I just checked it by some eg programs). But due to the lack of tutorials in python I decided to move to c. I just run an Hello world program from http://www.cs.iit.edu/~agam/cs512/lect-notes/opencv-intro/
My program is
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <cv.h>
#include <highgui.h>
int main(int argc, char *argv[])
{
IplImage* img = 0;
int height,width,step,channels;
uchar *data;
int i,j,k;
if(argc<2){
printf("Usage: main <image-file-name>\n\7");
exit(0);
}
// load an image
img=cvLoadImage(argv[1]);
if(!img){
printf("Could not load image file: %s\n",argv[1]);
exit(0);
}
// get the image data
height = img->height;
width = img->width;
step = img->widthStep;
channels = img->nChannels;
data = (uchar *)img->imageData;
printf("Processing a %dx%d image with %d channels\n",height,width,channels);
// create a window
cvNamedWindow("mainWin", CV_WINDOW_AUTOSIZE);
cvMoveWindow("mainWin", 100, 100);
// invert the image
for(i=0;i<height;i++) for(j=0;j<width;j++) for(k=0;k<channels;k++)
data[i*step+j*channels+k]=255-data[i*step+j*channels+k];
// show the image
cvShowImage("mainWin", img );
// wait for a key
cvWaitKey(0);
// release the image
cvReleaseImage(&img );
return 0;
}
first while compiling I got the following error
hello-world.c:4:16: fatal error: cv.h: No such file or directory
compilation terminated.
and I rectify this error by compiling like this
gcc -I/usr/lib/perl/5.12.4/CORE -o hello-world hello-world.c
But now the error is
In file included from hello-world.c:4:0:
/usr/lib/perl/5.12.4/CORE/cv.h:14:5: error: expected specifier-qualifier-list before ‘_XPV_HEAD’
hello-world.c:5:21: fatal error: highgui.h: No such file or directory
compilation terminated.
Qns :
Is it this header is not installed in my system? While I'm using this command find /usr -name "highgui.h" I'm not find anything
If this header is not in my sysytem hoew I install this?
Please help me . I'm new in opencv
First check if highgui.h exists on your machine:
sudo find /usr/include -name "highgui.h"
If you find it on path lets say "/usr/include/opencv/highgui.h"
then use:
#include <opencv/highgui.h> in your c file.
or
while compiling you could add
-I/usr/include/opencv in gcc line
but then your include line in c file should become:
#include "highgui.h"
if, your first command fails that is you don't "find" highgui.h on your machine. Then clearly you are missing some package. To figure out that package name, use apt-find command:
sudo apt-find search highgui.h
on my machine, it gave me this:
libhighgui-dev: /usr/include/opencv/highgui.h
libhighgui-dev: /usr/include/opencv/highgui.hpp
if you don't have apt-find then install it first, using:
sudo apt-get install apt-find
So, now you know the package name, then issue:
sudo apt-get install libhighgui-dev
once this is done, use the find command to see where exactly, headers been installed and then use then change include path accordingly
I have the following headers in my project:
#include <opencv2/opencv.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/objdetect/objdetect.hpp>
#include <opencv2/features2d/features2d.hpp>
The version of OpenCV 2.4.2
i was trying to use clang to parse c++ code, but am unable to compile my source code because i am unable to find libclang headers.
I am running ubuntu 10.04 and have installed clang and llvm successfully from the repositories.
Please tell me where to find the file to include .
The example i am trying to run is :
#include<clang-c/Index.h>
int main(int argc, char *argv[]) {
CXIndex Index = clang_createIndex(0, 0);
CXTranslationUnit TU = clang_parseTranslationUnit(Index, 0,argv, argc, 0, 0, CXTranslationUnit_None);
for (unsigned I = 0, N = clang_getNumDiagnostics(TU); I != N; ++I) {
CXDiagnostic Diag = clang_getDiagnostic(TU, I);
CXString String = clang_formatDiagnostic(Diag,
clang_defaultDiagnosticDisplayOptions());
fprintf(stderr, "%s\n", clang_getCString(String));
clang_disposeString(String);
}
clang_disposeTranslationUnit(TU);
clang_disposeIndex(Index);
return 0;
}
Package clang-2.7 from ubuntu 10.04 http://packages.ubuntu.com/lucid/devel/clang doesnt include header file clang-c/Index.h, nor have a libclang.so:
http://packages.ubuntu.com/lucid/i386/clang/filelist
Neither do llvm-dev package: http://packages.ubuntu.com/lucid/i386/llvm-dev/filelist
So, ubuntu 10.04 have no clang package with libclang or anything related to clang development.
As Banthar suggested, you should use clang from llvm site, either built from sources (it is easy in ubuntu) or packed as binary package.
As Adam Monsen said in a comment to the accepted answer, starting from Ubuntu 13.10, the file is provided by the following package:
libclang-3.4-dev
Change version number according to your requirements. The file resides in
/usr/lib/llvm-3.4/include/clang-c/Index.h