Release X64平台

createdll.h
#ifndef CREARDLL_H_
#define CREARDLL_H_

extern "C" _declspec(dllexport) int add(int x, int y);/*_declspec(dllexport)声明一个导出函数,是说这个函数要从本DLL导出,我要给别人用。*/
int add(int x, int y);  //求和函数

#endif

createdll.cpp
#include"stdafx.h"  //注意不要忘了添加这个头文件
#include"creatdll.h"
#include<iostream>

int add(int x, int y)
{
    return x + y;
}

调用
#include<iostream>
#pragma comment(lib,"makeDLL.lib")

_declspec(dllimport) int add(int x, int y); //_declspec(dllimport)声明一个导入函数,是说这个函数是从别的DLL导入,我要用。

int main()
{
    std::cout << "2 + 3 = " << add(2, 3) << std::endl;

std::cin.get();
    return 0;
}

#define CPU_ONLY

包含目录:
F:\caffe-windows\include

F:\NugetPackages\boost.1.59.0.0\lib\native\include

F:\NugetPackages\glog.0.3.3.0\build\native\include

F:\NugetPackages\gflags.2.1.2.1\build\native\include

F:\NugetPackages\protobuf-v120.2.6.1\build\native\include

F:\NugetPackages\OpenBLAS.0.2.14.1\lib\native\include

F:\NugetPackages\OpenCV.2.4.10\build\native\include

E:\fengzhuangku\caffeConfigure\include\caffe

E:\fengzhuangku\caffeConfigure\include\caffe\layers

库目录:
F:\NugetPackages\lmdb-v120-clean.0.9.14.0\lib\native\lib\x64

F:\NugetPackages\LevelDB-vc120.1.2.0.0\build\native\lib\x64\v120\Release

F:\NugetPackages\OpenCV.2.4.10\build\native\lib\x64\v120\Release

F:\caffe-windows\Build\x64\Release

F:\opencv2.4.10\build\x64\vc12\lib

F:\NugetPackages\boost_date_time-vc120.1.59.0.0\lib\native\address-model-64\lib

F:\NugetPackages\boost_filesystem-vc120.1.59.0.0\lib\native\address-model-64\lib

F:\NugetPackages\boost_system-vc120.1.59.0.0\lib\native\address-model-64\lib

F:\NugetPackages\glog.0.3.3.0\build\native\lib\x64\v120\Release\dynamic

F:\NugetPackages\boost_thread-vc120.1.59.0.0\lib\native\address-model-64\lib

F:\NugetPackages\boost_chrono-vc120.1.59.0.0\lib\native\address-model-64\lib

F:\NugetPackages\gflags.2.1.2.1\build\native\x64\v120\static\Lib

F:\NugetPackages\hdf5-v120-complete.1.8.15.2\lib\native\lib\x64

F:\NugetPackages\protobuf-v120.2.6.1\build\native\lib\x64\v120\Release

F:\NugetPackages\OpenBLAS.0.2.14.1\lib\native\lib\x64

E:\fengzhuangku\caffeConfigure\lib   (libcaffe)

连接库
libboost_date_time-vc120-mt-1_59.lib
libboost_filesystem-vc120-mt-1_59.lib
libboost_system-vc120-mt-1_59.lib
libglog.lib
libcaffe.lib
gflags.lib
gflags_nothreads.lib
hdf5.lib
hdf5_hl.lib
libprotobuf.lib
libopenblas.dll.a
Shlwapi.lib
LevelDb.lib
lmdb.lib

E:\opencversiyio\build\x64\vc12\lib\opencv_video2410.lib
E:\opencversiyio\build\x64\vc12\lib\opencv_objdetect2410.lib
E:\opencversiyio\build\x64\vc12\lib\opencv_core2410.lib
E:\opencversiyio\build\x64\vc12\lib\opencv_highgui2410.lib
E:\opencversiyio\build\x64\vc12\lib\opencv_imgproc2410.lib
E:\opencversiyio\build\x64\vc12\lib\opencv_ts2410.lib
E:\opencversiyio\build\x64\vc12\lib\opencv_nonfree2410.lib
E:\opencversiyio\build\x64\vc12\lib\opencv_ocl2410.lib
E:\opencversiyio\build\x64\vc12\lib\opencv_photo2410.lib
E:\opencversiyio\build\x64\vc12\lib\opencv_stitching2410.lib
E:\opencversiyio\build\x64\vc12\lib\opencv_superres2410.lib
E:\opencversiyio\build\x64\vc12\lib\opencv_videostab2410.lib
E:\opencversiyio\build\x64\vc12\lib\opencv_calib3d2410.lib
E:\opencversiyio\build\x64\vc12\lib\opencv_contrib2410.lib
E:\opencversiyio\build\x64\vc12\lib\opencv_features2d2410.lib
E:\opencversiyio\build\x64\vc12\lib\opencv_flann2410.lib
E:\opencversiyio\build\x64\vc12\lib\opencv_gpu2410.lib
E:\opencversiyio\build\x64\vc12\lib\opencv_legacy2410.lib
E:\opencversiyio\build\x64\vc12\lib\opencv_ml2410.lib

//注册问题

#include "caffe/common.hpp" 
#include "caffe/layers/input_layer.hpp" 
#include "caffe/layers/inner_product_layer.hpp" 
#include "caffe/layers/dropout_layer.hpp" 
#include "caffe/layers/conv_layer.hpp" 
#include "caffe/layers/relu_layer.hpp"

#include "caffe/layers/pooling_layer.hpp" 
#include "caffe/layers/lrn_layer.hpp" 
#include "caffe/layers/softmax_layer.hpp" 
#include "caffe/layers/normalize_layer.hpp"
#include "caffe/layers/permute_layer.hpp"
#include "caffe/layers/flatten_layer.hpp"
#include "caffe/layers/prior_box_layer.hpp"
#include "caffe/layers/concat_layer.hpp"
#include "caffe/layers/reshape_layer.hpp"
#include "caffe/layers/softmax_layer.hpp"
#include "caffe/layers/detection_output_layer.hpp"

namespace caffe
{
extern INSTANTIATE_CLASS(InputLayer);
extern INSTANTIATE_CLASS(ConvolutionLayer);
REGISTER_LAYER_CLASS(Convolution);
extern INSTANTIATE_CLASS(InnerProductLayer);
extern INSTANTIATE_CLASS(DropoutLayer);
extern INSTANTIATE_CLASS(ReLULayer);
REGISTER_LAYER_CLASS(ReLU);
extern INSTANTIATE_CLASS(PoolingLayer);
REGISTER_LAYER_CLASS(Pooling);
extern INSTANTIATE_CLASS(LRNLayer);
//REGISTER_LAYER_CLASS(LRN);
extern INSTANTIATE_CLASS(SoftmaxLayer);
//REGISTER_LAYER_CLASS(Softmax);
extern INSTANTIATE_CLASS(NormalizeLayer);
//REGISTER_LAYER_CLASS(Normalize);
extern INSTANTIATE_CLASS(PermuteLayer);
//REGISTER_LAYER_CLASS(Permute);
extern INSTANTIATE_CLASS(FlattenLayer);
extern INSTANTIATE_CLASS(PriorBoxLayer);
extern INSTANTIATE_CLASS(ConcatLayer);
extern INSTANTIATE_CLASS(ReshapeLayer);
extern INSTANTIATE_CLASS(SoftmaxLayer);
REGISTER_LAYER_CLASS(Softmax);
extern INSTANTIATE_CLASS(DetectionOutputLayer);
}

#endif

这时还会遇到一个麻烦的问题,添加了REGISTER_LAYER_CLASS()他会报重复注册,去掉这一句又报不认识这一层。
在layer_factory.hpp里做如下更改可以解决这个问题:

把static void AddCreator(const string& type, Creator creator){}里的:
    CHECK_EQ(registry.count(type), 0)<< "Layer type " << type << " already registered.";
    registry[type] = creator;

改为:

if (registry.count(type) != 0)
{
std::cout<< "Layer type " << type << " already registered.     ";
}
else
{
registry[type] = creator;
}
这样就能确保只注册一次了。

测试库

把编译生成的dll和lib库拷贝到测试工程中。配置库,运行需要dll库

caffe 动态库 Release X64的更多相关文章

  1. 【VS工程设置】 编译动态库,命令行添加参数,不使用预编译头,指定该项目链接 哪种 运行库

    编译动态库 注意: 动态库: [目标文件扩展] => .dll + [配置类型] => 动态库(.dll) 静态库: [目标文件扩展] => .lib + [ 配置类型]=> ...

  2. 最全Windows版本jemalloc库(5.2.1)及其使用:包含动态库和静态库、x86版本和x64版本、debug版本和release版本

    编写服务器程序时,需要频繁的申请和释放内存,长时间运行会产生大量的内存碎片,这就导致即使当前系统中的闲置内存还足够多,但也无法申请到大的连续可用的内存块,因为此时的物理内存已经千疮百孔像个马蜂窝.此外 ...

  3. faster_rcnn c++版本的 caffe 封装,动态库(2)

    摘要: 转载请注明出处,楼燚(yì)航的blog,http://www.cnblogs.com/louyihang-loves-baiyan/ github上的代码链接,求给星星:) https:// ...

  4. Unity跨平台C/CPP动态库编译---可靠UDP网络库kcp基于CMake的各平台构建实践

    1.为什么需要动态库 a)提供原生代码(native code)的支持,也叫原生插件,但是我实践的是c/cpp跨平台动态库,这里不具体涉及安卓平台java库和ios平台的objectc库构建. b)某 ...

  5. c++动态库封装及调用(3、windows下动态库调用)

    1.DLL的隐式调用 隐式链接采用静态加载的方式,比较简单,需要.h..lib..dll三件套.新建“控制台应用程序”或“空项目”.配置如下: 项目->属性->配置属性->VC++ ...

  6. 详解UE4静态库与动态库的导入与使用

    转自:http://blog.csdn.net/u012999985/article/details/71554628 一.基本内容概述   最近做项目时经常看到build.cs文件,就想研究一下UE ...

  7. 在VS2015中用C++编写可被其它语言调用的动态库DLL

    转自:http://blog.csdn.net/songyi160/article/details/50754705 VS2015用C++创建动态库DLL步骤如下: (1)启动VS2015>文件 ...

  8. Java通过jna调用c++动态库

    1 环境准备 操作系统:windows 10,x64 jna,jna-4.4.0.jar c++开发环境,vc2013 java开发环境,eclipse,jdk8 2 dll开发 通过vc2013创建 ...

  9. Unity3D跨平台动态库编译---记kcp基于CMake的各平台构建实践

    一 为什么需要动态库 1)提供原生代码(native code)的支持,也叫原生插件,但是我实践的是c/cpp跨平台动态库,这里不具体涉及安卓平台java库和ios平台的objectc库构建. 2)某 ...

随机推荐

  1. ODAC(V9.5.15) 学习笔记(五)TSmartQuery

    TSmartQuery是相对于TOraQuery更简洁的数据集,其成员如下 名称 类型 说明 Expand Boolean 缺省为False,如果为True,则表示无论SQL中罗列的字段是哪些,数据集 ...

  2. HDU 6406 Taotao Picks Apples & FJUT3592 做完其他题后才能做的题(线段树)题解

    题意(FJUT翻译HDU): 钱陶陶家门前有一棵苹果树. 秋天来了,树上的n个苹果成熟了,淘淘会去采摘这些苹果. 到园子里摘苹果时,淘淘将这些苹果从第一个苹果扫到最后一个. 如果当前的苹果是第一个苹果 ...

  3. 编译caffe的Python借口,提示:ImportError: dynamic module does not define module export function (PyInit__caffe)

    >>> import caffeTraceback (most recent call last): File "<stdin>", line 1, ...

  4. InnoDB锁笔记

    InnoDB主要使用行级锁(row lock),其行锁是通过在索引项上加锁而实现的,如果MySQL的执行计划没有用到索引,那么行锁也就无意义了 InnoDB的行锁是通过给索引上的索引(聚集,非聚集)添 ...

  5. HDU 5445 Food Problem(多重背包+二进制优化)

    http://acm.hdu.edu.cn/showproblem.php?pid=5445 题意:现在你要为运动会提供食物,总共需要提供P能量的食物,现在有n种食物,每种食物能提供 t 能量,体积为 ...

  6. hdu 3832 Earth Hour bfs

    Earth Hour Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 125536/65536 K (Java/Others) Prob ...

  7. testin 测试用例管理平台

    应用信息:应用图标,应用名称,版本号,应用包名,系统平台[Android,ios,Web/H5,小程序,快应用]项目成员:成员帐号[邮箱],成员姓名,成员角色,成员职位,状态[激活,未激活],操作[移 ...

  8. django模型表单ModelForm

    如果你正在构建一个数据库驱动的应用,那么你可能会有与Django的模型紧密映射的表单.比如,你有个BlogComment模型,并且你还想创建一个表单让大家提交评论到这个模型中.在这种情况下,写一个fo ...

  9. PostgreSQL 扩展开发基础教程

    搭建基础结构 安装扩展 sudo apt-get install postgresql-contribcreatedb stupsql stucreate extension pg_buffercac ...

  10. python3.5学习第一章

    在python中,变量赋值或者其他语句后不需要加”:“ python中,缩进特别重要! 条件语句和循环语句,要加”:“ 一.变量赋值 name = "cecelia"name2 = ...