NetBeans提供了段错误,使用终端运行prgram不

时间:2015-06-08 11:14:01

标签: c++ netbeans opencl

我遇到了一个非常奇怪的问题。 当通过NetBeans运行我非常简单的一个文件程序时,我有以下错误:

RUN FINISHED; Segmentation fault; core dumped; real time: 150ms; user: 0ms; system: 0ms

我的跑步命令很简单./Name-Of-The-File。

当我使用终端并cd到包含该程序的文件夹并运行相同的命令时,我得到以下输出:

Hullo
PLatform Number is : 1
Hullo

(请注意,添加了Hullos以确定segfault发生的位置,因为我在main()中的第一行打印了Hullo。)

以下是该计划的代码:

/* 
 * File:   main.cpp
 * Author: sysgen
 *
 * Created on June 4, 2015, 7:08 PM
 */

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <utility>
#include <CL/cl.hpp>

const std::string hw("Hello World \n");

/*
 * 
 */

//OpenCL Error checking function

inline void checkErr(cl_int err, const char *name){
    if (err != CL_SUCCESS){
        std::cerr << "FATAL OPENCL ERROR: " << name << "( " << err << ") " << std::endl;
        exit(EXIT_FAILURE);
    }
}

int main(void) {
    //Creating an OpenCL context

    std::cout << "Hullo" << std::endl;

    cl_int err;
    std::vector< cl::Platform > platformList; //We make a vector which will contain the platforms
    cl::Platform::get(&platformList);
    checkErr(platformList.size() !=0 ? CL_SUCCESS : -1, "cl::Platform::get");
    std::cerr << "PLatform Number is : " << platformList.size() << std::endl;
    std::string platformVendor;
    platformList[0].getInfo((cl_platform_info)CL_PLATFORM_VENDOR, &platformVendor);

    std::cout << "Hullo" << std::endl;

    return 0;
}

此错误也会出现在代码块中。 gdb提供了更多详细信息:

Building to ensure sources are up-to-date
Selecting target: 
Debug
Adding source dir: /home/sysgen/NetBeansProjects/OpenCL SVOGL/
Adding source dir: /home/sysgen/NetBeansProjects/OpenCL SVOGL/
Adding file: /home/sysgen/NetBeansProjects/OpenCL SVOGL/bin/Debug/OpenCL SVOGL
Changing directory to: "/home/sysgen/NetBeansProjects/OpenCL SVOGL/."
Set variable: LD_LIBRARY_PATH=.:/opt/AMDAPPSDK-3.0-0-Beta/lib/x86_64/:/usr/lib32
Starting debugger: /usr/bin/gdb -nx -fullname  -quiet  -args "/home/sysgen/NetBeansProjects/OpenCL SVOGL/bin/Debug/OpenCL SVOGL"
done
Registered new type: wxString
Registered new type: STL String
Registered new type: STL Vector
Setting breakpoints
Reading symbols from /home/sysgen/NetBeansProjects/OpenCL SVOGL/bin/Debug/OpenCL SVOGL...(no debugging symbols found)...done.
Debugger name and version: GNU gdb (Ubuntu 7.9-1ubuntu1) 7.9
Program received signal SIGSEGV, Segmentation fault.
In ?? () ()
177 dlerror.c: No such file or directory.
#1  0x00007ffff70dd6fd in init () at dlerror.c:177

0 个答案:

没有答案