小编sol*_*lti的帖子

如何在CMake文件中添加链接器或编译标志?

我正在使用arm-linux-androideabi-g++编译器.当我尝试编译一个简单的"你好,世界!" 程序编译好.当我通过在该代码中添加一个简单的异常处理来测试它时它也可以工作(添加之后-fexceptions..我猜它默认是禁用的).

这适用于Android设备,我只想使用CMake,而不是ndk-build.

例如 - first.cpp

#include <iostream>

using namespace std;

int main()
{
   try
   {
   }
   catch (...)
   {
   }
   return 0;
}
Run Code Online (Sandbox Code Playgroud)

./arm-linux-androideadi-g++ -o first-test first.cpp -fexceptions

它没有问题......

问题 ...我试图用CMake文件编译文件.

我想添加-fexceptions标志.我试过了

set (CMAKE_EXE_LINKER_FLAGS -fexceptions ) or set (CMAKE_EXE_LINKER_FLAGS "fexceptions" )
Run Code Online (Sandbox Code Playgroud)

set ( CMAKE_C_FLAGS "fexceptions")
Run Code Online (Sandbox Code Playgroud)

它仍然显示错误.

c++ cmake

196
推荐指数
4
解决办法
44万
查看次数

如何为android-ndk8b(x86 arch Android)构建i686-linux-android-gfortran?

我试着用build-gcc.sh建设的i686-Linux的Android平台的gfortran下面这个 (它是androdindk-7B),但我得到link.h.错误 我从这里添加了link.h ,但它提供了更多的错误.

有没有人尝试为x86 Android启用i686-linux-android-gfortran?

x86 android gcc fortran

40
推荐指数
1
解决办法
2439
查看次数

在android中编译boost时出错

我试图根据这个安装boost 1.5到android .

当我编译时,我收到一个错误.这是编译错误的一个片段:

gcc.compile.c++ bin.v2/libs/thread/build/gcc-android4.4.3/release/link-static/runtime-link-    static/threading-multi/pthread/thread.o
<command-line>: warning: "BOOST_FILESYSTEM_VERSION" redefined
<command-line>: warning: this is the location of the previous definition
In file included from ./boost/thread/thread.hpp:17,
             from libs/thread/src/pthread/thread.cpp:11:
./boost/thread/pthread/thread_data.hpp: In member function 'void    boost::thread_attributes::set_stack_size(size_t)':
./boost/thread/pthread/thread_data.hpp:42: error: 'PAGE_SIZE' was not declared in this scope

"../../toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-g++"  -ftemplate-depth-128 -O3 -finline-functions -Wno-inline -Wall -pedantic --sysroot=../../platforms/android-9/arch-arm -mthumb -Os -fno-strict-aliasing -O2 -DNDEBUG -g -lstdc++ -I../../sources/cxx-stl/gnu-libstdc++/include -I../../sources/cxx-stl/gnu-libstdc++/libs/armeabi/include -D__GLIBC__ -DBOOST_NO_INTRINSIC_WCHAR_T -DBOOST_FILESYSTEM_VERSION=2 -pthread -Wextra -Wno-long-long -pedantic -DBOOST_ALL_NO_LIB=1 -DBOOST_CHRONO_STATIC_LINK=1 -DBOOST_FILESYSTEM_VERSION=3 -DBOOST_SYSTEM_NO_DEPRECATED -DBOOST_SYSTEM_STATIC_LINK=1 -DBOOST_THREAD_BUILD_LIB=1 -DBOOST_THREAD_POSIX -DNDEBUG  -I"." -c -o …
Run Code Online (Sandbox Code Playgroud)

c++ android boost

5
推荐指数
2
解决办法
3147
查看次数

为什么arm-linux-androideabi-gcc会给出iostream错误

我在我的计算机上安装了arm-linux-androideabi-gcc,但是当我尝试编译一个简单的hellow世界时,它会出错(我选择不使用ndk-build).我只想从命令行编译...

#include <iostream>

using namespace std;

int main (){
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

我收到了这个错误:

错误:iostream:没有这样的文件或目录

我有arm-linux-androideabi-gcc ~/android-ndk-r8b/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin.

我试过包括 -I ~/android-ndk-r7b/platforms/android-9/arch-arm/usr

我也尝试过包括-lstdc++看它是否有效但没有......

./arm-linux-androideabi-g++ -o ff first.cpp -I /home/hari/android-ndk-r7b/platforms/android-9/arch-arm/usr -lstdc++
Run Code Online (Sandbox Code Playgroud)

linker android gcc arm

5
推荐指数
1
解决办法
4564
查看次数

如何向shared_ptr添加偏移量?

我试图为我的矩阵类创建一块内存,因为std::vector<std::vector<double>>它没有给出我想要的性能.所以我决定使用单个1d阵列.所以我想到使用double的shared_ptr.

要声明我做的变量:

std::shared_ptr<double> matrix;

为已声明的共享指针分配内存我做了:

matrix = std::make_shared<double []> (row*col);

现在访问元素以将某些内容分配给矩阵中的特定位置:

*(matrix + r*col + c) = 0.0;

这给了我错误的说法

`error:'operator +'不匹配(操作数类型是'std :: shared_ptr'和'size_t')

我以为我们可以使用+指针.为什么不让我为指针添加标量值?

c++ c++11

4
推荐指数
1
解决办法
674
查看次数

如何使用make_pair创建id和struct(对象)对?

我试图像这样创建一对id和object:

 #include <iostream>
  #include <utility>
  #include <functional>

  struct num{

      double x;
      double y;

  };


  int main(){

      auto tmp = std::make_pair(1, {1.0, 2.0});

 }
Run Code Online (Sandbox Code Playgroud)

我得到错误 error: no matching function for call to 'make_pair(int, <brace-enclosed initializer list>)'

有没有一种正确的方法来创建id和对象?

c++ c++11

4
推荐指数
1
解决办法
1723
查看次数

如何创建特定大小的 unordered_map?

我知道我们可以做到这一点std::unordered_map<key, value> my_map; 当我尝试查看它所说的大小zero以及当我尝试查看 bucket_count 时,它给出了11.

我想做的是这样的 std::unordered_map<key, value> my_map(1000);

但我得到错误 expected identifier before numeric constant

我想设置哈希表的大小,以便在向量重新分配内存(从旧内存位置(小)到新内存位置(较大)的值的副本)时不会遇到相同的问题。 Since I have large data of specific size (~100,000) that I want to hash, this motivates me to do preallocation

当我在cppreference 中看到 unordered_map 构造函数时,它需要分配器、散列函数等。我们真的需要提供这么多信息来将散列映射设置为特定大小吗?

c++ hash

3
推荐指数
1
解决办法
5052
查看次数

行进立方体和八叉树之间有什么区别?

八叉树是行进立方体的特例吗?我的意思是八叉树使用相同的行进立方体的三角形立方体.我知道八叉树是四叉树的三维形式.我只是想知道我是否正确的方向.在树形成之后,八叉树如何形成三角形(用于创建表面)与行进立方体的步骤相同?

c++ opengl marching-cubes octree

2
推荐指数
2
解决办法
2420
查看次数

为什么buildbot抛出ImportError:无法导入名称异常?

我目前正在尝试理解buildbot,并且正在完成教程的第一部分.但我被困在我应该创建主人的部分.我尝试使用网站修复错误,但仍然给我错误.

Traceback (most recent call last):
File "./bin/buildbot", line 5, in <module>
pkg_resources.run_script('buildbot==0.8.7p1', 'buildbot')
File "/home/hari/tmp/buildbot/sandbox/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 489, in run_script
File "/home/hari/tmp/buildbot/sandbox/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 1207, in run_script
File "/home/hari/tmp/buildbot/sandbox/lib/python2.7/site-packages/buildbot-0.8.7p1-py2.7.egg/EGG-INFO/scripts/buildbot", line 4, in <module>
runner.run()
File "/home/hari/tmp/buildbot/sandbox/lib/python2.7/site-packages/buildbot-0.8.7p1-py2.7.egg/buildbot/scripts/runner.py", line 696, in run
subcommandFunction = reflect.namedObject(subconfig.subcommandFunction)
File "/home/hari/tmp/buildbot/sandbox/lib/python2.7/site-packages/Twisted-13.0.0-py2.7- linux-x86_64.egg/twisted/python/_reflectpy3.py", line 151, in namedObject
module = namedModule('.'.join(classSplit[:-1]))
File "/home/hari/tmp/buildbot/sandbox/lib/python2.7/site-packages/Twisted-13.0.0-py2.7-linux-x86_64.egg/twisted/python/_reflectpy3.py", line 137, in namedModule
topLevel = __import__(name)
File "/home/hari/tmp/buildbot/sandbox/lib/python2.7/site-packages/buildbot-0.8.7p1-py2.7.egg/buildbot/scripts/create_master.py", line 23, in <module>
from buildbot.db import connector
File "/home/hari/tmp/buildbot/sandbox/lib/python2.7/site-packages/buildbot-0.8.7p1-py2.7.egg/buildbot/db/connector.py", line 22, in …
Run Code Online (Sandbox Code Playgroud)

buildbot sqlalchemy-migrate python-2.7

2
推荐指数
1
解决办法
5886
查看次数

如何设法在自定义视图组中将一个孩子带到另一个孩子面前?

我在android中创建自己的自定义视图组.我有两个孩子.一个是linearLayout(它是第一个孩子,占据屏幕的一半),上面有一些背景图像和按钮,另一个是View的扩展(它是第二个孩子,覆盖整个屏幕),我用手指画一些东西.

我希望(第一个孩子)线性布局隐藏在视图的(第二个孩子)扩展下,以便我可以使用一些手势将第二个孩子滑动到右侧(有点像google,youtube的幻灯片)并且看到第一个孩子(LinearLayout).问题出在onLayout上我按照一定的顺序放置孩子,但无论我做什么,第一个孩子(LinearLayout)总是在前面.

  secondchild.layout(0,0,top,bottom);
  firstchild.layout(0,0,top/2,bottom);
Run Code Online (Sandbox Code Playgroud)

我也试过了

  firstchild.layout(0,0,top/2,bottom);      
  secondchild.layout(0,0,top,bottom);
Run Code Online (Sandbox Code Playgroud)

但第一个孩子总是名列前茅.

服装ViewGroup的代码:

public class RootViewLayout extends ViewGroup  {
      private View mDrawView;
      private View mSlideView;
      private int mTop;
      private int mDragRange;

      public RootViewLayout(Context context, AttributeSet attrs) {
          super(context, attrs);
      }
      @Override
      protected void onFinishInflate() {
          mDrawView  = findViewById(R.id.content_frame_white);
          mSlideView = findViewById(R.id.slide_frame);       
     }
     @Override
     protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
         int widthSize = MeasureSpec.getSize(widthMeasureSpec);
         int heightSize = MeasureSpec.getSize(heightMeasureSpec);
         setMeasuredDimension(widthSize, heightSize);   
     }
     @Override
     protected void onLayout(boolean changed, int left, int top, int right, …
Run Code Online (Sandbox Code Playgroud)

layout android android-layout

2
推荐指数
1
解决办法
2753
查看次数