Giter Site home page Giter Site logo

cmake_examples's Introduction

cmake演示

problem

标准工程文件CMake文档存在问题

/usr/bin/ld: cannot find -lLIBPATHS-NOTFOUND/bin  
collect2: error: ld returned 1 exit status

应该是没有先生成库文件的问题?

标准项目cmake内容

#使用的cmake版本,必填,根据实际项目而定
cmake_minimum_required(VERSION 3.0)

#工程名称,自定义
project (SDK)
#添加指定目录下的源文件(.c/.cpp源文件)
aux_source_directory(${CMAKE_CURRENT_LIST_DIR}/src/  SRC_LIST_SDK )
#设置需要编译的源文件
list (APPEND SRC_LIST_ALL  ${SRC_LIST_SDK})

#添加需要编译的头文件
include_directories(${CMAKE_CURRENT_LIST_DIR}/include/)

#设置编译参数
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${LOCAL_W_FLAGS} ${LOCAL_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LOCAL_W_FLAGS} ${LOCAL_C_FLAGS} -std=c++14 ")

#设置链接的库
link_directories(${CMAKE_CURRENT_LIST_DIR}/lib/)
#设置链接的库
link_libraries(xxx)

#生成目标文件为可执行文件
add_executable(SDK ${SRC_LIST_ALL})

#链接为最终的可执行文件
target_link_libraries(SDK)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.