使用库移植的时候,我们首先需确认的时候,库里面有没有S7-200SMARTPLC所不支持的指令,如果有那么我们不能移植,或者说移植后需要更改。我们以模拟量转换库为例进行移植说明。
首先使用S7-200编程软件STEP7 Microwin软件调用这些库,如图所示:
程序编好后保存项目。项目保存后,打开S7-200SMART的编程软件(step7 Microwin SMART编程软件),使用这个软件打开使用S7-200编程软件编号的这个程序,然后右键点击STEP7 Microwin smart 软件指令菜单中的库指令,选择里面的创建库,然后创建一个库,如图所示:
帆辩点击属性按钮,设置库名称及保存路径。
如需要对库进行加密,点击保护选项,在里面设置密码态雀缺。库建好后,关闭编程软件重新打开软件。右键点击软件指令菜单中的库指令,选择里面的添加/删除库,岁坦添加库,如图所示:
最后点击确认按钮,这样就把这个模拟量转换库从200的编程软件中移植到200 SMART的编程软件中了。
private void button3_Click(object sender, EventArgs e)
{
this.Close()
}
private void button1_Click(object sender, EventArgs e)
{
openFileDialog1.ShowDialog()
textBox2.Text = openFileDialog1.FileName
}
private void button2_Click(object sender, EventArgs e)
{
if (textBox1.Text == "" || textBox2.Text =="" || textBox3.Text =="" || textBox4.Text =="")
{
MessageBox.Show("请选择要附加数据库的数据信息", "信息提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation)
}
else
{
DataSet ds = new DataSet()
//定义连接SQL Server数据库字符串
string consqlserver = @"Data Source=" + textBox4.Text + "Initial Catalog=MyDatasIntegrated Security=True"
//定义SQL Server连接对象
SqlConnection con = new SqlConnection(consqlserver)
try
{
con.Open()
SqlCommand cmd = new SqlCommand()
//定义附加数据库的SQL语句
cmd.CommandText = "sp_attach_db @dbname='" + textBox1.Text + "',@filename1='"+ textBox2.Text +"',@filename2='"+ textBox3.Text +"'"
//指出通过前面创建的数据库连接执行
cmd.Connection = con
//执行SQL语句
cmd.ExecuteNonQuery()
MessageBox.Show("数据库附加成功", "信息提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information)
}
catch (Exception ex)
{
MessageBox.Show("山李数据库附加失败", "信息提示"逗庆迟, System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error)
}
finally
{
con.Close()
con.Dispose()
}
}
}
private void button4_Click(object sender, EventArgs e)
{
openFileDialog1.ShowDialog()
textBox3.Text = 差孝openFileDialog1.FileName
}
这里是使用NDK进行编译boost的但肯定对我有用吧。。经过一番折腾终于编译成功,,高兴,呵呵! 转载下面将主要的雀老过程记录下来:
1、下载boost 源码:
Boost for Android
Boost for android is a set of tools to compile the main part of the Boost C++ Libraries for the Android platform.
Currently supported boost versions are 1.45.0, 1.48.0 and 1.49.0.
因此歼搜下载最新的 1.49 版本,下载完成后进行打补丁
2、下载补丁代码
boost-1_49_0
3、打补丁代码
boost_1_49_0.tar.bz2 放在android的 external 下解压:
tar -xjvf external/boost_1_49_0.tar.bz2
将boost-1_49_0.patch放在external\boost_1_49_0下面根目录执行:
patch -Np1 -d external/boost_1_49_0 <external/boost_1_49_0/boost-1_49_0.patch
4、编写boost的makefile文件,即Android.mk
LOCAL_PATH:= $(call my-dir)
common_SRC_FILES := \
顷改升libs/thread/src/pthread/thread.cpp \
libs/thread/src/pthread/once.cpp \
common_SRC_FILES += \
libs/filesystem/v3/src/codecvt_error_category.cpp \
libs/filesystem/v3/src/operations.cpp \
libs/filesystem/v3/src/path.cpp \
libs/filesystem/v3/src/path_traits.cpp \
libs/filesystem/v3/src/portability.cpp \
libs/filesystem/v3/src/utf8_codecvt_facet.cpp \
libs/system/src/error_code.cpp \
libs/system/src/local_free_on_destruction \
include $(CLEAR_VARS)
LOCAL_MODULE:= libboost
LOCAL_SRC_FILES := $(common_SRC_FILES)
prebuilt_stdcxx_PATH := prebuilts/ndk/current/sources/cxx-stl/gnu-libstdc++
LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/boost \
$(prebuilt_stdcxx_PATH)/include \
$(prebuilt_stdcxx_PATH)/libs/$(TARGET_CPU_ABI)/include/ \
LOCAL_C_INCLUDES += \
$(prebuilt_stdcxx_PATH)/include \
$(prebuilt_stdcxx_PATH)/libs/$(TARGET_CPU_ABI)/include/ \
$(prebuilt_supccxx_PATH)/include
LOCAL_CFLAGS += -fvisibility=hidden -lpthread
LOCAL_CPPFLAGS += -fexceptions -frtti
LOCAL_SHARED_LIBRARIES := libc libstdc++ libstlport
LOCAL_LDFLAGS += -L$(prebuilt_stdcxx_PATH)/libs/$(TARGET_CPU_ABI) -lgnustl_static -lsupc++
LOCAL_MODULE_TAGS := optional
include $(BUILD_SHARED_LIBRARY)
比较重要的是上面 红色 部分文字
最后编译生成:
target thumb C++: libboost <= external/boost_1_49_0/libs/thread/src/pthread/thread.cpp
target thumb C++: libboost <= external/boost_1_49_0/libs/thread/src/pthread/once.cpp
target thumb C++: libboost <= external/boost_1_49_0/libs/filesystem/v3/src/codecvt_error_category.cpp
target thumb C++: libboost <= external/boost_1_49_0/libs/filesystem/v3/src/operations.cpp
target thumb C++: libboost <= external/boost_1_49_0/libs/filesystem/v3/src/path.cpp
target thumb C++: libboost <= external/boost_1_49_0/libs/filesystem/v3/src/path_traits.cpp
target thumb C++: libboost <= external/boost_1_49_0/libs/filesystem/v3/src/portability.cpp
target thumb C++: libboost <= external/boost_1_49_0/libs/filesystem/v3/src/utf8_codecvt_facet.cpp
target thumb C++: libboost <= external/boost_1_49_0/libs/system/src/error_code.cpp
target SharedLib: libboost (out/target/product/godbox/obj/SHARED_LIBRARIES/libboost_intermediates/LINKED/libboost.so)
target Symbolic: libboost (out/target/product/godbox/symbols/system/lib/libboost.so)
target Strip: libboost (out/target/product/godbox/obj/lib/libboost.so)
Install: out/target/product/godbox/system/lib/libboost.so
成功生成 libboost.so 库
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)