小编ano*_*ard的帖子

库已链接但引用未定义

我正在尝试用UIDntu编译一个openCL程序,其中NVIDIA卡曾经使用过一次,

#include <CL/cl.h>
#include <iostream>
#include <vector>

using namespace std;

int main() {
  cl_platform_id platform;
  cl_device_id device;
  cl_context context;
  cl_command_queue command_queue;
  cl_int error;

  if(clGetPlatformIDs(1, &platform, NULL) != CL_SUCCESS) {
    cout << "platform error" << endl;
  }

  if(clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, 1, &device, NULL) != CL_SUCCESS) {
    cout << "device error" << endl;
  }

  context = clCreateContext(NULL, 1, &device, NULL, NULL, &error);
  if(error != CL_SUCCESS) {
    cout << "context error" << endl;
  }

  command_queue = clCreateCommandQueue(context, device, 0, &error);
  if(error != CL_SUCCESS) { …
Run Code Online (Sandbox Code Playgroud)

c++ ubuntu linker opencl

34
推荐指数
3
解决办法
5万
查看次数

gcc cc1:内存不足分配

我正在尝试使用Angstrom Linux在我的BeagleBoard中编译源代码.昨天我能够编译我的代码.但今天我无法编译代码,它说:

ccl: out of memory allocating 268439608 bytes after a total of 405504 bytes
make *** [getimagefromcam1.o] Error 1
Run Code Online (Sandbox Code Playgroud)

我的编译字符串是:

gcc getimagefromcam1.c `pkg-config --cflags --libs opencv` -o getimagefromcam1 -lpthread
Run Code Online (Sandbox Code Playgroud)

代码是:

#include <cv.h>
#include <highgui.h>
#include <cxcore.h>
#include <stdio.h>

int main(int argc, char* argv[])
{    
  CvCapture* camera = cvCreateCameraCapture(0); // Use the default camera

  IplImage*     frame = 0;
  IplImage      img;

  cvSetCaptureProperty(camera,CV_CAP_PROP_FRAME_WIDTH,2016) ;
  cvSetCaptureProperty(camera,CV_CAP_PROP_FRAME_HEIGHT,1512); 

  frame = cvQueryFrame(camera); //need to capture at least one extra frame
  frame = cvQueryFrame(camera);

  if (frame != …
Run Code Online (Sandbox Code Playgroud)

linux stack gcc ccl

9
推荐指数
1
解决办法
1万
查看次数

单声道gtk你好世界失败,'失踪的方法'

我是第一次尝试单声道.以下是我设置它的步骤.

在VirtualBox中安装了Kubuntu 12.04 LTS

apt-get install mono-complete gtk-sharp2
Run Code Online (Sandbox Code Playgroud)

然后我尝试在本教程中运行hello world应用程序.

http://www.mono-project.com/Mono_Basics

命令行应用程序运行正常.

我按照说明使用以下命令编译了GTK应用程序:

gmcs hello.cs -pkg:gtk-sharp-2.0
Run Code Online (Sandbox Code Playgroud)

当我运行应用程序时,它失败并出现以下错误:

Missing method System.Type::op_Inequality(Type,Type) in assembly /usr/lib/mono/2.0/mscorlib.dll, referenced in assembly /usr/lib/mono/gac/gtk-sharp/2.12.0.0__35e10195dab3c99f/gtk-sharp.dll

Unhandled Exception: System.MissingMethodException: Method not found: 'System.Type.op_Inequality'.
  at Gtk.Window..ctor (System.String title) [0x00000] in <filename unknown>:0
  at Hello.Main () [0x00000] in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.MissingMethodException: Method not found: 'System.Type.op_Inequality'.
  at Gtk.Window..ctor (System.String title) [0x00000] in <filename unknown>:0
  at Hello.Main () [0x00000] in <filename unknown>:0
Run Code Online (Sandbox Code Playgroud)

对我来说,单声道库看起来与gtk-sharp库不兼容.

有没有人对如何使这个工作有任何建议?

gtk mono gtk#

7
推荐指数
1
解决办法
5023
查看次数

使用"C"执行API将sqlite3表导出到文件中

我在fedora 14中使用sqlite3版本3.6.23.1.我能够使用这样的命令提示符将表导出到文件中,

sqlite3 data.db

sqlite> .output sample.txt;

sqlite> select *from sample;
Run Code Online (Sandbox Code Playgroud)

我想在应用程序级别处理此案例.

我正在使用sqlite3开源"C"API在应用程序级别执行此命令.

execute("delete from sample:);// working fine

execute(".output sample.txt"); //Not working
Run Code Online (Sandbox Code Playgroud)

它的投掷错误叫做 "SQL error in sqlite3_exec: near ".": syntax error"

请建议我如何使用此API创建文件以导入数据.

API的功能定义.

int execute(const char* fmt, ...)
{

    char *err_messg;

    int ret = 0, result = 0;

    char sql_string[1024] = ""; //this honestly needs to be more elegant; will do for now

    va_list args;

    va_start(args, fmt);

    ret = vsprintf(sql_string, fmt, args);

    va_end(args);

    printf("sql_string: %s\n", sql_string);

    if (!ret)
        result = …
Run Code Online (Sandbox Code Playgroud)

c sqlite

6
推荐指数
2
解决办法
4697
查看次数

在课堂上使用枚举会是公开的,为什么?

我正在使用enum进行我正在进行的课程,我正在使用Google查找示例以确保我正确使用枚举.我去了几个网站,包括MSDN网站和枚举列在公共而不是私人.我一直认为数据成员是私有的.我是不是基地,如果是这样的话为什么?

c++ enums private public

5
推荐指数
2
解决办法
732
查看次数

在c中使用malloc和结构

所以我正在尝试将malloc添加到我创建的电话簿应用程序中,但由于我是C的新手,我不确定我所做的是否正确.我遇到了一个小问题,但是我已经阅读了我所拥有的初学者书籍,但它并没有像我想的那样详细,我无法通过搜索Google来判断我是否只是我如何设置malloc完全错误,或者我错过了什么.

基本上,我有4个阵列在我的结构First_Name,Last_name,home,cell.其中每个都有2个功能,一个从用户获取信息的功能和一个打印并将用户信息添加到电话簿的功能.我现在所拥有的是原始代码的一小部分,它只将第一个名称添加到电话簿中(因此它不是整个代码),并且在每个获取用户输入的函数中,我想添加malloc函数.现在我只有第一个名字和第一个malloc设置,但问题是,当我去检查电话簿以查看名称是否输入成功时,程序退出.如果我取出malloc,它可以成功运行.

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <conio.h>

#define BUFFER 50
    //Structure for contacts
typedef struct friends_contact {

    char *First_Name;
    char *Last_Name;
    char *home;
    char *cell;
} fr;

void menu(fr * friends, int *counter, int user_entry, int i);
void setFirst(fr *, int *, int i);
char getFirst(fr *, int i);
void add_contact(fr * friends, int *counter, int i);
void print_contact(fr * friends, int *counter, int i);

int main()
{

    int …
Run Code Online (Sandbox Code Playgroud)

c malloc struct

4
推荐指数
1
解决办法
3万
查看次数

如何在使用夹板工具检查源代码时包含头文件?

我创建了2个C程序源代码文件和一个只包含函数声明的头文件.

mypattern.h

 #include<stdio.h>
void pattern_check(char *,int,char *);
Run Code Online (Sandbox Code Playgroud)

pattern_main.c

    #include<mypattern.h>
int main(int argc,char *argv[])
{
 int i,max,flag=1;
 char *p,*cmd="end";
 if(argc!=3)
 {
  printf("usage : Invalid no of arguments\n");
  return 0;
 }
 max=atoi(argv[1]);
 char elements[max][15];
 printf("\nEnter the %d input strings :\n",max);
 for(i=0;i<max;i++)
 {
   p=elements[i];
  // printf("%u\n",p);
   scanf("%s",p);
//   printf("%s-->%u\n",p,p);
  if(*p==*cmd)
  {
   flag=0;
   max=i;
   break;
  }
 }
 if(flag)
 p=p-(sizeof(char)*((max-1)*15));
 else
 p=p-(sizeof(char)*((max)*15));
 pattern_check(p,max,argv[2]);
 return 0;
}
Run Code Online (Sandbox Code Playgroud)

pattern_search.c

  #include<mypattern.h>
void pattern_check(char *elements,int max,char *pattern)
{
 int i,count=0,len=0;
 char *ptr,*ch,*pat[max],*output=NULL;
// printf("\nPattern : %s\n",pattern);
 for(i=0;i<max;i++)
 {
 // …
Run Code Online (Sandbox Code Playgroud)

linux parsing splint

2
推荐指数
1
解决办法
5003
查看次数

如何在c中强制printf返回负值?

我需要编写一个printf应返回负值的 C 程序。它应该是这样的:

#include <stdio.h>
int main()
{
    int ret_val;
    ret_val = printf(something);
    printf("%d", ret_val);
}
Run Code Online (Sandbox Code Playgroud)

这个的输出应该是一个负数(ret_val应该是负数)。

c printf return-value

2
推荐指数
1
解决办法
1215
查看次数

C中的可变函数

1)为什么/* test1 */块下的代码不打印任何东西,但是/* test2 */打印的代码是否正确?

2)如何va_arg(va, char*)/* test 1 */代码块中使用.


void rdfDBG(int dbglevel, const char *fmt, ...) {

    va_list va;

#if 1 /* test 1 */
    char* logbuf;

    if ((logbuf = calloc(0x0, LOGBUFFERSIZE))== NULL)
        fprintf(stderr, "out of memory\n"); /* 1. Is there a better way instead of using fprintf? */

    va_start(va, fmt);
    (void) vsnprintf(logbuf, strlen(logbuf), fmt, va); /* 2. print nothing */
    va_end(va);

    free(logbuf);
#endif

#if 0 /* test 2 */
    va_start(va, …
Run Code Online (Sandbox Code Playgroud)

c variadic-functions

1
推荐指数
1
解决办法
544
查看次数

运算符优先级和三元运算符

我的C语言有问题。

#include<stdio.h>
int main()
{
    int a = 10, b = 0, c = 7;
    if (a ? b : c == 0)
        printf("1");
    else if (c = c || a && b)
        printf("2");
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

这段代码显示2,但是我认为a:b:c返回b = 0,0 == 0返回1。您能解释一下代码吗?

c operator-precedence ternary

1
推荐指数
1
解决办法
2940
查看次数

Gtk 和 gstreamer 链接器错误

我正在尝试从谷歌代码编译简单的GST 播放器。我已经修复并安装了丢失的库,现在我收到链接器错误

\n\n
vickey@tb:~/work/gst-player-0.0.0$ make\ngcc -ggdb -Wall -W -Wformat-nonliteral -Wcast-align -Wpointer-arith -Wbad-function-cast -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations -Winline -Wundef -Wnested-externs -Wcast-qual -Wshadow -Wwrite-strings -Wno-unused-parameter -Wfloat-equal -pedantic -ansi -std=c99 `pkg-config --cflags gtk+-2.0` `pkg-config --libs gtk+-2.0` `pkg-config --cflags gstreamer-0.10` `pkg-config --libs gstreamer-0.10` -lgstinterfaces-0.10 ui.c gst-backend.c -o gst-player\nIn file included from /usr/include/gtk-2.0/gtk/gtk.h:236:0,\n                 from ui.c:19:\n/usr/include/gtk-2.0/gtk/gtkitemfactory.h:47:1: warning: function declaration isn\xe2\x80\x99t a prototype [-Wstrict-prototypes]\nui.c: In function \xe2\x80\x98toggle_fullscreen\xe2\x80\x99:\nui.c:60:9: warning: passing argument 1 of \xe2\x80\x98gtk_window_unfullscreen\xe2\x80\x99 from incompatible pointer type [enabled by default]\n/usr/include/gtk-2.0/gtk/gtkwindow.h:340:10: note: expected \xe2\x80\x98struct GtkWindow *\xe2\x80\x99 but …
Run Code Online (Sandbox Code Playgroud)

c++ gtk gstreamer

1
推荐指数
1
解决办法
8029
查看次数