我遇到了使用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=PSUserMainGet
的ldflag
后...但我无法弄清楚如何将它添加到正确生成文件......如果是这样,即使正确固定。我还看到他们的LIBS
错误的顺序...并将SDL2
和ppapi_simple
列入两次为其他人工作的列表。他们都是旧帖子,虽然我没有尝试过任何工作(不是我一定会尝试正确的)
我非常失落...任何帮助,将不胜感激。
谢谢
我仍然收到相同的错误。我使用辣椒版本是47. libppapi_simple.a:错误:未定义引用'PSUserMainGet' –
我知道这是半年前,但你是否得到它正常工作?如果是这样,那么知道你做了什么会很有帮助。 – Zendel
对不起,这些是我有的唯一笔记,自从这篇文章以来没有用过它。 – bobkingof12vs