Neutree / c_cpp_project_framework

CMake build system( framework) with kconfig support for C/CPP projects
https://neucrack.com/p/276
MIT License
157 stars 38 forks source link

Building a dynamic library using libmaix #11

Closed pauceano closed 3 months ago

pauceano commented 3 months ago

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 tomain' 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

Neutree commented 3 months ago

dumplcate with #10