当前位置: 首页 > news >正文

招标网站开发文档vs做的网站如何使用

招标网站开发文档,vs做的网站如何使用,外贸公司怎么注册,龙岩seo目录 一、编译动静态库 二、链接静态库 三、链接动态库 前情提示#xff1a;【Make编译控制 07】CMake常用命令-CSDN博客 有些时候我们编写的源代码并不需要将他们编译生成可执行程序#xff0c;而是生成一些静态库或动态库提供给第三方使用#xff0c;所以我们需要用到…目录 一、编译动静态库 二、链接静态库 三、链接动态库 前情提示【Make编译控制 07】CMake常用命令-CSDN博客 有些时候我们编写的源代码并不需要将他们编译生成可执行程序而是生成一些静态库或动态库提供给第三方使用所以我们需要用到 add_library 命令来生成库。 一、编译动静态库 add_library(库名称 库类型 源文件1 [源文件2] ...) # 编译动态库 add_library(库名称 SHARED 源文件1 [源文件2] ...) # 在Linux中动态库名字分为三部分lib库名字.so # 此处只需要指定出库的名字就可以了另外两部分在生成该文件的时候会自动填充。# 编译静态库 add_library(库名称 STATIC 源文件1 [源文件2] ...) # 在Linux中静态库名字分为三部分lib库名字.a # 和动态库一样只用写出库名。# 在Windows中虽然库名和Linux格式不同但也只需指定出名字即可。 (base) [rootlocalhost 10_test]# tree . . ├── CMakeLists.txt ├── include │ ├── add.h │ └── sub.h └── src├── add.cpp├── main.cpp└── sub.cpp2 directories, 6 files (base) [rootlocalhost 10_test]# # CMakeLists.txt 文件cmake_minimum_required(VERSION 2.8) project(MATH) set(CMAKE_CXX_STANDARD 11)include_directories(${PROJECT_SOURCE_DIR}/include)aux_source_directory(${CMAKE_SOURCE_DIR}/src SRC_LIST) list(REMOVE_ITEM SRC_LIST ${CMAKE_SOURCE_DIR}/src/main.cpp)# ----------------- 编译静态库 ----------------- set(LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/lib) # EXECUTABLE_OUTPUT_PATH 用于指定输出路径 # 在Linux下生成的动态库默认是有执行权限的所以可以直接用 EXECUTABLE_OUTPUT_PATH 宏 # Linux下生成的静态库默认不具有可执行权限所以需要用 LIBRARY_OUTPUT_PATH 宏 # LIBRARY_OUTPUT_PATH 宏对静态库和动态库都适用add_library(myaddsub STATIC ${SRC_LIST}) # add_library(myaddsub SHARED ${SRC_LIST}) (base) [rootlocalhost build]# cmake .. -- The C compiler identification is GNU 4.8.5 -- The CXX compiler identification is GNU 4.8.5 -- Check for working C compiler: /usr/bin/cc -- Check for working C compiler: /usr/bin/cc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working CXX compiler: /usr/bin/c -- Check for working CXX compiler: /usr/bin/c -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Configuring done -- Generating done -- Build files have been written to: /root/gitee/Test/Make_Learn/10_test/build (base) [rootlocalhost build]# make Scanning dependencies of target myaddsub [ 50%] Building CXX object CMakeFiles/myaddsub.dir/src/add.cpp.o [100%] Building CXX object CMakeFiles/myaddsub.dir/src/sub.cpp.o Linking CXX static library ../lib/libmyaddsub.a [100%] Built target myaddsub (base) [rootlocalhost build]# tree .. .. ├── build │ ├── CMakeCache.txt │ ├── CMakeFiles │ │ ├── 2.8.12.2 │ │ │ ├── CMakeCCompiler.cmake │ │ │ ├── CMakeCXXCompiler.cmake │ │ │ ├── CMakeDetermineCompilerABI_C.bin │ │ │ ├── CMakeDetermineCompilerABI_CXX.bin │ │ │ ├── CMakeSystem.cmake │ │ │ ├── CompilerIdC │ │ │ │ ├── a.out │ │ │ │ └── CMakeCCompilerId.c │ │ │ └── CompilerIdCXX │ │ │ ├── a.out │ │ │ └── CMakeCXXCompilerId.cpp │ │ ├── cmake.check_cache │ │ ├── CMakeDirectoryInformation.cmake │ │ ├── CMakeOutput.log │ │ ├── CMakeTmp │ │ ├── Makefile2 │ │ ├── Makefile.cmake │ │ ├── myaddsub.dir │ │ │ ├── build.make │ │ │ ├── cmake_clean.cmake │ │ │ ├── cmake_clean_target.cmake │ │ │ ├── CXX.includecache │ │ │ ├── DependInfo.cmake │ │ │ ├── depend.internal │ │ │ ├── depend.make │ │ │ ├── flags.make │ │ │ ├── link.txt │ │ │ ├── progress.make │ │ │ └── src │ │ │ ├── add.cpp.o │ │ │ └── sub.cpp.o │ │ ├── progress.marks │ │ └── TargetDirectories.txt │ ├── cmake_install.cmake │ └── Makefile ├── CMakeLists.txt ├── include │ ├── add.h │ └── sub.h ├── lib │ └── libmyaddsub.a └── src├── add.cpp├── main.cpp└── sub.cpp11 directories, 38 files 二、链接静态库 link_libraries(static lib [static lib...]) # 参数1指定出要链接的静态库的名字可以是完整库名也可以是去掉前后缀的库名 # 参数2-N要链接的其它静态库的名字 cmake_minimum_required(VERSION 2.8) project(MATH) set(CMAKE_CXX_STANDARD 11)include_directories(${PROJECT_SOURCE_DIR}/include)aux_source_directory(${CMAKE_SOURCE_DIR}/src SRC_LIST) list(REMOVE_ITEM SRC_LIST ${CMAKE_SOURCE_DIR}/src/main.cpp)# ----------------- 编译静态库 ----------------- set(LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/lib) # EXECUTABLE_OUTPUT_PATH 用于指定输出路径 # 在Linux下生成的动态库默认是有执行权限的所以可以直接用 EXECUTABLE_OUTPUT_PATH 宏 # Linux下生成的静态库默认不具有可执行权限所以需要用 LIBRARY_OUTPUT_PATH 宏 # LIBRARY_OUTPUT_PATH 宏对静态库和动态库都适用add_library(myaddsub STATIC ${SRC_LIST}) # add_library(myaddsub SHARED ${SRC_LIST})# ----------------- 链接静态库 ----------------- link_libraries(myaddsub)set(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/workspace) add_executable(app ${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp) (base) [rootlocalhost build]# cmake .. -- The C compiler identification is GNU 4.8.5 -- The CXX compiler identification is GNU 4.8.5 -- Check for working C compiler: /usr/bin/cc -- Check for working C compiler: /usr/bin/cc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working CXX compiler: /usr/bin/c -- Check for working CXX compiler: /usr/bin/c -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Configuring done -- Generating done -- Build files have been written to: /root/gitee/Test/Make_Learn/10_test/build (base) [rootlocalhost build]# make Scanning dependencies of target myaddsub [ 33%] Building CXX object CMakeFiles/myaddsub.dir/src/add.cpp.o [ 66%] Building CXX object CMakeFiles/myaddsub.dir/src/sub.cpp.o Linking CXX static library ../lib/libmyaddsub.a [ 66%] Built target myaddsub Scanning dependencies of target app [100%] Building CXX object CMakeFiles/app.dir/src/main.cpp.o Linking CXX executable ../workspace/app [100%] Built target app (base) [rootlocalhost build]# tree .. .. ├── build │ ├── CMakeCache.txt │ ├── CMakeFiles │ │ ├── 2.8.12.2 │ │ │ ├── CMakeCCompiler.cmake │ │ │ ├── CMakeCXXCompiler.cmake │ │ │ ├── CMakeDetermineCompilerABI_C.bin │ │ │ ├── CMakeDetermineCompilerABI_CXX.bin │ │ │ ├── CMakeSystem.cmake │ │ │ ├── CompilerIdC │ │ │ │ ├── a.out │ │ │ │ └── CMakeCCompilerId.c │ │ │ └── CompilerIdCXX │ │ │ ├── a.out │ │ │ └── CMakeCXXCompilerId.cpp │ │ ├── app.dir │ │ │ ├── build.make │ │ │ ├── cmake_clean.cmake │ │ │ ├── CXX.includecache │ │ │ ├── DependInfo.cmake │ │ │ ├── depend.internal │ │ │ ├── depend.make │ │ │ ├── flags.make │ │ │ ├── link.txt │ │ │ ├── progress.make │ │ │ └── src │ │ │ └── main.cpp.o │ │ ├── cmake.check_cache │ │ ├── CMakeDirectoryInformation.cmake │ │ ├── CMakeOutput.log │ │ ├── CMakeTmp │ │ ├── Makefile2 │ │ ├── Makefile.cmake │ │ ├── myaddsub.dir │ │ │ ├── build.make │ │ │ ├── cmake_clean.cmake │ │ │ ├── cmake_clean_target.cmake │ │ │ ├── CXX.includecache │ │ │ ├── DependInfo.cmake │ │ │ ├── depend.internal │ │ │ ├── depend.make │ │ │ ├── flags.make │ │ │ ├── link.txt │ │ │ ├── progress.make │ │ │ └── src │ │ │ ├── add.cpp.o │ │ │ └── sub.cpp.o │ │ ├── progress.marks │ │ └── TargetDirectories.txt │ ├── cmake_install.cmake │ └── Makefile ├── CMakeLists.txt ├── include │ ├── add.h │ └── sub.h ├── lib │ └── libmyaddsub.a ├── src │ ├── add.cpp │ ├── main.cpp │ └── sub.cpp └── warkspace└── app14 directories, 49 files (base) [rootlocalhost build]# ../workspace/app 10 5 15 10 - 5 5 (base) [rootlocalhost build]# 三、链接动态库 target_link_libraries(target PRIVATE|PUBLIC|INTERFACE item... [PRIVATE|PUBLIC|INTERFACE item...]...)target指定要加载动态库的文件的名字 该文件可能是一个源文件该文件可能是一个动态库文件该文件可能是一个可执行文件 PRIVATE|PUBLIC|INTERFACE动态库的访问权限默认为PUBLIC 如果各个动态库之间没有依赖关系无需做任何设置三者没有没有区别一般无需指定使用默认的 PUBLIC 即可。动态库的链接具有传递性如果动态库 A 链接了动态库B、C动态库D链接了动态库A此时动态库D相当于也链接了动态库B、C并可以使用动态库B、C中定义的方法。 动态库的链接和静态库是完全不同的 静态库会在生成可执行程序的链接阶段被打包到可执行程序中所以可执行程序启动静态库就被加载到内存中了。动态库在生成可执行程序的链接阶段不会被打包到可执行程序中当可执行程序被启动并且调用了动态库中的函数的时候动态库才会被加载到内存。 因此在cmake中指定要链接的动态库的时候应该将命令写到生成了可执行文件之后 # CMakeLists.txt 文件cmake_minimum_required(VERSION 2.8) project(MATH) set(CMAKE_CXX_STANDARD 11)include_directories(${PROJECT_SOURCE_DIR}/include)aux_source_directory(${CMAKE_SOURCE_DIR}/src SRC_LIST) list(REMOVE_ITEM SRC_LIST ${CMAKE_SOURCE_DIR}/src/main.cpp)# ----------------- 编译动态库 ----------------- set(LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/lib) # EXECUTABLE_OUTPUT_PATH 用于指定输出路径 # 在Linux下生成的动态库默认是有执行权限的所以可以直接用 EXECUTABLE_OUTPUT_PATH 宏 # Linux下生成的静态库默认不具有可执行权限所以需要用 LIBRARY_OUTPUT_PATH 宏 # LIBRARY_OUTPUT_PATH 宏对静态库和动态库都适用# add_library(myaddsub STATIC ${SRC_LIST}) add_library(myaddsub SHARED ${SRC_LIST})# ----------------- 链接动态库 ----------------- set(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/workspace) add_executable(app ${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp)target_link_libraries(app myaddsub pthread) # 可以连接多个动态库 (base) [rootlocalhost build]# cmake .. -- The C compiler identification is GNU 4.8.5 -- The CXX compiler identification is GNU 4.8.5 -- Check for working C compiler: /usr/bin/cc -- Check for working C compiler: /usr/bin/cc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working CXX compiler: /usr/bin/c -- Check for working CXX compiler: /usr/bin/c -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Configuring done -- Generating done -- Build files have been written to: /root/gitee/Test/Make_Learn/10_test/build (base) [rootlocalhost build]# make Scanning dependencies of target myaddsub [ 33%] Building CXX object CMakeFiles/myaddsub.dir/src/add.cpp.o [ 66%] Building CXX object CMakeFiles/myaddsub.dir/src/sub.cpp.o Linking CXX shared library ../lib/libmyaddsub.so [ 66%] Built target myaddsub Scanning dependencies of target app [100%] Building CXX object CMakeFiles/app.dir/src/main.cpp.o Linking CXX executable ../workspace/app [100%] Built target app (base) [rootlocalhost build]# tree .. .. ├── build │ ├── CMakeCache.txt │ ├── CMakeFiles │ │ ├── 2.8.12.2 │ │ │ ├── CMakeCCompiler.cmake │ │ │ ├── CMakeCXXCompiler.cmake │ │ │ ├── CMakeDetermineCompilerABI_C.bin │ │ │ ├── CMakeDetermineCompilerABI_CXX.bin │ │ │ ├── CMakeSystem.cmake │ │ │ ├── CompilerIdC │ │ │ │ ├── a.out │ │ │ │ └── CMakeCCompilerId.c │ │ │ └── CompilerIdCXX │ │ │ ├── a.out │ │ │ └── CMakeCXXCompilerId.cpp │ │ ├── app.dir │ │ │ ├── build.make │ │ │ ├── cmake_clean.cmake │ │ │ ├── CXX.includecache │ │ │ ├── DependInfo.cmake │ │ │ ├── depend.internal │ │ │ ├── depend.make │ │ │ ├── flags.make │ │ │ ├── link.txt │ │ │ ├── progress.make │ │ │ └── src │ │ │ └── main.cpp.o │ │ ├── cmake.check_cache │ │ ├── CMakeDirectoryInformation.cmake │ │ ├── CMakeOutput.log │ │ ├── CMakeTmp │ │ ├── Makefile2 │ │ ├── Makefile.cmake │ │ ├── myaddsub.dir │ │ │ ├── build.make │ │ │ ├── cmake_clean.cmake │ │ │ ├── CXX.includecache │ │ │ ├── DependInfo.cmake │ │ │ ├── depend.internal │ │ │ ├── depend.make │ │ │ ├── flags.make │ │ │ ├── link.txt │ │ │ ├── progress.make │ │ │ └── src │ │ │ ├── add.cpp.o │ │ │ └── sub.cpp.o │ │ ├── progress.marks │ │ └── TargetDirectories.txt │ ├── cmake_install.cmake │ └── Makefile ├── CMakeLists.txt ├── include │ ├── add.h │ └── sub.h ├── lib │ └── libmyaddsub.so ├── src │ ├── add.cpp │ ├── main.cpp │ └── sub.cpp └── workspace└── app14 directories, 48 files (base) [rootlocalhost build]# ../workspace/app 10 5 15 10 - 5 5 (base) [rootlocalhost build]#
http://www.w-s-a.com/news/943627/

相关文章:

  • 自己做网站商城需要营业执照吗老外做牛排的视频网站
  • 网站推广效果的评估指标主要包括公司广告推广
  • 昆明网站建设那家好哪个网站学做凉皮
  • hype做网站动效哪里有给网站做
  • 打扑克网站推广软件设计类专业哪个最好
  • 网站设计首页网站建设意向书
  • 做网站要学那些angularjs后台管理系统网站
  • 广州白云手机网站建设学做点心上哪个网站
  • 哈尔滨网站建设步骤百度青岛代理公司
  • 怎么利用代码做网站军队 网站备案
  • 百度手机版网址免费广州seo
  • 军博做网站公司wordpress评论插件
  • 如何申请一个网站 做视频网站报错解析
  • 徐州高端网站建设无锡找做网站
  • 网站如何不需要备案百度的宣传视频广告
  • 如何用易语言做网站采购系统有哪些
  • 建一个网站容易吗浙江省城乡建设厅官网
  • 奇点网站建设黄骅贴吧百度贴吧
  • 站长爱it如何分析网站设计
  • 服装公司网站定位seo网站关键词
  • 电商网站开发流程文档南京 seo 价格
  • 网站建设任务分解张家港网站制作服务
  • 化州+网站建设网络营销怎么做推广
  • 贵阳网站设计方案阿里云 wordpress 数据库
  • 如何做购物返佣金网站高校 网站建设实施方案
  • 网站如何连接微信支付网页制作与网站开发
  • 地名网站建设方案营销型网站策划书
  • 网站优化排名查询网站图片怎么做的高级
  • 官方网站建设调研报告小程序短链接生成
  • 专做耐克阿迪鞋网站免费微信网站模板下载