0

我真的很惊讶,今天我下载了 Ubuntu 12 LTS 32bit 并安装了 build essential。

然后我为我的项目创建了一个makefile,我只是从互联网上的另一个项目复制粘贴并编辑了一点以启用C++11的东西,如果它需要GLM的东西?

无论如何,makefile:

GPP = g++
GCC = gcc
plugin_OUTFILE = "./QuaternionStuff.so"

COMPILE_FLAGS = -std=c++0x -m32 -O3 -fPIC -c -I ./ -w -D LINUX -D PROJECT_NAME=\"plugin\"

plugin = -D plugin $(COMPILE_FLAGS)

all: plugin

clean:
    -rm -f *~ *.o *.so

plugin: clean
    $(GPP) $(plugin) ./*.cpp
    $(GPP) -std=c++0x -m32 --static -fshort-wchar -shared -o $(plugin_OUTFILE) *.o

现在,当我运行它时,linux 会吐出错误,我真的不明白它们..

现在,代码可以在 Windows 上运行,编译良好,具有最高警告级别等,这很好!

但是 g++ 程序对此有些不满意:

no matching function for call to ‘GetPitchYawBetweenCoords(glm::vec3, glm::vec3, glm::vec2&)’
note: glm::vec2 GetPitchYawBetweenCoords(glm::vec3&, glm::vec3&)
note:   candidate expects 2 arguments, 3 provided

//prototypes:
inline glm::vec2 GetPitchYawBetweenCoords(glm::vec3 &source, glm::vec3 &target);
inline void GetPitchYawBetweenCoords(glm::vec3 &source, glm::vec3 &target, glm::vec2 &output);

以及代码,以及调用它的相应函数:

//the call
inline void AmxSetVector3(AMX * amx, cell * &params, unsigned char startpos, glm::vec3 vector)
{
    //some code here
}

inline void AmxSetVector2Inverse(AMX * amx, cell * &params, unsigned char startpos, glm::vec2 vector)
{
    //some code here
}

static cell AMX_NATIVE_CALL GetPitchYawBetweenPositions( AMX* amx, cell* params )
{
    glm::vec2 rot;
    GetPitchYawBetweenCoords(AmxGetVector3(params,1),AmxGetVector3(params,4),rot);
    AmxSetVector2Inverse(amx,params,7,rot);
    return 1;
}

它怎么能区分这两个非常不同的功能(原型)?这是所有错误中最令人困惑的部分,但还有更多:(

我看不出有什么问题。

所以,我要做的是:我改变(非常痛苦,因为现在我的代码变得古怪,因为我需要改变一切只是为了 linux 分发)将函数更改为不同的名称,我只是在末尾添加了一个“R”第二个原型,但随后又出现了大量错误..

In function ‘cell SomeFunction(AMX*, cell*)’:
error: invalid initialization of non-const reference of type ‘glm::vec3& 
{aka glm::detail::tvec3<float>&}’ from an rvalue of type ‘glm::detail::tvec3<float>’

这又是……在相同的功能上……:

static cell AMX_NATIVE_CALL GetPitchYawBetweenPositions( AMX* amx, cell* params )
{
    glm::vec2 rot;
    GetPitchYawBetweenCoords(AmxGetVector3(params,1),AmxGetVector3(params,4),rot);
    AmxSetVector2Inverse(amx,params,7,rot);//HERE
    return 1;
}

到底是怎么回事?我不知道如何解决这个问题..

G++版本是4.6

4

1 回答 1

1

显然,AmxGetVector3返回一个glm::detail::tvec3<float>.
根据标准,这个临时对象不能绑定到非常量引用(这是第二条消息试图告诉你的)。

不幸的是,Visual C++ 有一个愚蠢的非标准扩展,默认启用,它允许这种绑定。

更改您的函数以具有这些(常量正确)原型:

inline glm::vec2 GetPitchYawBetweenCoords(const glm::vec3 &source, const glm::vec3 &target);
inline void GetPitchYawBetweenCoords(const glm::vec3 &source, const glm::vec3 &target, glm::vec2 &output);
于 2013-08-01T05:41:39.363 回答