这是命令和错误.
gcc --shared \
-m64 \
-shared-libgcc \
-Wl,--whole-archive ./release64/*.a
/usr/lib64/libc_nonshared.a(elf-init.oS): In function `__libc_csu_init':
(.text+0x1d): undefined reference to `__init_array_end'
/usr/bin/ld: /usr/lib64/libc_nonshared.a(elf-init.oS): relocation R_X86_64_PC32 against undefined hidden symbol `__init_array_end' can not be used when making a shared object
/usr/bin/ld: final link failed: Bad value
collect2: ld returned 1 exit status
make: *** [build] Error 1
Run Code Online (Sandbox Code Playgroud)
这是什么意思?
我需要一种方法来找出哪个小部件负责通过信号调用插槽.这假设我有多个小部件的信号连接到我的应用程序中的同一个插槽.
QSignalMapper似乎是一个有效的答案,但我无法弄清楚如何将触发信号的对象传递到我的插槽中.
错误:"glGenerateMipmap"没有依赖于模板参数的参数,因此'glGenerateMipmap'的声明必须可用[-fpermissive]
我有#include <GL/glext.h>包含,可以在标题中看到函数的声明,但是我得到上面的编译器错误.我在Ubuntu 13.04上安装了最新的nvidia驱动程序.我假设将定义此函数.
我对这个功能的使用是:
if (mipmapped) {
glGenerateMipmap(GL_TEXTURE_2D);
}
Run Code Online (Sandbox Code Playgroud)
为什么我的编译器会阻塞这个函数?在这种情况下,这个错误意味着什么?
你可以将结构加载到成员变量是私有的vbo中吗?
UPDATE
问题是通用的没有样本,因为我不知道如何询问具体问题.下面的答案正确到我想要的地步.但对于那些浪费时间来看这个问题的代码来说:
#ifndef POINT2D_H_INCLUDED
#define POINT2D_H_INCLUDED
#include <glext.h>
namespace glext
{
/*! \class Point 2D class geometry based
* \brief This class defines a 2D point_2d
*
* Some details about the Test class
*/
template <typename T>
class point_2d
{
private:
/// The first element in the ordered pair
T _x;
/// The second element in the ordered pair
T _y;
public:
/*! \brief default constructor sets both elements in ordered pair to 0
*/
point_2d();
/*! \brief …Run Code Online (Sandbox Code Playgroud) 我的系统配置如下:SDL2,Fedora 21,Nvidia GTX驱动程序.
[mhoggan@localhost build]$ glxinfo | grep version
server glx version string: 1.4
client glx version string: 1.4
GLX version: 1.4
OpenGL core profile version string: 4.4.0 NVIDIA 346.47
OpenGL core profile shading language version string: 4.40 NVIDIA via Cg compiler
OpenGL version string: 4.5.0 NVIDIA 346.47
OpenGL shading language version string: 4.50 NVIDIA
OpenGL ES profile version string: OpenGL ES 3.1 NVIDIA 346.47
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.10
GL_EXT_shader_implicit_conversions, GL_EXT_shader_integer_mix,
[mhoggan@localhost …Run Code Online (Sandbox Code Playgroud) 我有一个指向结构的指针,我可以使用 .gdb 在 gdb 中打印它print /x (*s)。
然而这给了我:
...,强度 = 2 '\002'},{distance_2cm = 3045,强度 = 3 '\003'},{distance_2cm = 14735,强度 = 7 '\a'},{distance_2cm = 3345,强度 = 3 '\003'},{distance_2cm = 14272,强度 = 7 '\a'},{distance_2cm = 3735,强度 = 2 '\002'},{distance_2cm = 14617,强度 = 6 '\006'},{distance_2cm = 4239,强度 = 2 '\002'},{距离_2cm = 9741,强度 = 5 '\005'},{距离_2cm = 4892,强度 = 2 '\002'},{距离_2cm = 10686,强度 = 4 '\ 004' },{distance_2cm = 6012,强度 = 3 '\003'},{distance_2cm = 9906,强度 = 3 '\003'}}},{head = {laser_block_id = 61183,rotational_theta …
我不能 100% 确定本文标题中描述的错误源自何处。它可能是上下文创建,也可能是实际的绘图代码。我将从绘图代码开始。下面的代码将使用 2.0 到 3.1 版本上下文进行渲染,但在 3.2 上下文或更高版本时停止渲染。应该注意的是,上下文是使用 glX 系列函数创建的。如果需要该代码,请在评论部分发布。我还假设 glDrawArrays 的错误与获取顶点着色器中“位置”变量的顶点属性指针时生成的错误有关?
绘制和初始化代码如下:
void start_func()
{
// Create Window
// Create Context
// Start Message Pump
// Clean Up
}
GLuint vbo;
GLuint shaderProgram;
bool compiler_errors(GLuint shaderId)
{
bool errors = false;
GLint isCompiled = 0;
glGetShaderiv(shaderId, GL_COMPILE_STATUS, &isCompiled);
GL_CALL("glGetShaderiv")
if(isCompiled == GL_FALSE) {
GLint maxLength = 0;
glGetShaderiv(shaderId, GL_INFO_LOG_LENGTH, &maxLength);
GL_CALL("glGetShaderiv")
std::vector<char> errorLog(maxLength);
glGetShaderInfoLog(shaderId, maxLength, &maxLength, &errorLog[0]);
GL_CALL("glGetShaderInfoLog")
std::stringstream out;
std::copy(errorLog.begin(), errorLog.end(),
std::ostream_iterator<char>(out, ""));
std::string errorsStr = out.str(); …Run Code Online (Sandbox Code Playgroud) 请注意,这段代码不是我写的.否则我不会问这个问题.完全归功于Jerry Coffin.无论如何,代码通过重载std :: iterator <>来生成一系列数字.
我将首先发布代码,然后我将解释我所看到的内容.如果一个专家C++成员可以纠正我,如果我错了,我将非常感激.
码
static const int N = 10;
template <class T>
class sequence : public std::iterator<std::forward_iterator_tag, T>
{
private:
T val;
public:
sequence(T init) : val(init) { }
T operator *( ) { return val; }
sequence &operator++( ) { ++val; return *this; }
bool operator != ( const sequence &other ) { return val != other.val; }
};
void foo( )
{
typedef std::vector<int> graph;
graph id1( gen_seq(0), gen_seq( N ) ); …Run Code Online (Sandbox Code Playgroud) 这来自更大的上下文,但是我已经删除了很多代码来简化问题.如果您觉得我遗漏了任何东西请告诉我.
假设您有一个模板类定义为:
#include <map>
#include <vector>
#include <string>
#include <fstream>
#include <iostream>
#include <iterator>
#include <algorithm>
template <class key, class container, class container_type>
class file_to_map
{
public:
file_to_map()
{
m_file = "";
}
file_to_map(std::string file)
{
m_file = file;
}
~file_to_map()
{
}
std::map<key, container>& get_map()
{
return m_map;
}
void set_file(const std::string file)
{
m_file = file;
}
void insert_into_map(key insert, container_type value)
{
m_map[insert].insert(value);
}
friend std::ostream& operator<< (std::ostream &out, file_to_map<key, container, container_type> &obj)
{
typedef typename std::map<key, …Run Code Online (Sandbox Code Playgroud) 我必须为 make_heap 重载什么运算符?是 () 运算符吗?如果我已经在我的算法中为另一个案例定义了它。任何人都可以提供在我的情况下使用 make_heap 的正确方法。请参阅下面的代码以更好地理解。
在我有的顶点类中
bool operator() (vertex &v) const
{
return (v.key() == _key);
}
Run Code Online (Sandbox Code Playgroud)
这在以下 std 方法 find_if 中构建图形时使用
vertex_iterator GraphComponents::graph::find_vertex_by_key(int key)
{
return std::find_if(_vertices.begin(), _vertices.end(), GraphComponents::vertex(key));
}
Run Code Online (Sandbox Code Playgroud)
现在在我的算法中,我想在不同的上下文中使用顶点作为函数对象。
std::list<int> GraphComponents::graph::breadth_first_search (int key, int start_key)
{
std::vector<GraphComponents::vertex *> heap;
for (vertex_iterator copy_iter = _vertices.begin(); copy_iter != _vertices.end(); ++copy_iter) {
heap.push_back(&(*copy_iter));
}
std::make_heap(heap.begin(), heap.end(), vertex(<should be distance>));
}
Run Code Online (Sandbox Code Playgroud)
这里我不想在比较中使用键,但我想使用距离成员,因此距离最短的顶点位于堆的顶部。短于实现我自己的堆,推荐的方法是什么?
在我看来,这应该找到我正在寻找的符号。相反,它没有找到该符号。我哪里错了?我知道该符号存在于 .jar 文件之一中。
1 ARRAY=(`find ${PWD} -name '*.jar'`);
2 SYMBOL=$1;
3 for i in ${ARRAY[@]};
4 do
5 JAR=`jar -tf $i`;
6 GREPED=`echo ${JAR} | grep -s ${SYMBOL} | tr -d ' '`;
7 if [ "${GREPED}" != "" ]; then
8 echo $GREPED
9 fi
7 done
Run Code Online (Sandbox Code Playgroud)
也许我误解了 jar 命令选项?
假设我为了好玩而下载了 android SDK,并在上面运行了一个工具,说它找不到给定的类 com.android.email.mail.Flag。所以我运行上面的脚本:
$ ./script.sh Flag
Run Code Online (Sandbox Code Playgroud)
这应该打印出jar命令的输出。如果我想要上面的 jar 文件第 8 行
echo $i.
这是带有相关错误的make命令:
g++ -g -O2 -Wl,-rpath=../../../external/boost-1.55.0-x86_64-linux-gcc-4.8.2/lib -pthread -o xml_wrapper_tester xml_wrapper_tester-runner.o -L../../../external/boost-1.55.0-x86_64-linux-gcc-4.8.2/lib -lboost-system ../xml_wrapper/.libs/libxml_wrapper.a -pthread
/usr/bin/ld: cannot find -lboost-system
Run Code Online (Sandbox Code Playgroud)
进入make文件所在的目录和ls -l指定-L的路径显示该库存在.
[mehoggan@localhost xml_wrapper_tester]$ ls -l ../../../external/boost-1.55.0-x86_64-linux-gcc-4.8.2/lib | grep system
-rw-rw-r--. 1 mehoggan mehoggan 217676 May 5 22:37 libboost_filesystem.a
lrwxrwxrwx. 1 mehoggan mehoggan 29 May 5 22:37 libboost_filesystem.so -> libboost_filesystem.so.1.55.0
-rwxrwxr-x. 1 mehoggan mehoggan 116955 May 5 22:37 libboost_filesystem.so.1.55.0
-rw-rw-r--. 1 mehoggan mehoggan 49154 May 5 22:37 libboost_system.a
lrwxrwxrwx. 1 mehoggan mehoggan 25 May 5 22:37 libboost_system.so -> libboost_system.so.1.55.0
-rwxrwxr-x. 1 mehoggan mehoggan …Run Code Online (Sandbox Code Playgroud) 鉴于以下内容:
struct tm tm;
time_t gps_epoch_to_epoch_diff;
memset(&tm, 0, sizeof(struct tm));
tm.tm_year = 70;
tm.tm_mon = 1;
tm.tm_mday = 1;
gps_epoch_to_epoch_diff = timegm(&tm);
printf("sec = %lus\n", gps_epoch_to_epoch_diff);
Run Code Online (Sandbox Code Playgroud)
我希望输出是
sec = 0s
但是,我得到了:
sec = 2678400s
为什么?