- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我目前正在尝试自定义 c++ android native 示例,以便能够更改在使用平板电脑时与 2(或 3)根手指交互时发生的行为。因此,根据我对 VTK 管道的理解,我应该修改 vtkAndroidRenderWindowInteractor 的行为(如果我错了,请纠正我)。所以这就是我到目前为止所拥有的:
myRenderInteractor.h
#include "vtkAndroidRenderWindowInteractor.h"
#include "vtkRenderingOpenGL2Module.h" // For export macro
#include "vtkRenderWindowInteractor.h"
#ifndef LOGI
#define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "NativeVTK", __VA_ARGS__))
#endif
#ifndef LOGW
#define LOGW(...) ((void)__android_log_print(ANDROID_LOG_WARN, "NativeVTK", __VA_ARGS__))
#endif
class myRenderInteractor : public vtkAndroidRenderWindowInteractor {
public:
static myRenderInteractor *New();
vtkTypeMacro(myRenderInteractor, vtkAndroidRenderWindowInteractor);
void PrintSelf(ostream& os, vtkIndent indent);
void log();
protected:
myRenderInteractor();
~myRenderInteractor();
};
myRenderInteractor.cxx
#include "myRenderInteractor.h"
vtkStandardNewMacro(myRenderInteractor);
myRenderInteractor::myRenderInteractor(){
vtkAndroidRenderWindowInteractor();
}
~myRenderInteractor::myRenderInteractor(){
~vtkAndroidRenderWindowInteractor();
}
void myRenderInteractor::log(){
// ...
}
最后在 main.cxx
#include "vtkNew.h"
#include "vtkActor.h"
#include "vtkCamera.h"
#include "vtkConeSource.h"
#include "vtkDebugLeaks.h"
#include "vtkGlyph3D.h"
#include "vtkPolyData.h"
#include "vtkPolyDataMapper.h"
#include "vtkRenderWindow.h"
#include "vtkRenderer.h"
#include "vtkSphereSource.h"
#include "vtkTextActor.h"
#include "vtkTextProperty.h"
#include "myRenderInteractor.h"
#include "vtkAndroidRenderWindowInteractor.h"
#include <android/log.h>
#include <android_native_app_glue.h>
#ifndef LOGI
#define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "NativeVTK", __VA_ARGS__))
#endif
#ifndef LOGW
#define LOGW(...) ((void)__android_log_print(ANDROID_LOG_WARN, "NativeVTK", __VA_ARGS__))
#endif
/**
* This is the main entry point of a native application that is using
* android_native_app_glue. It runs in its own thread, with its own
* event loop for receiving input events and doing other things.
*/
void android_main(struct android_app* state)
{
// Make sure glue isn't stripped.
app_dummy();
vtkNew<vtkRenderWindow> renWin;
vtkNew<vtkRenderer> renderer;
vtkNew<myRenderInteractor> iren;
// this line is key, it provides the android
// state to VTK
iren->SetAndroidApplication(state);
renWin->AddRenderer(renderer.Get());
iren->SetRenderWindow(renWin.Get());
vtkNew<vtkSphereSource> sphere;
sphere->SetThetaResolution(8);
sphere->SetPhiResolution(8);
vtkNew<vtkPolyDataMapper> sphereMapper;
sphereMapper->SetInputConnection(sphere->GetOutputPort());
vtkNew<vtkActor> sphereActor;
sphereActor->SetMapper(sphereMapper.Get());
vtkNew<vtkConeSource> cone;
cone->SetResolution(6);
vtkNew<vtkGlyph3D> glyph;
glyph->SetInputConnection(sphere->GetOutputPort());
glyph->SetSourceConnection(cone->GetOutputPort());
glyph->SetVectorModeToUseNormal();
glyph->SetScaleModeToScaleByVector();
glyph->SetScaleFactor(0.25);
vtkNew<vtkPolyDataMapper> spikeMapper;
spikeMapper->SetInputConnection(glyph->GetOutputPort());
vtkNew<vtkActor> spikeActor;
spikeActor->SetMapper(spikeMapper.Get());
renderer->AddActor(sphereActor.Get());
renderer->AddActor(spikeActor.Get());
renderer->SetBackground(0.4,0.5,0.6);
vtkNew<vtkTextActor> ta;
ta->SetInput("Droids Rock");
ta->GetTextProperty()->SetColor( 0.5, 1.0, 0.0 );
ta->SetDisplayPosition(50,50);
ta->GetTextProperty()->SetFontSize(32);
renderer->AddActor(ta.Get());
renWin->Render();
iren->Start();
}
我面临的问题是出现以下错误。所以也许我只是愚蠢地忘记了一些非常简单的东西,但我就是找不到为什么我会得到它。
/Users/.../Desktop/VTKNew/Common/Core/vtkNew.h:66: error: undefined reference to 'myRenderInteractor::New()' collect2: error: ld returned 1 exit status make[3]: ***
[Examples/Android/NativeVTK/libs/armeabi-v7a/libNativeVTK.so] Error 1 make[2]: ***
[Examples/Android/NativeVTK/jni/CMakeFiles/NativeVTK.dir/all] Error 2 make[1]: ***
[Examples/Android/NativeVTK/CMakeFiles/NativeVTK-apk-release.dir/rule] Error 2 make: ***
[Examples/Android/NativeVTK/CMakeFiles/NativeVTK-apk-release.dir/rule] Error 2
很想在这方面得到一些帮助。
提前致谢
编辑:在我的 Examples/Android/NativeVTK/中的 Makefile 中,我有:
# Convenience name for target.
Examples/Android/NativeVTK/CMakeFiles/NativeVTK-ant-configure.dir/rule:
cd /Users/lonnibesancon/Desktop/VTKNew/vtkbin/CMakeExternals/Build/vtk-android && $(MAKE) -f CMakeFiles/Makefile2 Examples/Android/NativeVTK/CMakeFiles/NativeVTK-ant-configure.dir/rule
.PHONY : Examples/Android/NativeVTK/CMakeFiles/NativeVTK-ant-configure.dir/rule
# Convenience name for target.
NativeVTK-ant-configure: Examples/Android/NativeVTK/CMakeFiles/NativeVTK-ant-configure.dir/rule
.PHONY : NativeVTK-ant-configure
# fast build rule for target.
NativeVTK-ant-configure/fast:
cd /Users/.../Desktop/VTKNew/vtkbin/CMakeExternals/Build/vtk-android && $(MAKE) -f Examples/Android/NativeVTK/CMakeFiles/NativeVTK-ant-configure.dir/build.make Examples/Android/NativeVTK/CMakeFiles/NativeVTK-ant-configure.dir/build
.PHONY : NativeVTK-ant-configure/fast
# Convenience name for target.
Examples/Android/NativeVTK/CMakeFiles/NativeVTK-apk-debug.dir/rule:
cd /Users/.../Desktop/VTKNew/vtkbin/CMakeExternals/Build/vtk-android && $(MAKE) -f CMakeFiles/Makefile2 Examples/Android/NativeVTK/CMakeFiles/NativeVTK-apk-debug.dir/rule
.PHONY : Examples/Android/NativeVTK/CMakeFiles/NativeVTK-apk-debug.dir/rule
# Convenience name for target.
NativeVTK-apk-debug: Examples/Android/NativeVTK/CMakeFiles/NativeVTK-apk-debug.dir/rule
.PHONY : NativeVTK-apk-debug
# fast build rule for target.
NativeVTK-apk-debug/fast:
cd /Users/.../Desktop/VTKNew/vtkbin/CMakeExternals/Build/vtk-android && $(MAKE) -f Examples/Android/NativeVTK/CMakeFiles/NativeVTK-apk-debug.dir/build.make Examples/Android/NativeVTK/CMakeFiles/NativeVTK-apk-debug.dir/build
.PHONY : NativeVTK-apk-debug/fast
# Convenience name for target.
Examples/Android/NativeVTK/CMakeFiles/NativeVTK-apk-release.dir/rule:
cd /Users/.../Desktop/VTKNew/vtkbin/CMakeExternals/Build/vtk-android && $(MAKE) -f CMakeFiles/Makefile2 Examples/Android/NativeVTK/CMakeFiles/NativeVTK-apk-release.dir/rule
.PHONY : Examples/Android/NativeVTK/CMakeFiles/NativeVTK-apk-release.dir/rule
# Convenience name for target.
NativeVTK-apk-release: Examples/Android/NativeVTK/CMakeFiles/NativeVTK-apk-release.dir/rule
.PHONY : NativeVTK-apk-release
# fast build rule for target.
NativeVTK-apk-release/fast:
cd /Users/.../Desktop/VTKNew/vtkbin/CMakeExternals/Build/vtk-android && $(MAKE) -f Examples/Android/NativeVTK/CMakeFiles/NativeVTK-apk-release.dir/build.make Examples/Android/NativeVTK/CMakeFiles/NativeVTK-apk-release.dir/build
.PHONY : NativeVTK-apk-release/fast
所以我认为我应该检查包含以下内容的 build.make:
# CMAKE generated file: DO NOT EDIT!
# Generated by "Unix Makefiles" Generator, CMake Version 3.1
#=============================================================================
# Special targets provided by cmake.
# Disable implicit rules so canonical targets will work.
.SUFFIXES:
# Remove some rules from gmake that .SUFFIXES does not remove.
SUFFIXES =
.SUFFIXES: .hpux_make_needs_suffix_list
# Suppress display of executed commands.
$(VERBOSE).SILENT:
# A target that is always out of date.
cmake_force:
.PHONY : cmake_force
#=============================================================================
# Set environment variables for the build.
# The shell in which to execute make rules.
SHELL = /bin/sh
# The CMake executable.
CMAKE_COMMAND = /usr/local/Cellar/cmake/3.1.2/bin/cmake
# The command to remove a file.
RM = /usr/local/Cellar/cmake/3.1.2/bin/cmake -E remove -f
# Escaping for special characters.
EQUALS = =
# The top-level source directory on which CMake was run.
CMAKE_SOURCE_DIR = /Users/.../Desktop/VTKNew
# The top-level build directory on which CMake was run.
CMAKE_BINARY_DIR = /Users/.../Desktop/VTKNew/vtkbin/CMakeExternals/Build/vtk-android
# Utility rule file for NativeVTK-apk-debug.
# Include the progress variables for this target.
include Examples/Android/NativeVTK/CMakeFiles/NativeVTK-apk-debug.dir/progress.make
Examples/Android/NativeVTK/CMakeFiles/NativeVTK-apk-debug:
cd /Users/.../Desktop/VTKNew/vtkbin/CMakeExternals/Build/vtk-android/Examples/Android/NativeVTK && /usr/local/bin/ant -file /Users/.../Desktop/VTKNew/vtkbin/CMakeExternals/Build/vtk-android/Examples/Android/NativeVTK/build.xml debug
NativeVTK-apk-debug: Examples/Android/NativeVTK/CMakeFiles/NativeVTK-apk-debug
NativeVTK-apk-debug: Examples/Android/NativeVTK/CMakeFiles/NativeVTK-apk-debug.dir/build.make
.PHONY : NativeVTK-apk-debug
# Rule to build all files generated by this target.
Examples/Android/NativeVTK/CMakeFiles/NativeVTK-apk-debug.dir/build: NativeVTK-apk-debug
.PHONY : Examples/Android/NativeVTK/CMakeFiles/NativeVTK-apk-debug.dir/build
Examples/Android/NativeVTK/CMakeFiles/NativeVTK-apk-debug.dir/clean:
cd /Users/.../Desktop/VTKNew/vtkbin/CMakeExternals/Build/vtk-android/Examples/Android/NativeVTK && $(CMAKE_COMMAND) -P CMakeFiles/NativeVTK-apk-debug.dir/cmake_clean.cmake
.PHONY : Examples/Android/NativeVTK/CMakeFiles/NativeVTK-apk-debug.dir/clean
Examples/Android/NativeVTK/CMakeFiles/NativeVTK-apk-debug.dir/depend:
cd /Users/.../Desktop/VTKNew/vtkbin/CMakeExternals/Build/vtk-android && $(CMAKE_COMMAND) -E cmake_depends "Unix Makefiles" /Users/.../Desktop/VTKNew /Users/.../Desktop/VTKNew/Examples/Android/NativeVTK /Users/.../Desktop/VTKNew/vtkbin/CMakeExternals/Build/vtk-android /Users/.../Desktop/VTKNew/vtkbin/CMakeExternals/Build/vtk-android/.../Android/NativeVTK /Users/.../Desktop/VTKNew/vtkbin/CMakeExternals/Build/vtk-android/.../Android/NativeVTK/CMakeFiles/NativeVTK-apk-debug.dir/DependInfo.cmake --color=$(COLOR)
.PHONY : Examples/Android/NativeVTK/CMakeFiles/NativeVTK-apk-debug.dir/depend
那是我需要更改的文件吗?坦率地说,我完全迷路了,并且很想获得更多关于整个过程的文档,因为由于某种原因我无法使用 cmake。当然,我宁愿不必求助于直接修改 makefile,但现在看来我别无选择。
最佳答案
这看起来像是您在库中定义了 myRenderInteractor,但随后忘记通过 target_link_libraries 将您的可执行文件链接到该库。
根据您问题中的错误输出,您从 ld 收到“ undefined reference ”错误——这是一个链接器错误。您的代码编译得很好。您需要将包含 myRenderInteractor 的库添加到链接到最终可执行文件的库列表中。如果您不使用 CMake 生成涉及的 makefile,那么您需要将库名称添加到您手工制作的 make 文件中链接的事物列表中。
关于c++ - VTK继承问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33236405/
关闭。这个问题是off-topic .它目前不接受答案。 想要改进这个问题? Update the question所以它是on-topic用于堆栈溢出。 关闭 12 年前。 Improve thi
我有一个动态网格,其中的数据功能需要正常工作,这样我才能逐步复制网格中的数据。假设在第 5 行中,我输入 10,则从第 6 行开始的后续行应从 11 开始读取,依此类推。 如果我转到空白的第一行并输入
我有一个关于我的按钮消失的问题 我已经把一个图像作为我的按钮 用这个函数动画 function example_animate(px) { $('#cont
我有一个具有 Facebook 连接和经典用户名/密码登录的网站。目前,如果用户单击 facebook_connect 按钮,系统即可运行。但是,我想将现有帐户链接到 facebook,因为用户可以选
我有一个正在为 iOS 开发的应用程序,该应用程序执行以下操作 加载和设置注释并启动核心定位和缩放到位置。 map 上有很多注释,从数据加载不会花很长时间,但将它们实际渲染到 map 上需要一段时间。
我被推荐使用 Heroku for Ruby on Rails 托管,到目前为止,我认为我真的会喜欢它。只是想知道是否有人可以帮助我找出问题所在。 我按照那里的说明在该网站上创建应用程序,创建并提交
我看过很多关于 SSL 错误的帖子和信息,我自己也偶然发现了一个。 我正在尝试使用 GlobalSign CA BE 证书通过 Android WebView 访问网页,但出现了不可信错误。 对于大多
我想开始使用 OpenGL 3+ 和 4,但我在使用 Glew 时遇到了问题。我试图将 glew32.lib 包含在附加依赖项中,并且我已将库和 .dll 移动到主文件夹中,因此不应该有任何路径问题。
我已经盯着这两个下载页面的源代码看了一段时间,但我似乎找不到问题。 我有两个下载页面,一个 javascript 可以工作,一个没有。 工作:http://justupload.it/v/lfd7不是
我一直在使用 jQuery,只是尝试在单击链接时替换文本字段以及隐藏/显示内容项。它似乎在 IE 中工作得很好,但我似乎无法让它在 FF 中工作。 我的 jQuery: $(function() {
我正在尝试为 NDK 编译套接字库,但出现以下两个错误: error: 'close' was not declared in this scope 和 error: 'min' is not a m
我正在使用 Selenium 浏览器自动化框架测试网站。在测试过程中,我切换到特定的框架,我们将其称为“frame_1”。后来,我在 Select 类中使用了 deselectAll() 方法。不久之
我正在尝试通过 Python 创建到 Heroku PostgreSQL 数据库的连接。我将 Windows10 与 Python 3.6.8 和 PostgreSQL 9.6 一起使用。 我从“ht
我有一个包含 2 列的数据框,我想根据两列之间的比较创建第三列。 所以逻辑是:第 1 列 val = 3,第 2 列 val = 4,因此新列值什么都没有 第 1 列 val = 3,第 2 列 va
我想知道如何调试 iphone 5 中的 css 问题。 我尝试使用 firelite 插件。但是从纵向旋转到横向时,火石占据了整个屏幕。 有没有其他方法可以调试 iphone 5 中的 css 问题
所以我有点难以理解为什么这不起作用。我正在尝试替换我正在处理的示例站点上的类别复选框。我试图让它做以下事情:未选中时以一种方式出现,悬停时以另一种方式出现(选中或未选中)选中时以第三种方式出现(而不是
Javascript CSS 问题: 我正在使用一个文本框来写入一个 div。我使用以下 javascript 获取文本框来执行此操作: function process_input(){
你好,我很难理解 P、NP 和多项式时间缩减的主题。我试过在网上搜索它并问过我的一些 friend ,但我没有得到任何好的答案。 我想问一个关于这个话题的一般性问题: 设 A,B 为 P 中的语言(或
你好,我一直在研究 https://leetcode.com/problems/2-keys-keyboard/并想到了这个动态规划问题。 您从空白页上的“A”开始,完成后得到一个数字 n,页面上应该
我正在使用 Cocoapods 和 KIF 在 Xcode 服务器上运行持续集成。我已经成功地为一个项目设置了它来报告每次提交。我现在正在使用第二个项目并收到错误: Bot Issue: warnin
我是一名优秀的程序员,十分优秀!