小编Rob*_*n92的帖子

从LD_LIBRARY_PATH中删除条目

我正在试验Linux共享库并export LD_LIBRARY_PATH=/path/to/library:${LD_LIBRARY_PATH}$ LD_LIBRARY_PATH中添加了一个entry().现在我希望它消失了.我怎样才能做到这一点?

PS.echo $LD_LIBRARY_PATH在我添加条目之前打字给了我一个空行.现在它说:

路径/到/库:

linux shared-libraries

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

组件坐标

我正在尝试获得与其父级相关的组件坐标.例如,当我有一个JFrame的大小500×500,其中有一个孩子- 的JPanel -在[50,10]我应该得到[50,10]结果.无论看起来多么简单,我一直都会遇到错误的坐标([0,0][ 3,24 ]).

这是我的JPanel代码:

class MyPanel extends JPanel implements MouseListener { 
    private Component parent;   
    private String strName;

    public MyPanel(Component pr, String name, int w, int h) {
        super();

        parent = pr;
        strName = new String(name);

        this.setLayout(null);
        this.setSize(w, h);
        this.setBackground(Color.WHITE);
        this.addMouseListener(this);

        this.setVisible(true);
    }

    /* MouseListener implementation */
    public void mouseClicked(MouseEvent event) {
            int x = event.getX(); int y = event.getY();
            Point pnt = new Point(SwingUtilities.convertPoint(this, …
Run Code Online (Sandbox Code Playgroud)

java swing point mouse-listeners swingutilities

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

减少内存分配GCC命令

今天,在我的计算机sciene课程中,我被告知我可以调整程序在编译期间可以分配的内存量(使用GCC,Linux).默认情况下,此数量设置为最佳模式(这意味着尽可能多).

在调试我的应用程序期间,我可以从这个编译器功能中受益匪浅,因为我需要正确处理分配错误,这在我的具有超过16 GB RAM的PC上非常棘手.

有谁知道这个选项是什么?我希望gcc --maxalloc 1024,这意味着我的程序将能够分配最多1024字节的内存.

c++ linux gcc memory-management

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

JApplet和KeyListener

我正在为我的计算机科学课开发一个应用程序.任务是编写计算器,但不使用JTextFields或JTextAreas.我想出了一个实现的想法,KeyListener在appletviewer中都很好用JFrame但在Google Chrome(可能还有其他浏览器)中根本不起作用.

这是我的代码片段.

//- BinaryCalc.java
import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;

public class BinaryCalc extends JApplet implements KeyListener {

    private JPanel panel;

    public BinaryCalc() {
        super();

        panel = new JPanel();
        this.add(panel);

        panel.addKeyListener(this);
        panel.requestFocusInWindow();
    }

    @Override
    public void init() {
        JOptionPane.showMessageDialog(this, "applet");
        panel.setFocusable(true);
        panel.requestFocus();
    }

    public void keyPressed(KeyEvent e) {
        JOptionPane.showMessageDialog(this, (char) e.getKeyCode());
    }

    public void keyReleased(KeyEvent e) {}

    public void keyTyped(KeyEvent e) {}

    public …
Run Code Online (Sandbox Code Playgroud)

java swing keylistener jframe japplet

3
推荐指数
2
解决办法
1968
查看次数

返回inclass结构

我有一个具有以下结构的模板类

//CFoo.hpp (header file)
template <typename T>
class CFoo {
        struct SFoo {
            T *ptr;
            /* rest is irrelevant */
        } *foo;

    public:
    /* omitting irrelevant parts */
    SFoo* get();
};
Run Code Online (Sandbox Code Playgroud)

现在,如果我在头文件中实现方法SFoo*get()一切都很好.但是,如果我将声明和定义分开,我的代码将停止使用以下编译错误.

//CFoo.cpp (source code, example 1)
/* omitting irrelevant parts */
template <typename T>
SFoo* CFoo<T>::get() { return foo; } //ERROR HERE
Run Code Online (Sandbox Code Playgroud)

错误: <where-is-the-error>: error: ‘SFoo’ does not name a type

//CFoo.cpp (source code, example 2)
/* omitting irrelevant parts */
template <typename T>
CFoo<T>::SFoo* CFoo<T>::get() { …
Run Code Online (Sandbox Code Playgroud)

c++ templates class

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

读取文件,损坏的数据

好像我不能编译我的GLSL着色器.偶尔(主要是在编辑文件之后),编译时出现以下错误:

----- SRC ----- (150 B)
#version 330 core

uniform mat4 mvpMatrix;

in vec4 vertexPosition_modelspace;

void main() {
    gl_Position = mvpMatrix * vertexPosition_modelspace;
}
gp!
----- END -----
SimpleTransform.vertexshader:Vertex shader failed to compile with the following errors:
ERROR: 0:10: error(#132) Syntax error: 'gp' parse error
ERROR: error(#273) 1 compilation errors.  No code generated
Run Code Online (Sandbox Code Playgroud)

这很奇怪,因为我发誓该文件不包含那个尴尬的gp!部分.不过我用调查过它

#version 330 core

uniform mat4 mvpMatrix;

in vec4 vertexPosition_modelspace;

void main() {
    gl_Position = mvpMatrix * vertexPosition_modelspace;
}
Run Code Online (Sandbox Code Playgroud)

而且更少 …

c++ linux opengl glsl glfw

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

动态/ Onspot JTextfield到JLabel

我想在StackOverflow上创建一对JTextField/JLabel,我的意思是我希望在JLabel中显示一个字符串,因为我在JTextField中编写它.

我尝试将ActionListener添加到JTextField,但它仅适用于ENTER.有任何想法吗?

java swing jlabel dynamic jtextfield

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

使用glTexImage2D上传图像数据失败

我正在开发一个 OpenGL 应用程序,在Linux (x86_32 和 x86_64)下一切正常,但在将应用程序移植到Windows期间我遇到了困难。我的应用程序使用非常基本的OpenGL 1.0、很棒的glfw 2.7.6libpng 1.5.7。在移植整个程序之前,我尝试编写尽可能简单的代码来测试这些库是否在 Windows 下正常工作,并且一切似乎都工作得很好,直到我开始使用纹理!

在我的程序中使用纹理glTexImage2D(..)会出​​现访问冲突,并出现以下错误:

First-chance exception at 0x69E8F858 (atioglxx.dll) in sidescroll.exe: 0xC0000005: Access violation reading location 0x007C1000.
Unhandled exception at 0x69E8F858 (atioglxx.dll) in sidescroll.exe: 0xC0000005: Access violation reading location 0x007C1000.
Run Code Online (Sandbox Code Playgroud)

我做了一些研究,发现这可能是 GPU 驱动程序错误。遗憾的是,我有一台配备AMD Radeon HD5650的东芝 L650-1NU笔记本电脑,没有提供任何驱动程序,而是由供应商分发的过时驱动程序。给定帖子的作者建议使用,但由于我使用OpenGL 1.0,我无法访问此方法。 glBindBuffer

您是否知道如何在不使用较新的 OpenGL 的情况下绕过此问题?不过,如果这是唯一的解决方案,可以向我提供有关如何将OpenGL 2.1glfw一起使用的教程或代码片段吗?

这是我的代码片段,它导致了错误:

img = img_loadPNG(BACKGROUND);
if (img) {
    printf("%p %d …
Run Code Online (Sandbox Code Playgroud)

windows opengl segmentation-fault glfw

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

扩展可比较的通用

我正在开发一个基于模板的Java类,它实现了各种树结构(例如标准二叉树,红黑树或B树).我的想法是像Java Collections中的各种列表一样完成它.这是一个接口类,然后由指定的树扩展.但是,我遇到了一个奇怪的问题:

BSTree.java:12: error: BSTree is not abstract and does not override abstract method     search(Comparable) in Tree
public class BSTree<T extends Comparable<T>> extends Tree {
       ^

BSTree.java:20: error: name clash: add(T#1) in BSTree and add(T#2) in Tree have the same erasure, yet neither overrides the other
    public void add(T key) throws NullPointerException {
                ^
  where T#1,T#2 are type-variables:
    T#1 extends Comparable<T#1> declared in class BSTree
    T#2 extends Comparable<T#2> declared in class Tree

BSTree.java:28: error: method compareTo in interface Comparable<T#2> cannot …
Run Code Online (Sandbox Code Playgroud)

java generics icomparable

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