我正在使用已经使用CMake的现有项目评估CLion 1.2.1.该项目由一些库模块和一个可执行文件组成.
我有一个安装目标,我用它来收集可执行文件和一个配置文件在bin文件夹中进行调试:
...
install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_BINARY_DIR}/bin/)
install(FILES config.xml DESTINATION ${CMAKE_BINARY_DIR}/bin/)
Run Code Online (Sandbox Code Playgroud)
在命令行上构建时,我只是运行:
make install
Run Code Online (Sandbox Code Playgroud)
正如预期的那样构建二进制文件,如果成功,则运行上述安装命令.
我的问题是我无法让CLion运行'install'目标.我希望能够创建一个新的运行/调试配置,但Target:下拉列表仅包含使用add_executable()和add_library()添加的目标.
我还尝试在"设置"对话框的"构建"选项中添加"安装".然而,现在每个目标运行安装,包括'clean',这是不正确的.
我试图通过定义一个类模板来编写一个基本的编译时版本,std::accumulate()该模板将递归迭代给定的范围并在每次迭代时添加元素.
使用gcc 4.8.4on 编译测试程序时Ubuntu 14.04,出现以下错误:
compile-time-accumulate.cpp: In function ‘int main()’:
compile-time-accumulate.cpp:44:40: error: call to non-constexpr function ‘std::vector<_Tp, _Alloc>::const_iterator std::vector<_Tp, _Alloc>::cbegin() const [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::const_iterator = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >; typename __gnu_cxx::__alloc_traits<typename std::_Vector_base<_Tp, _Alloc>::_Tp_alloc_type>::const_pointer = const int*]’
v.cbegin(),
^
compile-time-accumulate.cpp:46:32: error: ‘class __gnu_cxx::__normal_iterator<const int*, std::vector<int> >’ is not a valid type for a template non-type parameter
0>::value;
Run Code Online (Sandbox Code Playgroud)
这是代码:
#include <iostream>
#include <vector>
template
< …Run Code Online (Sandbox Code Playgroud) 我正在尝试从Visual Studio迁移到Jetbrains(非常棒)的CLion IDE,它使用CMake来组织项目.
到目前为止,过渡是顺利的:创建CMake项目并将它们导入CLion很容易,我可以开始在一个平台上编码然后继续在另一个平台上没有问题.
但是,Visual Studio中的一个方面,我找不到一个相当于CMake的是属性表:我使用它们主要用于保持包括目录路径和图书馆链接库(即一个.vsprops文件,每个库,例如OpenCV.vsprops,Boost.vsprops,等等.).
这样,在VS中,我可以.vsprops在不同项目之间共享库文件,而无需每次都配置路径/库.
CMake是否有与Visual Studio属性表类似的机制?如何将库的includes/lib存储在CMake可解析文件中,然后在CMakeLists.txt中"导入"它以便链接到库?
基本上,我想要做的是:
link_target_to_libs(myTarget "path/to/propertySheet1" "path/to/propertySheet2" ...).目前我已经开始使用auto关键字.我对此有一些疑问:
如果我需要遍历vector我:
vector<int>v;
for(auto it : v){
cout << it <<endl;
}
Run Code Online (Sandbox Code Playgroud)
但是假设我需要做以下事情:
vector<int>v;
for(auto it:v){
for(auto jt:X){
//where X is next position of it's position
//What I mean is if it is currently at 2nd position then
//jt iterator will start from 3rd position
}
}
Run Code Online (Sandbox Code Playgroud)
我完全不知道该怎么做.请建议适当的方法.提前谢谢.
我正在尝试用Java实现前馈神经网络.我创建了三个类NNeuron,NLayer和NNetwork."简单"计算似乎很好(我得到正确的总和/激活/输出),但是当涉及到培训过程时,我似乎没有得到正确的结果.谁能告诉我我做错了什么?NNetwork类的整个代码很长,所以我发布导致问题的部分:[编辑]:这实际上几乎都是NNetwork类
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class NNetwork
{
public static final double defaultLearningRate = 0.4;
public static final double defaultMomentum = 0.8;
private NLayer inputLayer;
private ArrayList<NLayer> hiddenLayers;
private NLayer outputLayer;
private ArrayList<NLayer> layers;
private double momentum = NNetwork1.defaultMomentum; // alpha: momentum, default! 0.3
private ArrayList<Double> learningRates;
public NNetwork (int nInputs, int nOutputs, Integer... neuronsPerHiddenLayer)
{
this(nInputs, nOutputs, Arrays.asList(neuronsPerHiddenLayer));
}
public NNetwork (int nInputs, int nOutputs, List<Integer> neuronsPerHiddenLayer)
{
// the number of neurons on the last …Run Code Online (Sandbox Code Playgroud) 按照本教程http://cases.azoft.com/android-tutorial-floating-activity/后,我能够创建一个浮动活动.
但是,要这样做,我必须添加以下内容styles.xml:
<item name="android:windowIsTranslucent">true</item>
Run Code Online (Sandbox Code Playgroud)
是否可以仅使用Android/Java代码获得相同的效果?(例如在Activity.onAttachedToWindow()...中)
在此先感谢您的帮助.
[编辑01] styles.xml不能改变(我不应该知道它里面有什么......).但出于测试目的,我使用的是默认值:
<resources>
<style name="AppBaseTheme" parent="Theme.AppCompat.Light">
</style>
<style name="AppTheme" parent="AppBaseTheme">
</style>
</resources>
Run Code Online (Sandbox Code Playgroud)
[编辑02] Resources.Theme.applyStyle()似乎做我想要的(根据API描述:"将新属性值放入主题").所以我创建了以下内容custom_style.xml:
<resources>
<style name="MyCustomStyle" >
<item name="android:windowIsTranslucent">true</item>
</style>
</resources>
Run Code Online (Sandbox Code Playgroud)
然后,onAttachedToWindow()我打电话给:
getTheme().applyStyle(R.style.MyCustomStyle, true);
Run Code Online (Sandbox Code Playgroud)
但它没有任何影响......
android android-layout android-theme android-windowmanager android-styles
我有一个图像,我知道该图像的四个坐标,现在我只想在这四个点形成的轮廓上放置另一个小图像.这个轮廓几乎是一个正方形.有没有办法用图像填充这个轮廓点?
我试图创建一个矩形,但我不能使用多个点创建一个矩形.我被卡住了.找不到任何解决方案.
我想在2个进程(A和B)之间使用2个命名管道(a2b和b2a)交换数据,如下所示:
A创建a2b和b2a管道mkfifo(3).A启动流程B(使用fork(),exec*()甚至system())A等到B open()s a2b和b2aA write()的数据 a2bB read()来自的数据 a2bB write()的数据 b2aA read()来自的数据 b2a如何让进程A等待进程B open()s命名管道的另一端? - 即如何实施第3步?
编辑1:正如@EJP所提到的,可以使用读/写/选择来实现步骤3.但是,我想知道是否还有其他方法.