Git Product home page Git Product logo

c_cpp_project_framework's Introduction

c_cpp_project_framework's People

Contributors

neutree avatar skb666 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

c_cpp_project_framework's Issues

如何添加复杂开源组件

如果想向 components 内添加其它开源组件
如 libevent、openssl 这种用 autoconfig 或者 make/cmake 自组织编译的复杂组件
应该如何与该项目配合编译呢

组件分类

建议组件 components 分为 3 类:

  1. 全局 SDK 组件,目录 components
  2. 项目共享组件,目录 <project_path_name>/components,例: examples/components
  3. 项目私有组件,目录 <project_path_name>/<project_name>/<component_name>,例: examples/demo1/libabc

场景说明: 多个独立项目,每个独立项目包含几个子项目,子项目用到一些组件可以放项目私有组件目录[3],多个子项目共享组件放到项目共享组件目录[2],每个独立项目都用的 SDK 的组件放到全局 SDK 组件目录[1]。

其他说明:
项目共享组件的使用场景:独立项目的 test 代码以及 examples,用到与改项目相同的组件;
这个编译框架作为跟 vcpkg 这样的基础设施,独立于项目之外工作,更方便复用和推广;
方便后期定制 vscode 插件;

Building a dynamic library using libmaix

I am trying to build a dynamic library using libmaix but I cannot.
I want to build libZMQ library,

I copied the hello_world example in libmaix, I have put all sources in main/src and includes in main/include

I have added to /libmaix/examples/libzmq/main/CMakeLists.txt
list(APPEND ADD_DEFINITIONS -fPIC)
and register_component(SHARED)
I see in the logs that compile.cmake has activated to_dynamic_lib flag.
But, after compiling everything, it ends with the following error:
.....
[ 95%] Building CXX object main/CMakeFiles/main.dir/src/zmq_utils.cpp.o
[ 96%] Building CXX object main/CMakeFiles/main.dir/src/zmtp_engine.cpp.o
[ 97%] Linking CXX shared library libmain.so
[ 97%] Built target main
Scanning dependencies of target libzmq
[ 98%] Building C object CMakeFiles/libzmq.dir/exe_src.c.o
[ 99%] Linking C executable libzmq
/opt/toolchain-sunxi-musl/toolchain/bin/../lib/gcc/arm-openwrt-linux-muslgnueabi/6.4.1/../../../../arm-openwrt-linux-muslgnueabi/lib/crt1.o: In function _start_c': /home/caiyongheng/tina/out/astar-parrot/compile_dir/toolchain/musl-1.1.16/crt/crt1.c:17: undefined reference to main'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/libzmq.dir/build.make:89: libzmq] Error 1
make[1]: *** [CMakeFiles/Makefile2:301: CMakeFiles/libzmq.dir/all] Error 2
make: *** [Makefile:84: all] Error 2
....

怎样给 toolchain 文件传递参数

当使用 --toolchain 指定文件时,是否有方法给该 .cmake 文件传递参数

场景

Android 平台 termux 下该模板配合 vcpkg 进行使用,指定 --toolchain${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake

使用 cmake 编译时,我可以这样进行参数传递:

cmake -S. -Bbuild -DVCPKG_HOST_TRIPLET=arm64-linux -DVCPKG_TARGET_TRIPLET=arm64-linux 

但使用 project.py build 时,使用以下命令进行构建时会显示帮助信息,不能成功构建:

./project.py build -DVCPKG_HOST_TRIPLET=arm64-linux -DVCPKG_TARGET_TRIPLET=arm64-linux

尝试及想法

通过修改 tools/cmake/project.py 中参数的解析方式:

# project_args = project_parser.parse_args()
project_args, other_args = project_parser.parse_known_args()

然后在 build 的处理中,将 other_args 里的参数补充传递给 cmake 去执行,使得可以使用上面的命令构建成功。

但是在 ./project.py build 时传参感觉不是那么优雅,怎样才可以使参数传递这个步骤在 ./project.py config 时完成

Building a dynamic library using libmaix

I am trying to build a dynamic library using libmaix but I cannot.
I want to build libZMQ library,

I copied the hello_world example in libmaix, I have put al sources in main/src and includes in main/include

I have added to /libmaix/examples/libzmq/main/CMakeLists.txt
list(APPEND ADD_DEFINITIONS -fPIC)
and register_component(SHARED)
I see in the logs that compile.cmake has activated to_dynamic_lib flag.
But, after compiling everything, it ends with the following error:
.....
[ 95%] Building CXX object main/CMakeFiles/main.dir/src/zmq_utils.cpp.o
[ 96%] Building CXX object main/CMakeFiles/main.dir/src/zmtp_engine.cpp.o
[ 97%] Linking CXX shared library libmain.so
[ 97%] Built target main
Scanning dependencies of target libzmq
[ 98%] Building C object CMakeFiles/libzmq.dir/exe_src.c.o
[ 99%] Linking C executable libzmq
/opt/toolchain-sunxi-musl/toolchain/bin/../lib/gcc/arm-openwrt-linux-muslgnueabi/6.4.1/../../../../arm-openwrt-linux-muslgnueabi/lib/crt1.o: In function _start_c': /home/caiyongheng/tina/out/astar-parrot/compile_dir/toolchain/musl-1.1.16/crt/crt1.c:17: undefined reference to main'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/libzmq.dir/build.make:89: libzmq] Error 1
make[1]: *** [CMakeFiles/Makefile2:301: CMakeFiles/libzmq.dir/all] Error 2
make: *** [Makefile:84: all] Error 2
.......
CMakeLists.txt

使用 cmake 编译时的代码版本问题

编译命令:

cd examples/demo1
cmake -S. -Bbuild
cmake --build build -t all

使用 cmake 而不是 python 进行编译时,若不指定 CMAKE_BUILD_TYPE ,遇到以下问题:

bug

原因应该是 compile.cmake 中版本判断错误,导致 global_config.hDEBUGRELEASE 定义的值与传入的宏不一致。

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.