2015-12-15 109 views
1

我遇到了使用SDL2库构建应用程序pepper_46的问题。我搜索了互联网,终于找到了Google的webports,这使我能够正确地编译SDL2以获得pnacl。Google的Native Client和编译SDL2

我有现在实际上是与makefile文件编译的一切问题......

这是最起码的C++文件我试图编译调用SDL_Init:

#include "ppapi/cpp/instance.h" 
#include "ppapi/cpp/module.h" 
#include "SDL2/SDL.h" 

class firstInstance : public pp::Instance { 
public: 
    explicit firstInstance(PP_Instance instance) : pp::Instance(instance) { 
    SDL_Init(SDL_INIT_VIDEO); 
    } 

    virtual ~firstInstance() {} 
}; 

class firstModule : public pp::Module { 
    public: 
    firstModule() : pp::Module() {} 
    virtual ~firstModule() {} 

    virtual pp::Instance* CreateInstance(PP_Instance instance) { 
    return new firstInstance(instance); 
    } 
}; 

namespace pp { 
    Module* CreateModule(){ 
    return new firstModule(); 
    } 
} 

我也有

# Copyright (c) 2013 The Chromium Authors. All rights reserved. 
# Use of this source code is governed by a BSD-style license that can be 
# found in the LICENSE file. 

# GNU Makefile based on shared rules provided by the Native Client SDK. 
# See README.Makefiles for more details. 

VALID_TOOLCHAINS := pnacl 

NACL_SDK_ROOT ?= $(abspath $(CURDIR)/..) 

TARGET = first 

include $(NACL_SDK_ROOT)/tools/common.mk 

LIBS = SDLmain SDL2 ppapi_gles2 ppapi_simple ppapi_cpp nacl_io ppapi pthread 

CFLAGS = -Wall -std=c++11 
SOURCES = first.cc 

# Build rules generated by macros from common.mk: 

$(foreach src,$(SOURCES),$(eval $(call COMPILE_RULE,$(src),$(CFLAGS)))) 

# The PNaCl workflow uses both an unstripped and finalized/stripped binary. 
# On NaCl, only produce a stripped binary for Release configs (not Debug). 
ifneq (,$(or $(findstring pnacl,$(TOOLCHAIN)),$(findstring Release,$(CONFIG)))) 
$(eval $(call LINK_RULE,$(TARGET)_unstripped,$(SOURCES),$(LIBS),$(DEPS))) 
$(eval $(call STRIP_RULE,$(TARGET),$(TARGET)_unstripped)) 
else 
$(eval $(call LINK_RULE,$(TARGET),$(SOURCES),$(LIBS),$(DEPS))) 
endif 

$(eval $(call NMF_RULE,$(TARGET))) 

但我得到的最好的是这样的错误:

,希望它会正确编译做出我的makefile一些改变
bobkingof12vs$ make serve 
    CXX pnacl/Release/first.o 
    LINK pnacl/Release/first_unstripped.bc 
/nacl/pepper_46/lib/pnacl/Release/libppapi_simple.a: error: undefined reference to 'PSUserMainGet' 
make: *** [pnacl/Release/first_unstripped.bc] Error 1 

我读的建议,有人固定的类似问题与-Wl,--undefined=PSUserMainGetldflag后...但我无法弄清楚如何将它添加到正确生成文件......如果是这样,即使正确固定。我还看到他们的LIBS错误的顺序...并将SDL2ppapi_simple列入两次为其他人工作的列表。他们都是旧帖子,虽然我没有尝试过任何工作(不是我一定会尝试正确的)

我非常失落...任何帮助,将不胜感激。

谢谢

回答

0

好吧,我发现了几个来源,帮助我终于弄明白......

所以,在做后webports的处理以获得正确安装SDL,我继续我的追捕正确的makefile使用。

终于找到了一个在gituhub:https://github.com/emscripten-ports/SDL2/blob/master/test/nacl/Makefile(它看起来比正常的NaCl的makefile有很大不同!)

凭借什么在这里做一个说明:https://github.com/emscripten-ports/SDL2/blob/master/docs/README-nacl.md

我需要做的唯一的其他东西被添加到我的c + +代码的这个函数:

int SDL_main(int argc, char *argv[]){ 
    return 0; 
} 

我的代码现在编译说至少!立即崩溃,但编译!

我会发布更多,如果我发现缺少的东西有帮助

+0

我仍然收到相同的错误。我使用辣椒版本是47. libppapi_simple.a:错误:未定义引用'PSUserMainGet' –

+0

我知道这是半年前,但你是否得到它正常工作?如果是这样,那么知道你做了什么会很有帮助。 – Zendel

+0

对不起,这些是我有的唯一笔记,自从这篇文章以来没有用过它。 – bobkingof12vs

相关问题